Peter Bucher
Peter Bucher

Reputation: 48

SaltStack watch file restart service won't work

I want SaltStack to reload or restart when the file 000-default-conf is changed, but when i manually edit the file on my debian9 system via ssh nothing happens.

Can anyone help? The configuration looks like this:

apache2:
  pkg.installed:
    - name: apache2

  service.running:
    - name: apache2
    - enable: True
    - reload: True
    - require:
      - pkg: apache2
    - watch:
      - file: /etc/apache2/sites-available/000-default-conf
      - file: /etc/apache2/sites-available/*
      - pkg: apache2

/etc/apache2/sites-available/000-default-conf:
  file.managed:
    - name: /etc/apache2/sites-available/000-default.conf
    - user: www-data
    - group: www-data
    - mode: 644
    - source: salt://apache-wordpress/files/000-default.conf
    - require:
      - pkg: apache2

a2enmod_rewrite:
  cmd.run:
    - name: a2enmod rewrite
    - require:
      - service: apache2

Upvotes: 1

Views: 4993

Answers (1)

ClumsyPuffin
ClumsyPuffin

Reputation: 4059

Manually made changes won't restart the service as mentioned in salt documentation:

watch can be used with service.running to restart a service when another state changes ( example: a file.managed state that creates the service's config file ).

(https://docs.saltstack.com/en/latest/ref/states/all/salt.states.service.html)

what you need is beacons and reactors , have a look at inotify beacon

Upvotes: 2

Related Questions