salt.runners.salt
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)
-
Changed in version 2018.3.0: Added
with_pillar
argumentExecute
fun
with the givenargs
andkwargs
. Parameterfun
should be the string name of the execution module to call.Note
Execution modules will be loaded every time this function is called. Additionally, keep in mind that since runners execute on the master, custom execution modules will need to be synced to the master using
salt-run saltutil.sync_modules
, otherwise they will not be available.- with_pillarFalse
-
If
True
, pillar data will be compiled for the masterNote
To target the master in the pillar top file, keep in mind that the default
id
for the master is<hostname>_master
. This can be overridden by setting anid
configuration parameter in the master config file.
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-run salt.cmd mymod.myfunc with_pillar=True
salt.runners.salt.cmd(fun, *args, **kwargs)
-
New in version 2017.7.0.
Execute
fun
on all minions matched bytgt
andtgt_type
. Parameterfun
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
salt.runners.salt.execute(tgt, fun, arg=(), timeout=None, tgt_type='glob', ret='', jid='', kwarg=None, **kwargs)
© 2021 SaltStack.
Licensed under the Apache License, Version 2.0.
https://docs.saltproject.io/en/latest/ref/runners/all/salt.runners.salt.html