Ansible的Inventory管理
时间:2017-11-05 21:03:06
收藏:0
阅读:259
Inventory的管理便是服务器的管理。
hosts文件的位置:
- /etc/ansible/hosts
- 在命令行通过-i参数指定
- 通过/etc/ansible/ansible.cfg中的Inventory参数指定
列出服务器 --list-hosts
[root@zydev01 ~]# ansible all --list-hosts hosts (3): 192.168.1.105 120.77.85.77 192.168.1.101
组中组,和组参数
加上children的方式声明组中包含其它组
[atlanta] host1 host2 [raleigh] host2 host3 [southeast:children] atlanta raleigh [southeast:vars] #定义组的主机的参数
ansible_port=3235 some_server=foo.southeast.example.com halon_system_timeout=30 self_destruct_countdown=60 escape_pods=2
mysql_port=3307 [usa:children] southeast northeast
Inventory的参数分为行为参数(ansible默认的,如ansible_port)和自定义变量(mysql_port)
打印参数:
使用正则表达式定义组和匹配组
定义组
[webservers] www[01:50].example.com
[databases]
db-[a:f].example.com
匹配组
ansible web* -m ping
原文:http://www.cnblogs.com/zydev/p/7788667.html
评论(0)