码迷,mamicode.com
首页 > 其他好文 > 详细

saltstack常用功能

时间:2018-03-23 17:47:26      阅读:621      评论:0      收藏:0      [点我收藏+]

标签: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: unknown
M2Crypto: 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.110
192.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做列表匹配,例如:L@minion1.test.com,minion3.domain.com or bl*.domain.com
I --针对 Pillar 做单个匹配,例如:I@pdata:foobar
S --针对子网或是IP做匹配,例如:S@192.168.1.0/24 or S@192.168.1.100
R --针对客户端范围做匹配,例如:R@%foo.bar

编辑master配置文件,注意组名前有两个空格,后有一个空格
# vi /etc/salt/master

nodegroups:
web: ‘L@192.168.10.110,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常用功能

标签:saltstack   自动化   运维   

原文地址:http://blog.51cto.com/showing/2090354

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!