saltstack 是最近比較流行的自動化運維工具之一,默認是有服務端 salt-master ,客戶端 salt-minion 的方式運行,也可以使用 ssh (salt-ssh),后面的文章會介紹。
最近在研究saltstack,網上的文檔千篇一律,為了加深記憶,干脆自己寫了,根據官方文檔來解釋,英文水平有限,能寫出多少意思就寫多少吧。
installation:
基本安裝步驟如下:
1.根據說明為你的系統平台,或者是使用引導腳本(bootstrap script),安裝salt-master。如果你使用安裝引導腳本的話,必須要加上 -M 選項。
2.確定你的 salt-minion 能找到 salt-master,也就是服務端和客戶端在網絡上是通的,一般是通過主機名來查找 。
3.在每一台你想管理的機器上安裝 salt-minion。
4.salt-minion 可以正常連接后,要在 salt-master 同意 minion 端的 key.
做完這一切,你可以使用下面的命令測試一下:salt '*' test.ping
quick install (快速安裝):
在大多數linux發行版本上,你可以通過 salt bootstrap來建立 salt minion,這種方法下篇文章介紹。
PLATFORM-SPECIFIC INSTALLATION INSTRUCTIONS(各種平台的安裝說明)
根據平台的不同,官網都有相對應的安裝說明,平台如下:
- Arch Linux
- Debian GNU/Linux / Raspbian
- Fedora
- FreeBSD
- Gentoo
- OpenBSD
- macOS
- RHEL / CentOS / Scientific Linux / Amazon Linux / Oracle Linux
- Solaris
- Ubuntu
- Windows
- SUSE
我這里只記錄 redhat family 發行版的安裝說明。
從官方 saltstack repository 安裝
自2015.8.0開始,在RHEL系統上安裝時不再需要epel庫,saltstack 存儲庫里提供了所有必需的依賴項。
[saltstack-repo]
name=SaltStack repo for Red Hat Enterprise Linux $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 https://repo.saltstack.com/yum/redhat/$releasever/$basearch/latest/base/RPM-GPG-KEY-CentOS-7
## 警告:如果是安裝在未注冊的 RHEL7系統上,需要加上centos7 的GPG key url
## 注意:systemd 和 systemd-python 是使用salt所必需的,請確認在安裝 salt 之前安裝了它
安裝命令:
yum install salt-master
yum install salt-minion
yum install salt-ssh
yum install salt-syndic
yum install salt-cloud
使用PIP安裝
pip install salt
安裝后的任務
MASTER
開機自啟動:
RHEL/CentOS 5 and 6
chkconfig salt-master on
RHEL/CentOS 7
systemctl enable salt-master.service
啟動 salt-master:
RHEL/CentOS 5 and 6
service salt-master start
RHEL/CentOS 7
systemctl start salt-master.service
MINION
開機自啟動:
RHEL/CentOS 5 and 6
chkconfig salt-minion on
RHEL/CentOS 7
systemctl enable salt-minion.service
啟動 salt-minion:
RHEL/CentOS 5 and 6
service salt-minion start
RHEL/CentOS 7
systemctl start salt-minion.service