saltstack常用功能
查看版本
# salt --version
salt 2015.5.8 (Lithium)
[root@localhost salt]# salt --version-report
Usage: salt [options] ‘<target>‘ <function> [arguments]
salt: error: no such option: --version-report
# salt --versions-report
Salt: 2015.5.8
Python: 2.6.6 (r266:84292, Jul 23 2015, 15:22:56)
Jinja2: unknownM2Crypto: 0.20.2
msgpack-python: 0.4.6
msgpack-pure: Not Installed
pycrypto: 2.0.1
libnacl: Not Installed
PyYAML: 3.10
ioflo: Not Installed
PyZMQ: 14.3.1
RAET: Not Installed
ZMQ: 3.2.5
Mako: 0.3.4
Tornado: Not Installed
timelib: Not Installed
dateutil: Not Installed
salt-key
查看所的有minion
# salt-key –L
Accepted Keys:
192.168.10.110192.168.43.218
Denied Keys:
Unaccepted Keys:
192.168.10.110
Rejected Keys:
接受指定的minion
# salt-key –a id
# salt-key -a 192.168.10.110
The following keys are going to be accepted:
Unaccepted Keys:
192.168.10.110
Proceed? [n/Y] Y
接受所有的minion
# salt-key -A
刪除指定的minion
# salt-key –d id
# salt-key -d 192.168.10.110
The following keys are going to be deleted:
Accepted Keys:
192.168.10.110
Proceed? [N/y] y
Key for minion 192.168.10.110 deleted.
刪除所有的minion
# salt-key -D
The following keys are going to be deleted:
Accepted Keys:
192.168.10.110
192.168.43.218
Proceed? [N/y] y
Key for minion 192.168.10.110 deleted.
Key for minion 192.168.43.218 deleted.
拒絕指定的minion
# salt-key –r id
拒絕所有的minion
# salt-key -R
The following keys are going to be rejected:
Unaccepted Keys:
192.168.10.110
Proceed? [n/Y] Y
Key for minion 192.168.10.110 rejected.
minion狀態管理
查看存活的minion
# salt-run manage.up
- 192.168.10.249
查看死掉的minion
#salt-run manage.down
查看down掉的minion,並將其刪除
# salt-run manage.down removekeys=True
查看minion的相關狀態
# salt-run manage.status
# salt-run manage.status
down:
up:
- 192.168.10.249
查看slat的所有master和minion的版本信息
# salt-run manage.versions
# salt-run manage.versions
Master:
2015.5.8
2016.Up to date:
----------
192.168.10.249:
2015.5.8
將minion分組
分組規則:
G --針對Grains做單個匹配,例如:G@os:Ubuntu
E --針對minion針對正則表達式匹婚配,例如:E@webd+.(dev|qa|prod).loc
P --針對Grains做正則表達式匹配,例如:P@os:(RedHat|Fedora|CentOS)
L --針對minion做列表匹配,例如:[email protected],minion3.domain.com or bl*.domain.com
I --針對 Pillar 做單個匹配,例如:I@pdata:foobar
S --針對子網或是IP做匹配,例如:[email protected]/24 or [email protected]
R --針對客戶端範圍做匹配,例如:R@%foo.bar
編輯master配置文件,註意組名前有兩個空格,後有一個空格
# vi /etc/salt/master
nodegroups:
web: ‘[email protected],192.168.10.111‘
# salt -N ‘web’ test.ping
192.168.10.110:
True
首先要保證組員在master的列表中,否則對分組進行操作時會不成功:
# salt -N group1 test.ping
No minions matched the target. No command was sent, no jid was assigned.
ERROR: No return received
saltstack常用功能