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.

1 Answer 1

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
1
  • That is exactly what I was looking for. Thank you!
    – guettli
    Feb 6, 2016 at 20:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .