-
Notifications
You must be signed in to change notification settings - Fork 0
15. Salt Event system
There is an event bus.
Salt has the ability to react to specific events.
This is very useful for event based automation.
You can map an action (reactor sls file) to an event in the section reactor
of the master conf file.
The reactor sls file defines the reactions.
This provides the ability to take actions according to events.
Reactor sls files should be placed in the /srv/reactor/
directory for consistency between environments, but this is not currently enforced by Salt.
Reactor sls files follow a similar format to other sls files in Salt.
They are written in YAML and can be templated using Jinja.
https://docs.saltstack.com/en/latest/topics/event/index.html
run this command on the master to watch the event bus:
salt-run state.event pretty=True
Fire an event off up to the master server
sudo salt "vqfx01" event.fire_master '{"data": "message to be sent in the event"}' 'jnpr/UI_COMMIT_COMPLETED'
vqfx01:
True
event bus:
20170628012815208558 {
"_stamp": "2017-06-27T23:28:15.208736",
"minions": [
"vqfx01"
]
}
salt/job/20170628012815208558/new {
"_stamp": "2017-06-27T23:28:15.209219",
"arg": [
{
"data": "message to be sent in the event"
},
"jnpr/UI_COMMIT_COMPLETED"
],
"fun": "event.fire_master",
"jid": "20170628012815208558",
"minions": [
"vqfx01"
],
"tgt": "vqfx01",
"tgt_type": "glob",
"user": "sudo_root"
}
jnpr/UI_COMMIT_COMPLETED {
"_stamp": "2017-06-27T23:28:15.260825",
"cmd": "_minion_event",
"data": {
"data": "message to be sent in the event"
},
"id": "vqfx01",
"pretag": null,
"tag": "jnpr/UI_COMMIT_COMPLETED"
}
salt/job/20170628012815208558/ret/vqfx01 {
"_stamp": "2017-06-27T23:28:15.262542",
"cmd": "_return",
"fun": "event.fire_master",
"fun_args": [
{
"data": "message to be sent in the event"
},
"jnpr/UI_COMMIT_COMPLETED"
],
"id": "vqfx01",
"jid": "20170628012815208558",
"retcode": 0,
"return": true,
"success": true
}