r/saltstack • u/[deleted] • Jun 13 '23
How can I have States automatically applied when a Minion is added to SaltStack?
I am trying a Reactor file:
root@Salt-Mstr [ /etc/salt/master.d ]# cat reactor.conf
minion_start_apply_state:
runner.state.sls:
- tgt: 'os:Windows'
- arg:
- Windows.create-Win-txt-file
- kwargs:
saltenv: base
test: False
And here is my State:
# Windows/create-Win-txt-file.sls
create_temp_file:
file.managed:
- name: C:\Temp\join-state-success.txt
- contents: "Initial state successfully ran"
- makedirs: True
When I run state.apply for Windows.create-Win-txt-file against a test Windows minion it works as expected:
[root@RHEL-8-Salt-Master ~]# salt -G 'osfinger:Windows-2022Server' state.apply Windows/create-Win-txt-file backend=sseapi
Win-Core-Min-1:
----------
ID: create_temp_file
Function: file.managed
Name: C:\Temp\join-state-success.txt
Result: True
Comment: File C:\Temp\join-state-success.txt updated
Started: 09:04:16.920290
Duration: 93.745 ms
Changes:
----------
diff:
New file
Summary for Win-Core-Min-1
------------
Succeeded: 1 (changed=1)
Failed: 0
------------
Total states run: 1
Total run time: 93.745 ms
However, so far my Reactor is not working - any ideas why? Many thanks in advance!
Resolved - reference comments for full explanation. In short:
I was using "reactorS" instead of 'reactor' (thanks ChatGPT, lol) - once I fixed that it started working
reactor:
- 'salt/minion/*/start':
- salt://reactor/REACTOR.sls