1

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?

6

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.

  • 1
    data['id'] misses curly brackets and should read as {{ data['id'] }} – courteouselk 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 – vskubriev Aug 20 '19 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.