This runner makes Salt's execution modules available on the salt master.
New in version 2016.11.0.
Salt's execution modules are normally available
on the salt minion. Use this runner to call
execution modules on the salt master.
Salt execution modules
are the functions called by the salt
command.
Execution modules can be called with salt-run
:
salt-run salt.cmd test.ping
# call functions with arguments and keyword arguments
salt-run salt.cmd test.arg 1 2 3 key=value a=1
Execution modules are also available to salt runners:
__salt__['salt.cmd'](fun=fun, args=args, kwargs=kwargs)
salt.runners.salt.
cmd
(fun, *args, **kwargs)¶Execute fun
with the given args
and kwargs
.
Parameter fun
should be the string name
of the execution module to call.
Note that execution modules will be loaded every time this function is called.
CLI example:
salt-run salt.cmd test.ping
# call functions with arguments and keyword arguments
salt-run salt.cmd test.arg 1 2 3 a=1
salt.runners.salt.
execute
(tgt, fun, arg=(), timeout=None, tgt_type='glob', ret='', jid='', kwarg=None, **kwargs)¶New in version 2017.7.0.
Execute fun
on all minions matched by tgt
and tgt_type
.
Parameter fun
is the name of execution module function to call.
This function should mainly be used as a helper for runner modules, in order to avoid redundant code. For example, when inside a runner one needs to execute a certain function on arbitrary groups of minions, only has to:
ret1 = __salt__['salt.execute']('*', 'mod.fun')
ret2 = __salt__['salt.execute']('my_nodegroup', 'mod2.fun2', tgt_type='nodegroup')
It can also be used to schedule jobs directly on the master, for example:
schedule:
collect_bgp_stats:
function: salt.execute
args:
- edge-routers
- bgp.neighbors
kwargs:
tgt_type: nodegroup
days: 1
returner: redis