saltstack学习一
一、安装1、master安装
yum install salt-master
vi /etc/salt/master
interface: 192.168.55.1
/etc/init.d/salt-master start
2、minion安装
yum install salt-minion
vi /etc/salt/minion
master: 192.168.55.1
id: 192.168.5.31
/etc/init.d/salt-minion start
配置文件interface、master和id的冒号后面都有空格,配置文件符合YAML格式。id是用来识别客户端的,可以使用主机名、IP地址等唯一的标识。
3、认证
salt-key -L 命令查看所有的公钥(这里的名字和minion配置文件中的id的value相同),包括accepted,unaccepted,rejected
# salt-key -L
Accepted Keys:
192.168.5.31
192.168.9.2
Unaccepted Keys:
Rejected Keys:
salt-key -a> 4、测试
# salt "*" test.ping
192.168.9.2:
True
192.168.5.31:
True
# salt-run manage.status
down:
up:
- 192.168.5.31
- 192.168.9.2
二、命令简介
salt使用正则表达式
# salt -E "192.168.5.1" test.ping salt根据grain的结果匹配
# salt -G "osrelease:6.5" test.ping 查看grain的所有参数
# salt "192.168.5.31" grains.items salt根据组匹配,在master配置文件中配置组
nodegroups:
group1: 'L@foo.domain.com,bar.domain.com,baz.domain.com and bl*.domain.com'
group2: 'G@os:Debian and foo.domain.com'
# salt -N group1 test.ping cmd.run 在客户端运行命令
# salt "192.168.55.2" cmd.run "hostname -i "
192.168.55.2:
192.168.55.2
页:
[1]