saltstack-部署
安装epel源(所有主机安装)
[root@salt-server /]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
- 安装salt
master安装salt
[root@salt-server /]# yum -y install salt-master
client安装
[root@salt-client-01 /]# yum -y install salt-minion [root@salt-client-02 /]# yum -y install salt-minion
查看master支持的命令
[root@salt-server /]# salt (tab键补全) salt salt-key salt-run salt-cp salt-master salt-unity
client支持的命令
[root@salt-client-01 /]# salt- salt-call salt-minion
修改client配置文件 (这里保持默认配置)
[root@salt-client-01 /]# vim /etc/salt/minion 16 #master: salt #默认为salt 可改为master的IP 78 #id: #默认为主机名 可根据自身环境修改 唯一的不能冲出
修改/etc/hosts
[root@salt-client-01 /]# echo "192.168.119.132 salt" >> /etc/hosts [root@salt-client-02 /]# echo "192.168.119.132 salt" >> /etc/hosts
启动服务(先启动master)
[root@salt-server /]# /etc/init.d/salt-master start Starting salt-master daemon: [ OK ] [root@salt-client-01 /]# /etc/init.d/salt-minion start Starting salt-minion daemon: [ OK ] [root@salt-client-02 /]# /etc/init.d/salt-minion start Starting salt-minion daemon: [ OK ]
命令执行
[root@salt-server /]# salt-key -L #显示所有minion认证信息 Accepted Keys: Denied Keys: Unaccepted Keys: salt-client-01 salt-client-02 Rejected Keys: [root@salt-server /]# salt-key -A -y # -A接受所有Unaccepted状态的minion认证信息 -a接受指定主机 -y 执行过程中自动yes不用手动 The following keys are going to be accepted: Unaccepted Keys: salt-client-01 salt-client-02 Key for minion salt-client-01 accepted. Key for minion salt-client-02 accepted. [root@salt-server /]# salt-key -L Accepted Keys: salt-client-01 salt-client-02 Denied Keys: Unaccepted Keys: Rejected Keys:
[root@salt-server /]# salt '*' test.ping salt-client-01: True salt-client-02: True
master目录
[root@salt-server salt]# cd pki/ [root@salt-server pki]# ls master [root@salt-server pki]# cd master/ [root@salt-server master]# ls master.pem minions minions_denied minions_rejected master.pub minions_autosign minions_pre [root@salt-server master]# pwd /etc/salt/pki/master minions #已通过认证的key minions_pre #等待认证的key minions_rejected #拒绝的key [root@salt-server master]# pwd /etc/salt/pki/master [root@salt-server master]# ls minions/ salt-client-01 salt-client-02 使用salt-key -d 'salt-client-01' -y 把salt-client-01提出 [root@salt-server master]# ls minions_pre/ salt-client-01 salt-minion-01