Saltstack update all minions highstate once gitfs remote changed

82 views Asked by At

I am struggling to implement a reactor (or any other method) to have all my minions updated once the salt master gitfs configured remote has changed (so when a commit has been pushed/merged into the branch the salt master is monitoring)

So far I tried to implement a reactor.conf with the following:

---
reactor:
  - salt/fileserver/gitfs/update:
      - filter: data.get('changed', False) == True
      - salt:
          tgt: "*"
          fun: state.apply
          arg:
            highstate: ""

But getting error:

2023-04-14 10:20:05 master01  | [ERROR   ] Exception encountered while compiling reactions
2023-04-14 10:20:05 master01  | Traceback (most recent call last):
2023-04-14 10:20:05 master01  |   File "salt/utils/reactor.py", line 178, in reactions
2023-04-14 10:20:05 master01  |     high.update(self.render_reaction(fn_, tag, data))
2023-04-14 10:20:05 master01  |   File "salt/utils/reactor.py", line 57, in render_reaction
2023-04-14 10:20:05 master01  |     if glob_ref.startswith("salt://"):
2023-04-14 10:20:05 master01  | AttributeError: 'dict' object has no attribute 'startswith'

What would be the right approach here?

1

There are 1 answers

0
OrangeDog On

Reactor configuration is supposed to be in two separate files

# /etc/salt/master.d/reactor.conf
reactor:
  - salt/fileserver/gitfs/update:
    - /srv/reactor/gitfs.sls
# /srv/reactor/gitfs.sls
{% if data.get('changed') %}
highstate_run:
  local.state.apply:
    - tgt: '*'
{% endif %}

https://docs.saltproject.io/en/latest/topics/reactor/