salt 使用state的sls文件来递归同步目录下的文件到minion

 
例子1,
使用sls文件将之前写的zabbix的监控key放到新装的机器上面,然后重启zabbix-agent的服务
#/usr/local/zabbix/etc/zabbix_agentd.conf.d:
sync_zabbix_key:
  file.recurse:
  - source: salt://file/zabbix/zabbix_agentd.conf.d
  - name: /usr/local/zabbix/etc/zabbix_agentd.conf.d
  - user: zabbix
  - group: zabbix
  - file_mode: 755
  - dir_mode: 755
  - makedirs: True
  - backup: minion    ##备份原有文件,备份目录在minion端的。/var/cache/salt/minion/files/base/file
  - include_enpty: True
# - recurse
## - user
# - group
# - mode
zabbix-agent:
  service.running:
    - name: zabbix-agent
    - watch:
      - file: /usr/local/zabbix/etc/zabbix_agentd.conf.d

 

 
 
例子2,
使用sls文件将之前写的zabbix的监控key放到新装的机器上面,然后重启zabbix-agent的服务
#/usr/local/zabbix/etc/zabbix_agentd.conf.d:
sync_zabbix_key:
  file.directory:
    - source: salt://file/zabbix/zabbix_agentd.conf.d
    - name: /usr/local/zabbix/etc/zabbix_agentd.conf.d
    - user: zabbix
    - group: zabbix
    - file_mode: 755
    - dir_mode: 755
    - makedirs: True
    - backup: minion
    - include_enpty: True
    - recurse:
      - user
      - group
      - mode
zabbix-agent:
  service.running:
    - name: zabbix-agent
    - watch:
      - file: /usr/local/zabbix/etc/zabbix_agentd.conf.d

 

这2种方法都可以,还不知道有什么差别。
posted @ 2017-11-24 10:11  LYCong  阅读(674)  评论(1编辑  收藏  举报