MENU

saltstack 远程执行 1. 目标

January 1, 2018 • Read: 3990 • 17年实战

官网

    https://docs.saltstack.com/en/latest/topics/tutorials/modules.html#target

格式

salt '<target>' <function> [arguments]

常用方法

salt (默认支持通配符)
salt -E (正则)
salt -G (grains)
salt -P (pillar)
salt -S (ip地址)
salt -C (混合)

默认 (支持通配符)

salt '*' test.ping
salt 'Test[0-9]' test.ping
salt 'T[a-z]*' test.ping

正则

salt -E  'web1-(prod|devel)' test.ping
#匹配prod 或者dev

grains

</pre>
salt -G 'os:Ubuntu' test.ping
</pre>

pillar

salt -p 'os:(Ubuntu|Centos)'

支持正则

ip 地址

salt -S '192.168.0.109' test.ping
salt -S '192.168.0.0/24' test.ping

混合

salt -C 'S@192.168.0.102 or  E@T.*d.(prod|devel).com' test.ping
#匹配IP地址或者正则

功能

salt '*' sys.doc
salt '*' cmd.run 'uname -a'
salt '*' cmd.run 'uname -a'

参数

salt '*' cmd.exec_code python 'import sys; print sys.version'
salt '*' pip.install salt timeout=5 upgrade=True

兼总条贯 知至知终

最后编辑于: March 26, 2018