mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add redirect_stderr argument to cmd.run_all
This allows cmd.run behavior with stderr redirected, while still returning the dictionary from cmd.run_all, including the return code.
This commit is contained in:
parent
16ebda999e
commit
9ca0f8f440
1 changed files with 11 additions and 0 deletions
|
@ -1406,6 +1406,7 @@ def run_all(cmd,
|
|||
ignore_retcode=False,
|
||||
saltenv='base',
|
||||
use_vt=False,
|
||||
redirect_stderr=False,
|
||||
**kwargs):
|
||||
'''
|
||||
Execute the passed command and return a dict of return data
|
||||
|
@ -1504,6 +1505,14 @@ def run_all(cmd,
|
|||
Note that ``env`` represents the environment variables for the command, and
|
||||
should be formatted as a dict, or a YAML string which resolves to a dict.
|
||||
|
||||
redirect_stderr : False
|
||||
If set to ``True``, then stderr will be redirected to stdout. This is
|
||||
helpful for cases where obtaining both the retcode and output is
|
||||
desired, but it is not desired to have the output separated into both
|
||||
stdout and stderr.
|
||||
|
||||
.. versionadded:: 2015.8.2
|
||||
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
@ -1528,10 +1537,12 @@ def run_all(cmd,
|
|||
'''
|
||||
python_shell = _python_shell_default(python_shell,
|
||||
kwargs.get('__pub_jid', ''))
|
||||
stderr = subprocess.STDOUT if redirect_stderr else subprocess.PIPE
|
||||
ret = _run(cmd,
|
||||
runas=runas,
|
||||
cwd=cwd,
|
||||
stdin=stdin,
|
||||
stderr=stderr,
|
||||
shell=shell,
|
||||
python_shell=python_shell,
|
||||
env=env,
|
||||
|
|
Loading…
Add table
Reference in a new issue