1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| ansible 192.168.8.34 -m ping 192.168.8.34 | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": false, "ping": "pong" }
#也可以通过密码登录加-k参数 注意要使用ssh先登录一次
ansible 192.168.8.34 -m ping -k
#检查所有主机 ansible all -m ping
#部分主机 ansible 192.168.8.32,192.168.8.33 -m ping
#分组 [web] 192.168.8.32 192.168.8.33 192.168.8.34 [db] 192.168.8.35 192.168.8.36 [cache] 192.168.8.36
#分组范围 [web] 192.168.8.[32:34]
#查看组中所有主机 ansible web --list-hosts
#并集 ansible web,db -m ping ansible 'web:db' -m ping
#交集 ansible 'web:&db' -m ping
#差集 ansible 'web:!db' -m ping #web中有db中无
|