0

Example from: https://docs.saltstack.com/en/latest/topics/tutorials/states_pt2.html

/etc/httpd/extra/httpd-vhosts.conf:
  file.managed:
    - source: salt://webserver/httpd-vhosts.conf

apache:
  pkg.installed: []
  service.running:
    - watch:
      - file: /etc/httpd/extra/httpd-vhosts.conf
    - require:
      - pkg: apache

Is there a way to inject a "watch"?

I manage a file for apache in an optional module.

The service.running is already in the main part, which is installed on all hosts.

How can I tell apache to restart if the optional module was changed?

I want strict separation in my salt files: The main part does not know the optional module.

I hope you understand me. If not, please leave a comment. Thank you.

guettli
  • 3,113
  • 14
  • 59
  • 110

1 Answers1

1

Instead of using watch at the service that you want to restart, you can use watch_in on the state that wants to trigger the restart. Here a snippet from my salt states:

/etc/consul/httpd.json:
  file.managed:
    - source: salt://web/conf/httpd.json
    - watch_in:
      - service: consul

consul:
  service.running:
    - enable: True
ahus1
  • 557
  • 4
  • 12