mirror of
https://github.com/valitydev/salt.git
synced 2024-11-09 01:36:48 +00:00
Quiet down minion startup
__salt__['cmd.run'] needs to be quiet when running inside the grains so add a quiet flag to salt.modules.cmd._run and use it. NOTE: This also quiets down the INFO messages displayed when running a command such as: salt-call -g
This commit is contained in:
parent
9cbb0485fe
commit
4314abd546
@ -23,7 +23,7 @@ import salt.utils
|
||||
# Solve the Chicken and egg problem where grains need to run before any
|
||||
# of the modules are loaded and are generally available for any usage.
|
||||
import salt.modules.cmd
|
||||
__salt__ = {'cmd.run': salt.modules.cmd.run}
|
||||
__salt__ = {'cmd.run': salt.modules.cmd._run_quiet}
|
||||
|
||||
|
||||
def _kernel():
|
||||
|
@ -22,16 +22,17 @@ DEFAULT_CWD = os.path.expanduser('~')
|
||||
__outputter__ = {
|
||||
'run': 'txt',
|
||||
}
|
||||
# TODO: Add a way to quiet down the logging here when salt-call -g is ran
|
||||
def _run(cmd,
|
||||
cwd=DEFAULT_CWD,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE):
|
||||
stderr=subprocess.PIPE,
|
||||
quiet=False):
|
||||
'''
|
||||
Do the DRY thing and only call subprocess.Popen() once
|
||||
'''
|
||||
ret = {}
|
||||
log.info('Executing command {0} in directory {1}'.format(cmd, cwd))
|
||||
if not quiet:
|
||||
log.info('Executing command {0} in directory {1}'.format(cmd, cwd))
|
||||
proc = subprocess.Popen(cmd,
|
||||
cwd=cwd,
|
||||
shell=True,
|
||||
@ -47,6 +48,13 @@ def _run(cmd,
|
||||
return ret
|
||||
|
||||
|
||||
def _run_quiet(cmd, cwd=DEFAULT_CWD):
|
||||
'''
|
||||
Helper for running commands quietly for minion startup
|
||||
'''
|
||||
return _run(cmd, cwd, stderr=subprocess.STDOUT, quiet=True)['stdout']
|
||||
|
||||
|
||||
def run(cmd, cwd=DEFAULT_CWD):
|
||||
'''
|
||||
Execute the passed command and return the output as a string
|
||||
|
Loading…
Reference in New Issue
Block a user