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