Is there any way in Ansible to succinctly test for set membership in a 
list, from a list?

An example in psuedo-Ansible code:

users:
   - name: Jim
     employee_roles:
        - Admin
   - name: Bob
     employee_roles:
        - DBA
   - name: Suz
     employee_roles:
        - Developer
   - name: Kev
     employee_roles:
        - DBA
        - Developer

Then, in group vars for a set of hosts:

group-a 
----------
active_system_roles:
   - Admin
   - DBA

group-b
----------
active_system_roles:
   - Admin
   - Developer

I'd like a task that could do something like (aware this isn't real code):

tasks:
   - name: Test
     debug:
         msg: "Do a thing to that user on this host"
     with_items: "{{ users }}"
     when: item.employee_roles in 
hostvars[inventory_hostname].active_system_roles

I.E. if any of the employee's roles are in the list of active_system_roles, 
do a thing to that user on that host.



-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/95025760-a26b-4a13-bdf4-60294f84d325%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to