vim /etc/salt/minion master: 172.16.1.211
vim /etc/salt/master
file_roots: base: - /srv/salt/mkdir /srv/salt cd /srv/salt vim apache.sls #安装apache并启动
apache-install: pkg.installed: - names: - httpd - httpd-develapache-service: service.running: - name: httpd - enable: True - reload: Truesalt ‘*’ state.sls apache #执行状态管理脚本
vim top.sls
base: '*': - apachesalt ‘*’ state.highstate #通过入口文件执行安装apache的脚本
vim /etc/salt/grains #客户端
roles: - webserver - memcache/etc/init.d/salt-minion restart vim top.sls #服务端
base: 'roles:webserver': - match: grain - apachesalt ‘*’ state.highstate #通过top筛选匹配的grain
vim /etc/salt/master
pillar_roots: base: - /srv/pillar/etc/init.d/salt-master restart
vim /srv/pillar/apache.sls
{%if grains['os'] == 'CentOS'%}apache: httpd{% elif grains['os'] == 'Debian' %}apache: apache2{% endif %}vim top.sls
base: '*': - apachesalt ‘*’ pillar.items #查看配置的pillar
新闻热点
疑难解答