使用saltstack的sls功能

sls文件编写

[root@vm01 ~]# vim /etc/salt/master
#在master配置文件中添加以下内容
file_roots:
base:
– /srv/salt

[root@vm01 ~]# mkdir -p /srv/salt
[root@vm01 ~]# cd /srv/salt/
[root@vm01 salt]# pwd
/srv/salt
[root@vm01 salt]# vim top.sls
base:
‘*’:
– httpd

[root@vm01 salt]# vim httpd.sls
httpd:
pkg:
– installed

[root@vm01 salt]#
[root@vm01 salt]# salt ‘*’ service.available httpd
vm02:
False
[root@vm01 salt]#
[root@vm01 salt]# salt ‘*’ state.highstate -v
Executing job with jid 20160412203923856918
——————————————-

vm02:
———-
ID: httpd
Function: pkg.installed
Result: True
Comment: The following packages were installed/updated: httpd
Started: 20:39:25.356652
Duration: 46945.068 ms
Changes:
———-
httpd:
———-
new:
2.2.15-47.el6.centos.4
old:

Summary
————
Succeeded: 1 (changed=1)
Failed: 0
————
Total states run: 1
[root@vm01 salt]#
[root@vm01 salt]# salt ‘*’ service.available httpd
vm02:
True
[root@vm01 salt]#

#minion端查看httpd是否已经安装成功
[root@vm02 ~]# rpm -q httpd
httpd-2.2.15-47.el6.centos.4.x86_64
[root@vm02 ~]#
#ok,已经安装成功了,就这么简单。

Share