# registered variables being dumped to local files

**URL:** <https://forum.ansible.com/t/registered-variables-being-dumped-to-local-files/25179>\
**Category:** Ansible Project\
**Created:** [August 3, 2017, 7:18pm UTC](https://forum.ansible.com/t/registered-variables-being-dumped-to-local-files/25179 "2017-08-03T19:18:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dewey\_Hylton](https://avatars.discourse-cdn.com/v4/letter/d/df788c/32.png) [@Dewey\_Hylton](https://forum.ansible.com/u/Dewey_Hylton)\
**Post date:** [August 3, 2017, 7:18pm UTC](https://forum.ansible.com/t/registered-variables-being-dumped-to-local-files/25179/1 "2017-08-03T19:18:12Z")

</div>

hi all. i run a python script on a linux server that produces a report relating to  
patch levels and such. it's a fairly simple thing that was requested for audit  
purposes. it's a home-grown script. it works fine, and does what it needs to do.  
the report it produces is simply sent to stdout.

with the hope of producing a single report covering all of these servers, i have  
created a simple playbook which is designed to run the script on all targets,  
capture their report via stdout, and add the reports to a single local file via  
local\_action. sometimes this works, and sometimes it does not. in all cases i  
can see that the report is generated (stdout for each target shows on the  
ansible controller during task execution). but sometimes all output for a given  
target is missing from the local logfile. here is the playbook:

in case it gets munged in email:  
&nbsp;&nbsp;&nbsp;&nbsp;[https://paste.pound-python.org/show/Q8hdyPC38ADSYCX82wwV/](https://paste.pound-python.org/show/Q8hdyPC38ADSYCX82wwV/)

---

<div class="post-metadata">

**Author:** ![Dewey\_Hylton](https://avatars.discourse-cdn.com/v4/letter/d/df788c/32.png) [@Dewey\_Hylton](https://forum.ansible.com/u/Dewey_Hylton)\
**Post date:** [August 3, 2017, 7:40pm UTC](https://forum.ansible.com/t/registered-variables-being-dumped-to-local-files/25179/2 "2017-08-03T19:40:50Z")

</div>

sorry, i pasted an older (broken) yml ...

[https://paste.pound-python.org/show/QAOL5ukLVvAtqtCN8I3V/](https://paste.pound-python.org/show/QAOL5ukLVvAtqtCN8I3V/)

the difference is "report.stdout" vs "report.stdout.lines" ...  
this issue also happens with blockinfile.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [August 3, 2017, 8:15pm UTC](https://forum.ansible.com/t/registered-variables-being-dumped-to-local-files/25179/3 "2017-08-03T20:15:43Z")

</div>

Lets say you have 20 host, then you would have 20 task trying to write to the same file at once(or at least 5 at a time with default, because forks is default set to 5), this will seldom if at all work.

You can use assemble or the template module, personally I would use the template.

local\_report.j2

---

<div class="post-metadata">

**Author:** ![Dewey\_Hylton](https://avatars.discourse-cdn.com/v4/letter/d/df788c/32.png) [@Dewey\_Hylton](https://forum.ansible.com/u/Dewey_Hylton)\
**Post date:** [August 3, 2017, 8:26pm UTC](https://forum.ansible.com/t/registered-variables-being-dumped-to-local-files/25179/4 "2017-08-03T20:26:42Z")

</div>

This makes a lot of sense. I thought i had multiple things running into each other, and I suppose  
the fact that it seemed to work sometimes threw me off somewhat.

Thanks!
