架构
server1 master 写好httpd nginx 等salt
server2 3 minion
server4 top master
server1
salt-key -d server4
server4
vim /etc/salt/master
order_masters: True
server1
yum install salt-syndic -y
vim /etc/salt/master
syndic_master: server4
systemctl start salt-syndic
systemctl restart salt-master
server4
[root@server4 ~]# salt-key -L
salt-key -A
server4
salt server2 test.ping
[root@server4 ~]# salt '*' test.ping
server1:
True
server2:
True
server3:
True
salt server2 state.sls httpd.service
相当于级联,server4不需要salt文件就可以通过master下达指令
[root@server4 ~]# salt '*' state.highstate
server2:
----------
ID: /etc/httpd/conf/httpd.conf
Function: file.managed
Result: True
Comment: File /etc/httpd/conf/httpd.conf is in the correct state
Started: 09:35:34.869931
Duration: 245.621 ms
不如ansible的ssh方便
无需安装minion,
全部关闭minion
systemctl stop salt-minion
server1
yum install salt-ssh -y
vim /etc/salt/roster
server2:
172.25.11.2
[root@server1 ~]# salt-ssh server2 test.ping -i
Permission denied for host server2, do you want to deploy the salt-ssh key? (password required):
[Y/n] y
Password for root@server2:
server2:
True
[root@server1 ~]# salt-ssh server2 test.ping
server2:
True