mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix puppet.fact and puppet.facts to use stdout.
facter prints non-fatal errors to stderr if cmd.run is used then this is merged into the output and breaks the parsing. This commit changes the puppet.fact and puppet.facts functions to use cmd.run_all instead.
This commit is contained in:
parent
83ed40c06a
commit
69e1f6f681
1 changed files with 13 additions and 4 deletions
|
@ -372,7 +372,12 @@ def facts(puppet=False):
|
|||
'''
|
||||
ret = {}
|
||||
opt_puppet = '--puppet' if puppet else ''
|
||||
output = __salt__['cmd.run']('facter {0}'.format(opt_puppet))
|
||||
cmd_ret = __salt__['cmd.run_all']('facter {0}'.format(opt_puppet))
|
||||
|
||||
if cmd_ret['retcode'] != 0:
|
||||
raise CommandExecutionError(cmd_ret['stderr'])
|
||||
|
||||
output = cmd_ret['stdout']
|
||||
|
||||
# Loop over the facter output and properly
|
||||
# parse it into a nice dictionary for using
|
||||
|
@ -398,9 +403,13 @@ def fact(name, puppet=False):
|
|||
salt '*' puppet.fact kernel
|
||||
'''
|
||||
opt_puppet = '--puppet' if puppet else ''
|
||||
ret = __salt__['cmd.run'](
|
||||
ret = __salt__['cmd.run_all'](
|
||||
'facter {0} {1}'.format(opt_puppet, name),
|
||||
python_shell=False)
|
||||
if not ret:
|
||||
|
||||
if ret['retcode'] != 0:
|
||||
raise CommandExecutionError(ret['stderr'])
|
||||
|
||||
if not ret['stdout']:
|
||||
return ''
|
||||
return ret
|
||||
return ret['stdout']
|
||||
|
|
Loading…
Add table
Reference in a new issue