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.