I am using reactor to catch certain events, my reactor.conf in /etc/salt/master.d looks like:
reactor:
- 'health/agent/update':
- salt://health-checks/reactor.sls
In reactor.sls - I want to get some data from agents and run a certain SLS only on certain salt minions (Not on salt master itself). So I use following block along with tgt
to ensure it runs only on those minions. This looks fine based on documentation at. In update_server.sls I produce some managed files.
{% set event_data = data.data %}
{% set target_server_name = data.data.server_name %}
'update server states':
runner.state.orchestrate:
- tgt: {{ target_server_name }}
- mods: health-checks/update_server
- pillar:
event_data: {{ event_data }}
But managed files are generated only on salt-master and not on any of tgt
minions. What am I missing? What is right way to run a sls on target minions and produce desired results there?
I also tried using salt.state but that results into an error, code
salt.state:
- tgt: '*{{ target_server_name }}*'
and error:
2015-12-04 06:37:24,467 [salt.utils.process][INFO ][17924] Process <class 'salt.utils.reactor.Reactor'> (17989) died with exit status None, restarting...
I think I realized the mistake I was doing.
First of all "runners" should be used for things which you need to do on master and not on remote minions, as clearly stated in Runner documentation at:
Salt runners work similarly to Salt execution modules however they execute on the Salt master itself instead of remote Salt minions.
What worked for me is here:
'update server states':
local.state.sls:
- tgt: '*{{ target_server_name }}*'
- arg:
- 'health-checks/update_server'
- kwarg:
pillar:
event_data: {{ event_data }}
This will run the update_server.sls file only on servers filtered by tgt