I have my inventory file configured with group variables. Example:
all:
children:
europe:
vars:
network_id: 3
network_name: "europe-eu"
hosts:
europe-eu-1254:
ansible_host: 8.8.8.8
ansible_ssh_pass: password
ansible_ssh_user: user
...
I would like to get the group variables in my tasks, but I have no idea how.
Example of the task:
- name: Start latest container
docker_container:
name: "server-{{ hostvars[inventory_hostname].vars.network_name }}"
image: "{{ docker_registry }}:{{ docker_tag }}"
state: started
recreate: yes
network_mode: host
oom_killer: no
restart_policy: always
become: yes
...
I assume, that {{ hostvars[inventory_hostname].vars.network_name }}
is not the right way.
{{ network_name }}
should contain it if the server is in groupeurope