Skip to content

Instantly share code, notes, and snippets.

@ytjohn
Created November 3, 2015 21:50
Show Gist options
  • Select an option

  • Save ytjohn/61873d20f67e4d69c616 to your computer and use it in GitHub Desktop.

Select an option

Save ytjohn/61873d20f67e4d69c616 to your computer and use it in GitHub Desktop.
# pillar
autosalt:
frequency: 15 # in minutes
minions:
'*':
sls:
- examples.pop
'minion*':
expr_form: glob
highstate: True
'role:minion1':
expr_form: pillar
sls:
- examples.hop
#ext/autosalt/orchestration/init.sls
{% set autosalt = salt['pillar.get']('autosalt') %}
{% set minions = autosalt.minions %}
{% for minion in minions %}
"state_{{ minion }}":
salt.state:
- tgt: '{{ minion }}'
- tgt_type: {{ minions[minion].expr_form|default('glob')}}
- highstate: {{ minions[minion].highstate|default('False') }}
{% if 'sls' in minions[minion] %}
- sls: {{ minions[minion].sls }}
{% endif %}
{% endfor %}
# pillar
role: minion1
# results of running:
# salt-run state.orchestrate ext.autosalt.orchestration -ldebug
#salt_sync_modules:
# salt.function:
# - name: saltutil.sync_all
# - tgt: 'minion1'
# - timeout: 300
#
#do_highstate:
# salt.state:
# - tgt: 'minion1'
# - highstate: True
# - timeout: 300
#
#do_singlestate:
# salt.state:
# - saltenv: base
# - tgt: 'minion2'
# - sls:
# - hop
# - timeout: 300
# target is singular, so one stanza per target.
# https://docs.saltstack.com/en/latest/topics/tutorials/states_pt5.html
#salt.states.saltmod.state(name, tgt, ssh=False, tgt_type=None,
# expr_form=None, ret='', highstate=None, sls=None, top=None,
# env=None, test=False, pillar=None, expect_minions=False,
# fail_minions=None, allow_fail=0, concurrent=False, timeout=None)
#tgt_type | expr_form
# The target type to resolve, defaults to glob
# highstate
# Defaults to None, if set to True the target systems will ignore
# any sls references specified in the sls option and call state.highstate
# on the targeted minions
base:
'master':
- autosalt
'minion1':
- minion1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment