Ansible - 如何读取主机清单文件中的组名?

时间:2017-05-22 23:56:52

标签: ansible ansible-inventory

[dev]
fitness.dev

[nginx]
fitness.dev
fitness.staging
www1.fitness.tld
www2.fitness.tld

[webserver]
nginx

例如剧本中某些步骤的结果。

tasks:
- name: Print out the group_names
  debug: msg="{{ hostvars.group_names[] }}"

我只关注主机广告资源文件中的group_names。

喜欢:

hostvars.groups_names[0]  is dev  
hostvars.groups_names[1]  is nginx 
hostvars.groups_names[2]  is webservers 

0 个答案:

没有答案