Events, Beacons, Reactors!

example showing node firing off event with tag. Master captures event and generates a file

Minion sends event with a Tag called "sayHello".

Master receives Tag and checks its "reactor.conf" for any matching instructions

If instruction present, it executes the related Reactor state

This example has a Minion firing off a simple Hello tag, which makes the Master run a "echo Hello > /tmp/hello.file"

    1. create /etc/salt/master.d/reactor.conf

    2. reactor:

    3. - 'sayhello':

    4. - /srv/reactor/sayhello.sls

    5. restart Master service to pick up change

    6. create Reactor file

    7. /srv/salt/reactor/sayhello.sls

    8. sayhello:

    9. local.cmd.run:

    10. - tgt: mrxteamcity

    11. - arg:

    12. - echo hello > /tmp/hello

    13. Fire an event from the minion

    14. salt-call event.send 'sayhello'

    15. Master will execute /srv/reactor/sayhello.sls

    16. Mininon's /tmp should now have a file /tmp/hello

    17. To listen to any events on the Master, run on Master:

    18. salt-run state.event pretty=True

Another example, anyone out of band changes to /etc/hosts file results in instant state run to update /etc/hosts to baseline