user18
(Александр Лозовской)
1
Hi! How i can get stdout using loop (f.e. for with_sequence statement)?
An example of how I want to use it:
Введите код...
The above request was registered to a variable called “status”, but since you are using with_sequence this is saved in an array.
Take a look at what you have like so:
Finally, you’ll probably see that you want:
- debug: msg="{{ item.stdout }}
with_items: status
item doesn’t mean anything unless there’s a loop in play, so you have to loop over status to use it.
status will be a list, so you have 4 stdouts to look at:
- debug: msg={{item.stdout}}
with_items: status.results
user18
(Александр Лозовской)
4
In this case i got all message from status.results and stdout after it.
I solved this problem through this:
debug: msg="{% for results in status.results %} {{results.cmd.7}} - {{ results.stdout }} {% endfor %}"
In this case, I get what I need, but all 4 stdout output in a single line. How do I put a linebreak after each row (Ansible escapes ‘\n’).