saltstack的簡單安裝配置

2021-09-10 02:01:55 字數 2324 閱讀 9733

系統環境:服務端和客戶端均為centos7,關閉防火牆和selinux

安裝master和minion

[root@v72 yum.repos.d]# yum install salt-master  -y

[root@v72 yum.repos.d]# yum install salt-minion  -y

[root@v73 ~]# yum install salt-minion -y

修改客戶端的配置檔案,就是改16行的master指向

[root@v72 yum.repos.d]# sed -i.bak '16s/#master: salt/master: 192.168.156.72/' /etc/salt/minion

[root@v73 yum.repos.d]# sed -i.bak '16s/#master: salt/master: 192.168.156.72/' /etc/salt/minion

啟動服務端和客戶端的服務

[root@v72 init.d]# service salt-master start

redirecting to /bin/systemctl start salt-master.service

[root@v72 init.d]# service salt-minion start 

redirecting to /bin/systemctl start salt-minion.service

[root@v73 yum.repos.d]# service salt-minion start

redirecting to /bin/systemctl start salt-minion.service

順著這個指令碼的思路可以實現批量安裝,一併把ssh免登陸驗證也完成了:

[root@m6 yum.repos.d]# cat /shell/installsaltmoint.sh 

#!/bin/bash

a=`cat /root/.ssh/id_rsa.pub`

cat /shell/pwd.txt | while read line

dohostip=`echo $line | cut -d" " -f1`

uname=`echo $line | cut -d" " -f2`

pwd=`echo $line | cut -d" " -f3`

/usr/bin/expect <<-eof

set time 30

spawn ssh $uname@$hostip

expect

"*password:"

}expect "*#"

send "echo $a >> /root/.ssh/authorized_keys\r"

expect "*#"

send "exit\r"

interact

expect eof

eofcd /etc/yum.repos.d

scp epel.repo centos-base.repo $uname@$hostip:/etc/yum.repos.d

ssh -n $uname@$hostip "yum install salt-minion -y"

ssh -n $uname@$hostip "sed -i.bak '16s/#master: salt/master: 192.168.156.72/' /etc/salt/minion" 

ssh -n $uname@$hostip "service salt-minion start"

done

cd /etc/yum.repos.d

檢視並接收客戶端

[root@v72 init.d]# salt-key

accepted keys:

denied keys:

unaccepted keys:

v72v73

rejected keys:

[root@v72 init.d]# salt-key -a

the following keys are going to be accepted:

unaccepted keys:

v72v73

proceed? [n/y] y

key for minion v72 accepted.

key for minion v73 accepted.

[root@v72 init.d]# salt-key

accepted keys:

v72v73

denied keys:

unaccepted keys:

rejected keys:

執行命令測試

saltstack安裝配置

1.準備三颱機器 salt master 192.168.4.68 salt minion1 192.168.4.67 salt minion2 192.168.4.69 2.開始安裝 salt master rpm ivh yum y update yum install y salt maste...

saltstack安裝配置(halite)

saltstack官方提供了乙個簡單的web ui halite。但是給出的安裝配置方法實在沒法實現,在網上找了幾篇部落格,見文章末尾的參考鏈結,可以用起來了。但是功能有點簡單。這篇文章記錄安裝配置halite的過程。1.從github轉殖halite原始碼。2.安裝salt api yum ins...

CentOS 7下SaltStack安裝配置詳解

centos 7下saltstack安裝配置詳解 簡述 saltstack saltstack是乙個新的基礎平台管理工具,只需要花費數分鐘即可執行起來,可以支撐管理上萬台伺服器的規模,數秒鐘即可完成資料傳遞。saltstack是使用python語言開發的,同時也支援restapi方便二次開發以及和它...