Official website: http://saltstack.com/
Domestic: http://www.saltstack.cn/
Command format:
Salt ' < operation target > ' < method > < parameters >
1. View minion001 host use:
[[email protected] ~]# salt ' minion001 ' cmd.run ' free -m ' minion001: total used free shared buffers cached mem: 988 560 428 0 32 305 -/+ buffers/cache: 221 766 Swap: 1983 0 1983[[email protected] ~]#
2.-e,--Pcre matches the host with regular expressions
Test if the host that has minion starts is connected
[Email protected] ~]# salt-e ' ^minion ' test.ping minion001:trueminion002:true[[email protected] ~]#
3.-l,--list, filtered in the form of a list of host IDs, similar in format to Python lists
Get System Information for minion001,minion002
[[email protected] ~]# salt -l ' minion001, minion002 ' grains.items osfullnameminion002: ---------- ssds: biosreleasedate: 01/23/2012 biosversion: 6.00 cpu_flags: - fpuminion001: -- -------- SSDs: biosreleasedate: 01/23/2012 biosversion: 6.00 cpu_flags: - fpu - vme - de
4.-g,--grain, matching filtering based on grains information of the host being controlled
The format is: ' <grain value>:<glob expression> '
Example: Filter the kernel for Linux host: Can be written, ' Kernel:linux '
[Email protected] ~]# salt-g ' osrelease:6.4 ' cmd.run ' python-v ' Minion001:python 2.6.6minion002:python 2.6.6[[em AIL protected] ~]#
If you need to mate with a regular expression, use the parameter--grain-pcre, tested only after the colon <glob expression> can use regular
[email protected] ~]# Salt--grain-pcre ' [a-z]+:linux ' test.ping No minions matched the target. No command was sent, no Jid was assigned. [[email protected] ~]# Salt--grain-pcre ' kernel:[a-z]+ ' test.ping minion001:trueminion002:true[[email p Rotected] ~]#
5.-i,--pillar matching filtering based on pillar information of the host being controlled
Format: "Object Name: Object Value"
Filter: ' APACHE:HTTPD ' "Nginx:root:/data"
Pending test ...
6.-n,--Nodegroup, filtering based on grouping in master configuration file/etc/salt/master on the host side
The definition of a group supports regular expressions, grain, conditional operations, etc.
Group, official website: http://docs.saltstack.com/en/latest/topics/targeting/nodegroups.html
[Email protected] ~]# cat/etc/salt/master interface:192.168.224.141 auto_accept:true file_roots:base:-/s Rv/salt nodegroups:group1: ' minion001 ' group2: ' minion002 ' group3: ' minion001,minion002 ' group4: ' * ' GROUP5: ' [email protected]^minion '
[Email protected] ~]# salt-n group1 test.pingminion001:true[[email protected] ~]# salt-n group2 test.pingminion002: True[[email protected] ~]# salt-n group3 test.pingminion002:trueminion001:true[[email protected] ~]# salt-n GROUP4 test.ping minion001:trueminion002:true[[email protected] ~]# salt-n group5 test.pingminion002: Trueminion001:true[[email protected] ~]#
7.-c,--compound, matching host information for different rules according to the conditional operator Not,and,or
Probe ID starts with minion, and the system is connected to the CentOS host
[Email protected] ~]# salt-c ' [email protected]^minion and [email protected]:centos ' test.ping Minion002:trueminio N001:true[[email protected] ~]#
8.-s,--IPCIDR match based on the IP address or IP subnet of the host being controlled
[Email protected] ~]# salt-s ' 192.168.224.142 ' test.pingminion001:true[[email protected] ~]# salt-s ' 192.168.224.0/ ' test.ping Minion002:trueminion001:true[[email protected] ~]#
Centralized management platform Saltstack remote execution commands