I have a static inventory that contains groups and servers inside these groups. Group names can change and so the server names. I'm passing group names as a variable during runtime to the playbook. I'm trying to check a bunch of ports between different servers in the inventory.
So if this is the inventory
group1
server1
group2
server2
server3
And I have group1 and group2 as variables.
I'm trying to do something like this
hosts: group1_var
tasks:
- name: test connection
ansible.windows.win_wait_for:
host: **{{groups[group2_var]}}** ##How do I implement this correctly????
port: 443
delay: 3
Also a second part to this question, but I cannot for some reason return the value of the magic variable if groupX is a variable. When it's a simple string it returns the server names ok.
debug : msg="{{groups['{{groupX}}']))"