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"
create /etc/salt/master.d/reactor.conf
reactor:
- 'sayhello':
- /srv/reactor/sayhello.sls
restart Master service to pick up change
create Reactor file
/srv/salt/reactor/sayhello.sls
sayhello:
local.cmd.run:
- tgt: mrxteamcity
- arg:
- echo hello > /tmp/hello
Fire an event from the minion
salt-call event.send 'sayhello'
Master will execute /srv/reactor/sayhello.sls
Mininon's /tmp should now have a file /tmp/hello
To listen to any events on the Master, run on Master:
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