Hi all ! is there any way of achieving the following ?
( i’ve tried this ones and i get “no hosts matched ” )
monitor_group = “glance”
hosts: “{{ monitor_group }}”
roles:
{ role: icinga2-check-commands, tags: [‘monitor-cloud’] }
OR
monitor_group = glance
hosts: “{{ monitor_group }}”
roles:
{ role: icinga2-check-commands, tags: [‘monitor-cloud’] }
Uwe_Sauter
(Uwe Sauter)
November 13, 2015, 3:58pm
2
What about:
- vars:
monitor_group: "glance"
- hosts: "{{ monitor_group }}"
roles:
- { role: icinga2-check-commands, tags: ['monitor-cloud'] }
I'm not saying that this'll work as I am trying to figure out variables myself. But you could give it a try.
Thank for the response, sorry that i didnt clarify this.
The monitor_cloud variable is in the [all:vars] section of the inventory.
Uwe_Sauter
(Uwe Sauter)
November 13, 2015, 4:12pm
4
I'm not sure I understand which variable troubles you. Is it "monitor_group" or "monitor-cloud" or "monitor_cloud"? Is there a
typo (underscore / dash)?
My problem is that i cant use a variable for the "- host: " part to realize what servers to run on.
Brian_Coca
(Brian Coca)
November 15, 2015, 8:17pm
7
group_vars/ are loaded AFTER -hosts: so you cannot use them to set the
hosts, you can do this using extra vars though:
ansible-playbook ... play.yml ... -e 'monitor_group=<hostname>'
Genius Brian.
thanks so much !