1.安装
master:
yum install salt-master salt-minion -y minion:
yum install salt-minion -y
2.修改配置文件(minion)
更改/etc/salt/minion
master: yanglin3
3.重启
systemctl start salt-master
systemctl start salt-minion
4.接受
salt-key salt-key -A #接受 salt "*" test.ping #测试连接 salt "*" cmd.run hostname #远程执行命令
5.配置
vim /etc/salt/master
添加:
file_roots:
base:
- /srv/salt/base
dev:
- /srv/salt/dev
test:
- /srv/salt/test
prod:
- /srv/salt/prod 创建目录
mkdir -pv /srv/salt/{base,dev,test,prod} 在base目录下编辑
apache.sls
apache-install:
pkg.installed:
- pkgs:
- httpd
service.running:
- name: httpd
启动:salt "yanglin1" state.sls apache
或者在base下创建web目录,将apache.sls放下面
启动:salt "yanglin3" state.sls web.apache
或者在base下面创建top.sls,
base:
'yanglin1':
- web.apache
'yanglin3':
- web.apache
启动:salt '*' state.highstate