一、编辑安装脚本(该脚本还没完善)
vi saltstack_install.sh
#!/bin/bash ## Install SaltStack on CentOS 6.8 by Lion 2017-03-25 16:00 ## Version 1.0 mkdir ~/tools -p cd ~/tools rpm --import https://repo.saltstack.com/yum/redhat/6/x86_64/latest/SALTSTACK-GPG-KEY.pub cat > /etc/yum.repos.d/saltstack.repo << EOF [saltstack-repo] name=SaltStack repo for RHEL/CentOS \$releasever baseurl=https://repo.saltstack.com/yum/redhat/\$releasever/\$basearch/latest enabled=1 gpgcheck=1 gpgkey=https://repo.saltstack.com/yum/redhat/\$releasever/\$basearch/latest/SALTSTACK-GPG-KEY.pub EOF yum clean expire-cache yum update case "$1" in ########master############# master) yum install salt-master -y yum install salt-ssh -y #yum install salt-syndic -y #yum install salt-cloud -y chkconfig salt-master on /etc/init.d/salt-master start ;; minion) #############Minion####### yum install salt-minion -y yum install salt-ssh -y #yum install salt-syndic -y #yum install salt-cloud -y chkconfig salt-minion on /etc/init.d/salt-minion start ;; *) echo $"Usage: $0 {master|minion}" exit 2 esac |
二、执行脚本
1)在服务端(这里主机名为:backup,IP:172.16.1.41),如果网络原因无法成功安装,请重复执行
bash saltstack_install.sh master
2)在客户端(这里主机名为:web01,IP:172.16.1.31),
bash saltstack_install.sh minion
三、服务端修改配置
vi /etc/salt/master
file_roots: base: - /srv/salt pillar_roots: base: - /srv/pillar |
四、服务端启动
/etc/init.d/satl-master restart
五、客户端修改配置
vi /etc/salt/minion
master: 172.16.1.41 id: web01 |
六、客户端重启
/etc/init.d/minion restart
七、在服务端认证
salt-key
salt-key -A
八、测试
salt 'web01' test.ping
web01: True |
至此,SaltStack的安装及简单的配置已经完成。
欢迎朋友们加入我创建的QQ交流群:161490064