454luikty 发表于 2017-8-21 11:39:44

saltstack命令的使用

saltstack命令的使用


1、核心命令 salt

Usage: salt '<target>' <function>

target用于代表对哪些minion进行操作,可采用如下匹配方式:

-E 正则表达式

# salt -E 'node' test.ping
node2.linux.com:
True


-L 列表的方式

# salt -L 'node2.linux.com' test.ping
node2.linux.com:
True

# salt -L 'agent1.linux.com, node2.linux.com' test.ping

-SIP网段的方式

# salt -S '192.168.0.0/24' test.ping
node2.linux.com:
True
agent1.linux.com:
True


-N <grp_name>以组的方式调用target

# salt -N group1 test.ping

组需要在/etc/salt/master事先定义

# vim /etc/salt/master
nodegroups:
group1: 'L@agent1.linux.com,node2.linux.com'


-C <target>复合条件

# salt -C 'L@node2.linux.com or E@agent' test.ping


-G 使用minion端的Grains值,以键值对的方式组成条件

# salt -G 'os:CentOS' test.ping


页: [1]
查看完整版本: saltstack命令的使用