Hi everyone,
I have many groups in my inventory like this:
[website-front-lb]
192.168.1.2
192.168.1.3
[proj1-subproj1-lb]
192.168.1.22
192.168.1.33
etc.
Now I want to access members of a specific group in my playbook. Both to show them or use them in conditionals.
I know that the nested {{}} notation is not possible. Also, {{}} can not be used in conditionals like when. I have tried to use "lookup" plugin without success.
Thank you for your help.
A pseudo playbook:
---
- hosts: all
# inventory:
# [website-front-lb]
# 192.168.1.2
# 192.168.1.3
vars:
proj: 'website'
subproj: 'front'
tasks:
- name: "Show group members"
debug: msg=?? # Something like: {{groups[{{proj}}-{{subproj}}-lb]}}
- name: "Conditional"
do something
when: inventory_hostname in {{groups[{{proj}}-{{subproj}}-lb]}}