Loop over multiple tasks

Hello,

Is it possible in Ansible to loop over multiple tasks?

Something like:

`

  • loop: “{{ mylist }}”

  • name: Task 1
    do something with item step 1

  • name: Task 2
    do something with item step 2

  • name: Task 3
    do something with item step 3

`

The only way I’ve found to accomplish this is to call out to a tasks file within the loop, and include all 3 tasks there. But it would be nicer to be able to do it in a single playbook.

`

  • name: Loop control
    include_tasks: “tasks.yml”
    loop: “{{ mylist }}”

`

Thanks for any feedback!

This is the only way to do it unfortunately.