multiple loops in single TASK

I want to to install some packages to several almalinux hosts

this TASK works, but I was thinking whether I could put the packages into a loop also (which would result into 2 loops in one TASK)
Can this be done? If so … ‘how’?

I tried to nest it like this

but execution failed with an “unsupported paramter for dnf module: loop” error

This is not possible.
Also, why would you want to ‘nest’ the packages?

ok, thx good point, maybe that’s just me trying to abstract things over the top

You cannot have multiple loops per task (aside from already existing
host loop) BUT you can basically get the same thing by making the data
result into the same thing you would have in that case or you can loop
over an include that has the task with it's own loop.