--- - name: Verify that each entry defines either a user or a group ansible.builtin.assert: that: - (item.user is defined and item.user | length > 0) != (item.group is defined and item.group | length > 0) fail_msg: > Each entry of sudo_users_sudoers must define either 'user' or 'group', but not both and not none. quiet: true with_items: "{{ sudo_users_sudoers }}"