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