I have a dummy doubt that keeps me stuck for a long time. I have a very banal inventory file with hosts and variables:
[lb] 10.112.84.122 [tomcat] 10.112.84
- name: host debug: msg="{{ item }}" with_items: - "{{ groups['tests'] }}"
This piece of code will give the message:
'10.112.84.122' '10.112.84.124'
as groups['tests'] basically return a list of unique ip addresses ['10.112.84.122','10.112.84.124'] whereas groups['tomcat'][0] returns 10.112.84.124.
groups['tests']
['10.112.84.122','10.112.84.124']
groups['tomcat'][0]
10.112.84.124