SaltStack自动化软件简介及安装
=======================================================================================================
环境配置
角色 | 主机名 | IP | 组名 |
master | master.salt.com | 192.168.200.100 | |
minion | node1.salt.com | 192.168.200.101 | web1group |
minion | node2.salt.com | 192.168.200.102 | web2group |
安装EPEL三台都安装EPEL
[root@master ~]# ls
epel-release-latest-7.noarch.rpm
[root@master ~]# rpm -ivh epel-release-latest-7.noarch.rpm
警告:epel-release-latest-7.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID 352c64e5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:epel-release-7-11 ################################# [100%]
安装Saltstack三台都安装
[root@master ~]# yum install salt-master -y #主控端
[root@node1 ~]# yum install salt-minion -y #被控端
[root@node2 ~]# yum install salt-minion -y #被控端
修改映射关系
[root@master ~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.200.100 master.salt.com
192.168.200.101 node1.salt.com
192.168.200.102 node2.salt.com
将hosts文件发送给node1和node2两台被控主机
[root@master ~]# scp /etc/hosts 192.168.200.101:/etc/
[root@master ~]# scp /etc/hosts 192.168.200.102:/etc/
[root@master ~]# vim /etc/salt/master
15 interface: 192.168.200.100 #绑定master通信IP 215 auto_accept: True #自动认证,避免手动运行salt-key来确认证书信任
406 file_roots: #指定saltstack文件根目录位置 407 base: 408 - /srv/salt/
[root@master ~]# systemctl start salt-master
node1与node2被控端主机都执行本次操作
[root@node1 ~]# vim /etc/salt/minion
16 master: 192.168.200.100 #指定master主机IP地址 78 id: node1.salt.com #修改被控主机识别ID,建议使用操作系统
[root@node1 ~]# systemctl start salt-minion
[root@master ~]# salt '*' test.ping
node2.salt.com:
True
node1.salt.com:
True
[root@master salt]# salt-key -L
Accepted Keys:
node1.salt.com
node2.salt.com
Denied Keys:
Unaccepted Keys:
Rejected Keys: