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