This state is intended for use from the Salt Master. It provides access to sending commands down to minions as well as access to executing master-side modules. These state functions wrap Salt's Python API.
Support for masterless minions was added to thesalt.state
function, so they can run orchestration sls files. This is particularly useful when the rendering of a state is dependent on the execution of another state. Orchestration will render and execute each orchestration block independently, while honoring requisites to ensure the states are applied in the correct order.
salt.states.saltmod.
function
(name, tgt, ssh=False, tgt_type='glob', expr_form=None, ret='', expect_minions=False, fail_minions=None, fail_function=None, arg=None, kwarg=None, timeout=None, batch=None, subset=None)¶Execute a single module function on a remote minion via salt or salt-ssh
glob
Deprecated since version 2017.7.0: Use tgt_type instead
10%
.Number of minions from the targeted set to randomly use
New in version 2017.7.0.
salt.states.saltmod.
runner
(name, **kwargs)¶Execute a runner module on the master
New in version 2014.7.0.
run-manage-up:
salt.runner:
- name: manage.up
salt.states.saltmod.
state
(name, tgt, ssh=False, tgt_type='glob', expr_form=None, ret='', highstate=None, sls=None, top=None, saltenv=None, test=False, pillar=None, pillarenv=None, expect_minions=True, fail_minions=None, allow_fail=0, concurrent=False, timeout=None, batch=None, queue=False, subset=None, orchestration_jid=None)¶Invoke a state run on a given target
The target specification for the state run.
Masterless support: When running on a masterless minion, the tgt
is ignored and will always be the local minion.
glob
Deprecated since version 2017.7.0: Use tgt_type instead
test=true
through to the state functionpillar
kwarg through to the state functionThe pillar environment to grab pillars from
New in version 2017.7.0.
Allow multiple state runs to occur at once.
WARNING: This flag is potentially dangerous. It is designed for use when multiple state runs can safely be run at the same Do not use this flag for performance optimization.
queue=true
through to the state functionExecute the command in batches. E.g.: 10%
.
New in version 2016.3.0.
Number of minions from the targeted set to randomly use
New in version 2017.7.0.
Examples:
Run a list of sls files via state.sls
on target
minions:
webservers:
salt.state:
- tgt: 'web*'
- sls:
- apache
- django
- core
- saltenv: prod
Run a full state.highstate
on target
mininons.
databases:
salt.state:
- tgt: role:database
- tgt_type: grain
- highstate: True
salt.states.saltmod.
wait_for_event
(name, id_list, event_id='id', timeout=300, node='master')¶Watch Salt's event bus and block until a condition is met
New in version 2014.7.0.
event_id
, if found it is removed from id_list
. When id_list
is empty this function returns success.id
for the minion
ID, another common value is name
for use with orchestrating
salt-cloud events.The following example blocks until all the listed minions complete a restart and reconnect to the Salt master:
reboot_all_minions:
salt.function:
- name: system.reboot
- tgt: '*'
wait_for_reboots:
salt.wait_for_event:
- name: salt/minion/*/start
- id_list:
- jerry
- stuart
- dave
- phil
- kevin
- mike
- require:
- salt: reboot_all_minions
salt.states.saltmod.
wheel
(name, **kwargs)¶Execute a wheel module on the master
New in version 2014.7.0.
accept_minion_key:
salt.wheel:
- name: key.accept
- match: frank