第一 在master 可以看到如下信息
[[email protected] salt]#

1
2
3
4
5
6
vim /etc/salt/master
#file_roots:
file_roots:
  base:
    - /srv/salt/
    #- /var/salt/
1
cd /srv/salt

[[email protected] salt]# pwd
/srv/salt
[[email protected] salt]#

1
2
3
4
5
6
 cat top.sls
base:
    '192.168.1.210':
       #- evan.sc
       - evan.pack  #这个是evan目录下有个pack.sls
       #- evan.fc7
1
2
mkdir evan
cd evan;

[[email protected] evan]#

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
vim  pack.sls
apache:
   pkg:
    - name: httpd
    - installed
   service:
    - name: httpd
    - running
    - reload: True
    - watch:
        - file: /etc/httpd/conf/httpd.conf
/etc/httpd/conf/httpd.conf:
   file.managed:
     - source: salt://fc7/httpd.conf
     - user: root
     - group: root
     - mode: 644
     - backup: minion

第二 回来minion
[email protected] salt]# rm -rf /etc/httpd/conf/httpd.conf
[[email protected] salt]# vim /etc/httpd/conf/httpd.conf
[[email protected] salt]# file /etc/httpd/conf/httpd.conf
/etc/httpd/conf/httpd.conf: ERROR: cannot open `/etc/httpd/conf/httpd.conf’ (No such file or directory)
由上可见 这个文件不在了
第四 to master
[[email protected] salt]#

1
 salt 192.168.1.210 state.highstate

192.168.1.210:
———-
State: – pkg
Name: httpd
Function: installed
Result: True
Comment: Package httpd is already installed
Changes:
———-
State: – file
Name: /etc/httpd/conf/httpd.conf
Function: managed
Result: True
Comment: File /etc/httpd/conf/httpd.conf updated
Changes: diff: New file
———-
State: – service
Name: httpd
Function: running
Result: True
Comment: Service reloaded
Changes: httpd: True
第五 然后再回来minion看一下 刚才不小心删除的文件又来了
[[email protected] salt]# file /etc/httpd/conf/httpd.conf
/etc/httpd/conf/httpd.conf: ASCII English text
参考
http://www.shencan.net/index.php/2013/05/24/saltstack%EF%BC%88%E4%B8%80%EF%BC%89/