1.关闭selinux
sed -in ‘s/SELINUX=enforcing/SELINUX=disabled/‘ /etc/selinux/config setenforce 0
2.关闭防火墙
systemctl disable firewalld.service systemctl stop firewalld.service systemctl is-enabled firewalld.service
3.安装master端
yum -y install salt-master
4.添加启动项,并启动
cp /etc/salt/master{,.bak} egrep -v ‘^#|^$‘ /etc/salt/master
interface: 10.0.0.105 #绑定master通信IP;
auto_accept: True(False) #开启自动认证
file_roots: #指定saltstack文件根目录位置
base:
- /srv/salt
systemctl enable salt-master.service systemctl start salt-master.service
5.利用salt-ssh安装minions端
salt-ssh ‘*‘ -r ‘yum -y install epel-release‘ salt-ssh ‘*‘ -r ‘yum makecache‘ salt-ssh ‘*‘ -r ‘yum -y install salt-minion‘ salt-ssh ‘*‘ -r ‘systemctl enable salt-minion.service‘ salt-ssh ‘*‘ -r ‘cp /etc/salt/minion{,.bak}‘ salt-ssh ‘*‘ -r "sed -in ‘s/#master: salt/master: 10.0.0.105/‘ /etc/salt/minion" salt-ssh ‘*‘ -r "egrep -v ‘^#|^$‘ /etc/salt/minion" salt-ssh ‘*‘ -r ‘systemctl start salt-minion.service‘ salt-key
salt ‘*‘ test.ping
这里说一下之前遇到的问题
我现在的机器是之前用cobbler批量安装(最小化安装,没有firewall),到了salt ‘*’ test.ping 的时候死活ping不同,
重启过,看过日志(日志正常)。。。
解决办法:
yum -y groupinstall base
然后就好了,也有了firewall,最后关闭了firewall就好了
希望可以帮助到大家
6.采用salt-master端执行命令
salt ‘*‘ cmd.run ‘uptime‘
salt3:
05:00:36 up 12 min, 1 user, load average: 0.00, 0.01, 0.03
salt2:
05:00:36 up 12 min, 1 user, load average: 0.00, 0.01, 0.03
附录:
当 /etc/salt/master没有配置auto_accept: True时,需要通过salt-key命令来进行证书认证操作;
salt-key -L 显示已经或未认证的被控端id; Accepted Keys: 已认证清单 Denied Keys: 拒绝 Unaccepted Keys: 未认证清单 Rejected Keys: 被拒绝的清单 salt-key -D 删除所有认证主机id证书; salt-key -d id 删除单个id证书 salt-key -A 接受所有id证书请求 salt-key -a id 接受单个id证书请求 salt-cp 文件传输 salt-key 证书管理 salt-run master runner命令
时间: 2024-11-09 02:50:25