CoursesSaltAdvanced

The event system & reactor

Event-driven automation.

Advanced14 min · lesson 9 of 12

Underneath everything Salt does is an event bus: minions and the master emit events — a minion starts, a job returns, a state fails, a custom event you fire — and the master can watch that stream. The reactor system hooks events to actions: when an event matching a tag appears, the reactor triggers a remote-execution or state action in response. This is what turns Salt from a tool you drive into an event-driven automation system that responds on its own.

EVENT-DRIVEN REACTOR
1Event emitted
minion start, job return, custom event
2Master watches event bus
the live event stream
3Reactor matches tag
e.g. salt/minion/*/start
4Triggers action
remote-exec or state (e.g. highstate)
Reactor actions run privileged with no human in the loop — match specific, trustworthy tags and distrust minion-supplied data.
terminal
# watch the live event bus (great for discovering event tags)
$ salt-run state.event pretty=True
salt/minion/web3/start { '_stamp': '...', 'id': 'web3' }
salt/job/2024.../ret/web1 { 'success': True, ... }
reactor config + sls
# /etc/salt/master
reactor:
- 'salt/minion/*/start':
- /srv/reactor/onboard.sls
---
# /srv/reactor/onboard.sls — apply highstate the moment a new minion connects
onboard_new_minion:
local.state.highstate:
- tgt: {{ data['id'] }}

What event-driven Salt unlocks

The reactor enables self-managing infrastructure: auto-apply highstate when a node first connects, remediate automatically when a monitoring event fires, scale a service in response to a custom event from your app. Combined with the orchestrate runner (which coordinates multi-step, cross-minion workflows from the master), Salt handles orchestration that ordered playbooks struggle with. It is Salt’s most distinctive advanced capability.

A reactor runs privileged actions automatically — scope its triggers
The reactor fires real, root-level actions with no human in the loop, so a too-broad event match or an attacker able to inject events onto the bus can drive automated damage. Match reactor triggers on specific, trustworthy event tags, be cautious reacting to data a minion supplies (it can be forged), and treat reactor SLS as privileged code — review it and keep its actions least-privilege.