标签:主机
取出两组中的交集
[root@CentOS6 auto]# ansible Login:\&Player -m ping 交集
No hosts matched
表示两个组中的所有主机
[root@CentOS6 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组中
[root@CentOS6 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"
}
[root@CentOS6 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
-----------
[root@CentOS6 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
…………
本文出自 “态度决定一切” 博客,请务必保留此出处http://relearn.blog.51cto.com/2605709/1689025
标签:主机
原文地址:http://relearn.blog.51cto.com/2605709/1689025