第一 在master 可以看到如下信息
[root@master salt]# vim /etc/salt/master
#file_roots:
file_roots:
base:
- /srv/salt/
#- /var/salt/
cd /srv/salt
[root@master salt]# pwd
/srv/salt
[root@master salt]# cat top.sls
base:
'192.168.1.210':
#- evan.sc
- evan.pack #这个是evan目录下有个pack.sls
#- evan.fc7
mkdir evan
cd evan;
[root@master evan]# 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
root@client salt]# rm -rf /etc/httpd/conf/httpd.conf
[root@client salt]# vim /etc/httpd/conf/httpd.conf
[root@client 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
[root@master salt]# 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看一下 刚才不小心删除的文件又来了
[root@client 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/