码迷,mamicode.com
首页 > 其他好文 > 详细

Ansible主机与组的定义Inventory

时间:2015-08-28 02:30:04      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:主机

取出两组中的交集

[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

Ansible主机与组的定义Inventory

标签:主机

原文地址:http://relearn.blog.51cto.com/2605709/1689025

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!