Chapter 6. The Salt Event Bus
Salt is a heavily asynchronous tool that comes with all the simplicity, reliability, and difficulty inherent in asynchronicity. Minions can request data and files from the master, send job returns or other data, refresh authentication, and more and all of this can happen at any time. Sometimes this is in response to user actions on either the minion or master; other times it is a scheduled job or routine maintenance.
Salt makes use of an event bus internally to send messages from minion to master and from one process to another. As with most things in Salt, this event bus is also exposed to users to extend, read from, and write to.
Event Tags and Data
A Salt event consists of two things: an event tag and event data. Event tags are a slash-delimited string where each slash provides a level of namespacing. Event data is a dictionary that contains a timestamp plus any arbitrary data useful for that type of event.
For example, when a minion finishes processing a job and sends the job return data back to the master, an event is fired that looks similar to the one shown in Example 6-1.
Example 6-1. salt/job/20170706170156951774/ret/device1
{
"_stamp"
:
"2017-07-06T23:01:57.098368"
,
"...snip..."
:
null
}
All Salt events start with salt/
, all Salt events start with salt/job/
, and so on, with each slash delimiting a new level of namespacing. The event bus in Salt can get quite busy so event tags are often matched-on to filter unwanted event types. (Event tags ...
Get Network Automation at Scale now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.