salt '*' cmd.run 'ifconfig' # 对所有slave操作用 " * " salt 'slave_id' cmd.run 'ifconfig' # 对指定slave操作用 "slave_id"
salt可以直接让minion执行模块命令,也可以直接执行shell命令 1.salt -C ‘wy-pe1 and wy-pe2 or wy-peN’ test.ping -C表示多参数(表示在测试多台主机的存活状态) # salt '*' disk.usage 查看磁盘使用情况(使用内建模块查看所有minion端的磁盘使用情况) #salt '*' cmd.run 'df -h' 使用cmd.run直接调用远程shell命令(功能同上) # salt '*' cmd.run 'cat /root/lall' 查看客户端主机的/root/lall文件
2.nodegroup对minion进行分组
1 2 3 4 5 6 7 8
nodegroups: group1: ‘L@foo.domain.com,bar.domain.com,baz.domain.com or bl*.domain.com’ group2: ‘G@os :Debian and foo.domain.com’ group3:’wy-pe2′ 进行分组测试: # salt -N group3 test.ping wy-pe2: True
3.grains对minion基本信息的管理:
1 2
salt ‘wy-pe2′ grins.ls 查看grains分类 salt ‘wy-pe2′ grins.items 查看minnon基本信息(硬件参数)
4.pillar对敏感信息的管理,只有匹配到的节点才能获取和使用
1
默认pillar数据定义文件存储路径:/srv/pillar
1.5. debug排错
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
[root@pw-aimm-srv master]# salt-minion -l debug [DEBUG ] Reading configuration from /etc/salt/minion [DEBUG ] Including configuration from '/etc/salt/minion.d/_schedule.conf' [DEBUG ] Reading configuration from /etc/salt/minion.d/_schedule.conf [DEBUG ] Using cached minion ID from /etc/salt/minion_id: pw-aimm-srv [DEBUG ] Using pkg_resources to load entry points [DEBUG ] Override __grains__: <module 'salt.loaded.int.log_handlers.sentry_mod' from '/usr/lib/python3.6/site-packages/salt/log/handlers/sentry_mod.py'> [DEBUG ] Configuration file path: /etc/salt/minion [WARNING ] Insecure logging configuration detected! Sensitive data may be logged. [INFO ] Setting up the Salt Minion "pw-aimm-srv" [INFO ] An instance is already running. Exiting the Salt Minion [INFO ] Shutting down the Salt Minion [DEBUG ] Stopping the multiprocessing logging queue listener [DEBUG ] closing multiprocessing queue [DEBUG ] joining multiprocessing queue thread [DEBUG ] Stopped the multiprocessing logging queue listener The Salt Minion is shutdown.