--- - name: Something else hosts: localhost connection: local gather_facts: false vars: bool_a: true bool_b: true bool_c: false bob: dole: execute_thing: true dont_execute_thing: false device: /dev/sally bleh: execute_thing: false dont_execute_thing: false device: /dev/beep tasks: - name: Debug something if some condition ansible.builtin.debug: msg: "We are here." when: - (bool_a | default(false) | bool or bool_b | default(false) | bool) - not bool_c | default(false) | bool - name: Loop bob ansible.builtin.debug: msg: "{{ item['key'] }} -> {{ item['value']['device'] }}" loop: "{{ bob | dict2items }}" loop_control: label: "{{ item['key'] }}" # when: # - "'sally' in item['value']['device']"