Reputation: 602
I have a variable client: client1
and I want to use it to fetch multiple facts into a template like below.
"{{ hostvars[{{ client }}][ansible_default_ipv4][address] }}"
"{{ hostvars[{{ client }}][ansible_hostname] }}"
"{{ hostvars[{{ client }}][ansible_fqdn] }}"
I have tried removing the braces, using a dictionary[key] in place of client but couldn't figure out. What is the right usage here?
Upvotes: 0
Views: 2811
Reputation: 68319
The right answer is: "{{ hostvars[client]['ansible_default_ipv4']['address'] }}"
Upvotes: 2