Salt stack 如何监视整个目录的变化?
我如何才能使上述工作? 我希望这样,每次在/etc/nginx/conf.d/newsite.conf中添加新配置时,nginx都会重新加载 目前我只能通过以下方式手动添加sls中的每个conf来实现:Salt stack 如何监视整个目录的变化?,salt-stack,Salt Stack,我如何才能使上述工作? 我希望这样,每次在/etc/nginx/conf.d/newsite.conf中添加新配置时,nginx都会重新加载 目前我只能通过以下方式手动添加sls中的每个conf来实现: nginx pkg.installed: - name: nginx service: - name: nginx - running - enable: True - watch: - file: /etc/nginx/* /etc
nginx
pkg.installed:
- name: nginx
service:
- name: nginx
- running
- enable: True
- watch:
- file: /etc/nginx/*
/etc/nginx:
file.recurse:
- source: salt://{{slspath}}/etc/nginx/
- include_empty: True
有什么方法可以自动执行吗?您不能监视目录中的文件更改以执行状态。但您可以通过查看状态结果来执行此操作。在您的情况下,只要
/etc/nginx
文件状态进行了更改,就应该重新启动nginx
:
/etc/nginx/conf.d/newsite.conf:
file.managed:
- source: salt://{{slspath}}/etc/nginx/conf.d/newsite.conf
你有没有考虑过incron作为替代方案?是的,我知道inotify,但这是不同的,我想将更改应用到20台服务器,并且只有在nginx文件夹中发生更改时才能重新加载服务。我可以在每台服务器上做一个incron,但我也希望输出和所有内容都通过saltstack。
nginx
pkg.installed:
- name: nginx
service.running:
- enable: True
- watch:
- file: /etc/nginx
/etc/nginx:
file.recurse:
- source: salt://{{slspath}}/etc/nginx/
- include_empty: True