I have an inventory file named hospital.inventory and it contains following group with a single value.
[dockerSwarmManager]
hp2-3.mydomain.com
Then I have a file name security.json.j2 inside the folder call templates. In there I want to refer above mentioned value in below placeholder.
"wellKnownUrl": "https://_placeholder_value_/my-configuration",
Is there any direct way of doing that?
As an alternative, how I did was declare a variable in main.yml file inside defaults directory and use it.
swarm_hostname: "\
{% for host in groups['dockerSwarmManager'] -%}\
{{host}}\
{%- if not loop.last %}, {% endif -%}\
{%- endfor %}"
I don't think it's nice to use a loop just to extract a single value from a group inside the inventory file even though I get the expected output.