Skip to content

Instantly share code, notes, and snippets.

@hemebond
Last active January 11, 2017 12:09
Show Gist options
  • Save hemebond/710ebb11ab1659b5061eeb57ca196278 to your computer and use it in GitHub Desktop.
Save hemebond/710ebb11ab1659b5061eeb57ca196278 to your computer and use it in GitHub Desktop.
Sync grains every start and highstate once automatically.
reactors:
# Run this script every time an abc instance starts
- 'salt/minion/abc*/start':
- '/srv/salt/reactors/abc/start.sls'
# Run this script every time an abc instance returns from a job
- 'salt/job/*/ret/abc*':
- '/srv/salt/reactors/abc/ret.sls'
{%- if data['fun'] == 'saltutil.sync_grains' %}
run_highstate:
cmd.state.apply:
- tgt: {{ data['id'] }}
- arg:
- reactors.first_run_highstate
# Only needed for the custom environment
- kwarg:
saltenv: abc
{%- endif %}
first:
local.saltutil.sync_grains:
- tgt: {{ data['id'] }}
# Only need this kwarg because of the custom environment
- kwarg:
saltenv: abc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment