Skip to content
This repository was archived by the owner on Oct 12, 2020. It is now read-only.

15. Salt Event system

Khelil Sator edited this page Jun 30, 2017 · 14 revisions

There is an event bus.
Salt has the ability to react to specific events.
This is very useful for event based automation.

Documentation

https://docs.saltstack.com/en/latest/topics/event/index.html

demo

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
}
Clone this wiki locally