天天看點

saltstack指令的使用

saltstack指令的使用

1、核心指令 salt 

Usage: salt [options] '<target>' <function> [arguments]

target用于代表對哪些minion進行操作,可采用如下比對方式:

-E 正規表達式

[root@slat-master ~]# salt -E 'node' test.ping

node2.linux.com:

True

-L 清單的方式

[root@slat-master ~]# salt -L 'node2.linux.com' test.ping

[root@slat-master ~]# salt -L 'agent1.linux.com, node2.linux.com' test.ping

-S  IP網段的方式

[root@slat-master ~]# salt -S '192.168.0.0/24' test.ping

agent1.linux.com:

-N <grp_name>以組的方式調用target

[root@slat-master ~]# salt -N group1 test.ping

組需要在/etc/salt/master事先定義 

# vim /etc/salt/master 

nodegroups:

group1: '[email protected],node2.linux.com'

-C <target>複合條件 

[root@slat-master ~]# salt -C '[email protected] or E@agent' test.ping

-G 使用minion端的Grains值,以鍵值對的方式組成條件

[root@slat-master ~]# salt -G 'os:CentOS' test.ping

#saltstack具體功能的應用待續。。。

本文轉自 北冥有大魚  51CTO部落格,原文連結:http://blog.51cto.com/lyw168/1957662,如需轉載請自行聯系原作者

繼續閱讀