查找目标minion的三种方式:
salt 'shell正则' 命令
salt -E 'prel 正则'
salt -N $group 命令
salt -L 'server_id1,server_id2,server_id3' 命令
根据bash glob来查找:salt ’*foo.com’ sys.doc
根据正则表达式来查找:salt -E ’.*’ cmd.run ’ls -l | grep foo’
根据hostname来查找:salt -L foo.bar.baz,quo.qux cmd.run ’ps aux | grep foo’
根据grains(机器各种信息)来查找:salt -G ’os:Redhat’ test.ping
综合以上几种模式混合查找:salt -C ’G@os:Debian and webser* or E@db.*’ test.ping
常见grains信息如下:
salt '*' grains.ls 查看grains分类
salt '*' grains.items 查看grains所有信息
salt '*' grains.item osrelease 查看grains某个信息
10.15.137.42:
biosreleasedate: 03/07/2013
biosversion: 1.6.0
cpu_flags: fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 x2apic popcnt aes xsave avx lahf_lm ida arat xsaveopt pln pts dts tpr_shadow vnmi flexpriority ept vpid
cpu_model: Intel(R) Xeon(R) CPU E5-2670 0 @ 2.60GHz
cpuarch: x86_64
defaultencoding: UTF8
defaultlanguage: en_US
domain: localdomain
fqdn: localhost.localdomain
gpus:
{'model': 'G200eR2', 'vendor': 'unknown'}
host: localhost
id: 10.15.137.42
ip_inte易做图ces: {'lo': ['127.0.0.1'], 'eth3': [], 'eth2': [], 'eth1': [], 'eth0': ['10.15.137.42']}
ipv4:
10.15.137.42
127.0.0.1
kernel: Linux
kernelrelease: 2.6.32-279.el6.x86_64
localhost: localhost.localdomain
manufacturer: Dell Inc.
master: 10.10.144.112
mem_total: 193651
nodename: localhost.localdomain
num_cpus: 32
num_gpus: 1
os: RedHat
os_family: RedHat
osarch: x86_64
oscodename: Santiago
osfinger: Red Hat Enterprise Linux Server-6
osfullname: Red Hat Enterprise Linux Server
osmajorrelease:
6
3
osrelease:6.3
path: /sbin:/usr/sbin:/bin:/usr/bin
productname: PowerEdge R720
ps: ps -efH
pythonpath:
/usr/bin
/usr/lib64/python26.zip
/usr/lib64/python2.6
/usr/lib64/python2.6/plat-linux2
/usr/lib64/python2.6/lib-tk
/usr/lib64/python2.6/lib-old
/usr/lib64/python2.6/lib-dynload
/usr/lib64/python2.6/site-packages
/usr/lib64/python2.6/site-packages/gtk-2.0
/usr/lib/python2.6/site-packages
/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info
pythonversion: 2.6.6.final.0
saltpath: /usr/lib/python2.6/site-packages/salt
saltversion: 0.16.4
serialnumber: C786BX1
server_id: 489250112
shell: /bin/sh
virtual: physical