Saltstack - 如何观察整个目录的变化?
Saltstack - how to watch a whole directory for changes?
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/conf.d/newsite.conf 中添加新配置时重新加载 nginx。
目前我只能通过以下方式手动添加 sls 中的每个 conf 才能实现:
/etc/nginx/conf.d/newsite.conf:
file.managed:
- source: salt://{{slspath}}/etc/nginx/conf.d/newsite.conf
有没有办法让它自动化?
您无法通过观察目录中的文件更改来执行状态。但是您可以观看状态结果来这样做。在您的情况下,只要 /etc/nginx
文件状态完成更改,以下内容就应该重新启动 nginx
:
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
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/conf.d/newsite.conf 中添加新配置时重新加载 nginx。
目前我只能通过以下方式手动添加 sls 中的每个 conf 才能实现:
/etc/nginx/conf.d/newsite.conf:
file.managed:
- source: salt://{{slspath}}/etc/nginx/conf.d/newsite.conf
有没有办法让它自动化?
您无法通过观察目录中的文件更改来执行状态。但是您可以观看状态结果来这样做。在您的情况下,只要 /etc/nginx
文件状态完成更改,以下内容就应该重新启动 nginx
:
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