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]}}



-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/97e76f5a-28ee-4119-8028-12f61d99a7ffn%40googlegroups.com.

Reply via email to