I'm using the icinga2-ansible-add-hosts role, which creates config files
for each host.
My playbook starts like this:
---
- hosts: all
gather_facts: True
- hosts: "{{ hosts | default('monitoring_servers') }}"
- strategy: debug
- role: icinga2-ansible-add-hosts
Inside the add-hosts role is the following task:
--
- name: Copy Host Definitions
template: src=hosts_template.j2
dest={{ icinga2_hosts_dir }}/{{ hostvars[item]['ansible_fqdn']
}}.conf
owner=root
group=root
mode=0644
with_items: "{{ groups['all'] }}"
notify:
- restart icinga2
When I run `ansible-playbook -i inventory/ --limit <GROUP> icinga2.yml
-vvv` I notice that gather_facts is only done on the hosts in <GROUP>, but
the template tries to generate config files for all of my hosts, because
"{{ groups['all'] }}" contains all of the hosts in the inventory directory,
not just those in <GROUP>.
Checking Google and IRC it seems like there is no way to programmatically
get the list of machines specified by --limit. Is that correct? Is there
a way to iterate over a list of hosts that were specified on the command
line?
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/4d48e431-9ea7-49a8-88e4-50675491ee15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.