取出两组中的交集
[[email protected] auto]# ansible Login:\&Player -m ping 交集
No hosts matched
表示两个组中的所有主机
[[email protected] auto]# ansible Login:Player -m ping
player_centos6.5-2 | success >> {
"changed": false,
"ping": "pong"
}
login_centos6.5-1 | success >> {
"changed": false,
"ping": "pong"
}
非的表达式,目标主机在Login组中但不在Player组中
[[email protected] auto]# ansible all:\!Player -m ping
login_centos6.5-1 | success >> {
"changed": false,
"ping": "pong"
}
room_centos6.5-3 | success >> {
"changed": false,
"ping": "pong"
}
session_centos6.5-4 | success >> {
"changed": false,
"ping": "pong"
}
[[email protected] auto]#
eg:
----------
[Login]
login_centos6.5-1 ansible_ssh_host=192.168.31.129
player_centos6.5-2 ansible_ssh_host=192.168.31.202
[Player]
player_centos6.5-2 ansible_ssh_host=192.168.31.202
-----------
[[email protected] auto]# ansible Login:\!Player -m ping
login_centos6.5-1 | success >> {
"changed": false,
"ping": "pong"
}
定义组:具体可以参考/etc/ansible/hosts
eg:
[Login]
login_centos6.5-1 ansible_ssh_host=192.168.31.129
[Player]
player_centos6.5-2 ansible_ssh_host=192.168.31.202
[Hello:children]
Login
Player
[TEST2]
login_centos6.5-1
player_centos6.5-2
…………