4

Imagine you want to apply some states on a group of minions, such as all ubuntu clients. It's possible by the time we apply that states some of the minions are offline.

How long do states remain in the message bus to be pushed on minions? What strategies do you suggest to tackle this problem and change minions states when they come back online? Is there a better way to make minion pull states than running salt-call state.highstate?

AKJ88
  • 153
  • 2
  • 7

1 Answers1

10

Salt comes with the so called reactor system, which should fit your needs.

The following is untested and taken from the linked docs.

/etc/salt/master.d/reactor.conf:

reactor:
    - 'salt/minion/*/start':          # Match the start event
        - /srv/reactor/start.sls      # Things to do when a minion starts

/srv/reactor/start.sls:

highstate_run:
    local.state.apply:
        - tgt: {{ data['id'] }}  # data included event data, id is the minion id.

This should ensure that each minion applies state.highstate after it has opened a connection to the salt master.

vskubriev
  • 686
  • 9
  • 15
dahrens
  • 286
  • 2
  • 5
  • 1
    `data['id']` misses curly brackets and should read as `{{ data['id'] }}` – 0x416e746f6e May 12 '19 at 20:35
  • Is there a way to exclude some hosts(minions) from a `highstate_run/local.state.apply` in this case ? I asked this question [here](https://stackoverflow.com/questions/57553898/saltstack-exclude-specific-minions-from-run-from-reactor) – vskubriev Aug 20 '19 at 10:37