--- # One level of the static check's flattening: moves the pending tasks into pve_vm_test_tasks and # makes their block, rescue and always lists the next pending ones, then recurses until none is left. # Both facts are templated from the values before this task. - name: Flatten one level of blocks ansible.builtin.set_fact: pve_vm_test_tasks: "{{ [pve_vm_test_tasks, pve_vm_test_pending] | flatten(levels=1) }}" pve_vm_test_pending: >- {{ [pve_vm_test_pending | map(attribute='block', default=[]) | list, pve_vm_test_pending | map(attribute='rescue', default=[]) | list, pve_vm_test_pending | map(attribute='always', default=[]) | list] | flatten(levels=2) }} - name: Flatten the next level ansible.builtin.include_tasks: flatten_tasks.yml when: pve_vm_test_pending | length > 0