SaltStack 监视文件重启服务将不起作用
SaltStack watch file restart service won't work
我希望 SaltStack 在文件 000-default-conf 更改时重新加载或重新启动,但是当我通过 ssh 在我的 debian9 系统上手动编辑该文件时,没有任何反应。
有人能帮忙吗?
配置如下所示:
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
如 salt 文档中所述,手动更改不会重新启动服务:
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)
你需要的是信标和反应器,看看inotify beacon
我希望 SaltStack 在文件 000-default-conf 更改时重新加载或重新启动,但是当我通过 ssh 在我的 debian9 系统上手动编辑该文件时,没有任何反应。
有人能帮忙吗? 配置如下所示:
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
如 salt 文档中所述,手动更改不会重新启动服务:
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)
你需要的是信标和反应器,看看inotify beacon