--- - name: In application gateway state include: "{{ item.state | default('present', true) }}.yml" vars: agw: "{{ item }}" when: - action is undefined - (agws | default([], true) | length) > 0 with_items: "{{ agws }}" - name: Update/create application gateway include: present.yml vars: agw: "{{ item }}" when: - action is defined - action == 'present' - (agws | default([], true) | length) > 0 with_items: "{{ agws }}" - name: Delete application gateway include: absent.yml vars: agw: "{{ item }}" when: - action is defined - action == 'absent' - (agws | default([], true) | length) > 0 with_items: "{{ agws }}" ...