debugging a loop

How can I debug each iteration of a loop in a playbook?
For example

First run with “-v” to see what the results array looks like.

Then, for the thing that is a loop, you could do:

  • debug: msg={{ item }}
    with_items: foo

Incidentally I think I’d like it if the debug module allowed this

debug: var=varname

(no template args) also

This way it would be easier to use on things that weren’t neatly key=value and could just dump the datastructure by name.

the debug there already does that. itwill run per iteration of the playbook, but not per iteration of the task. result will have an array of the output of the task keyed by item.

you can also use -vvv to get the debug as it happens.

Right, but it should make the variable name a possible key to make it easier to do this with certain data.

Right now, it’s keyed a bit trying to output strings, which causes problems with template evaluation.