Hello,
I could neither make it work, nor find a clear explanation, on whether it is possible to make a include loop
with with_items: taking a list values produced as the output of another command.
The following works:
command: /usr/bin/something
register: result
debug: msg=“{{item}}”
with_items: ${result.stdout_lines}
However I could not manage the following to work:
command: /usr/bin/something
register: result
include: another_playbook.yml <------ this one has 5 actions that must be executed in a row for each target
with_items: ${result.stdout_lines}
It fails with message:
ERROR: with_items expects a list
My concrete demand is that I have in the included playbook, actions that must be executed in sequence for each target, while targets are not known
util runtime. So I could not use multiple actions, each one with a ‘with_items: with_items: ${result.stdout_lines}’, because the second action in
“another_playbook” should only be executed for the next item if all actions in the playbook have succeeded for the previous item.
Is there an elegant way of doing this with playbooks?
Thanks in advance for any hints.
Best regards,
Luciano Cavalheiro