Saltstack - 如何观看整个目录的变化?

时间:2016-03-21 20:41:16

标签: salt-stack

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。

目前我只能通过以下方式手动添加sl中的每个conf来实现:

/etc/nginx/conf.d/newsite.conf:
  file.managed:
   - source: salt://{{slspath}}/etc/nginx/conf.d/newsite.conf

有没有办法实现自动化?

1 个答案:

答案 0 :(得分:3)

您无法在目录中观看文件更改以执行状态。但是你可以观察州的结果。在您的情况下,只要nginx文件状态发生更改,以下内容应重新启动/etc/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
相关问题