# Save debug results to a local file ( not copying all )

**URL:** <https://forum.ansible.com/t/save-debug-results-to-a-local-file-not-copying-all/34539>\
**Category:** Ansible Project\
**Created:** [January 29, 2021, 2:47pm UTC](https://forum.ansible.com/t/save-debug-results-to-a-local-file-not-copying-all/34539 "2021-01-29T14:47:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ramesh\_AR](https://avatars.discourse-cdn.com/v4/letter/r/3e96dc/32.png) [@Ramesh\_AR](https://forum.ansible.com/u/Ramesh_AR)\
**Post date:** [January 29, 2021, 2:47pm UTC](https://forum.ansible.com/t/save-debug-results-to-a-local-file-not-copying-all/34539/1 "2021-01-29T14:47:23Z")

</div>

I have a task that will save outputs to a local file, when I check the text file the contents are missing .  
ex: I have 13 inventory host and should run each task and save the output to local file. so ideally should have all 13 results in each file.

I tried serial fork but nothing helped. can someone plz assist.

$ cat 1txt |grep IP |wc -l  
13  
$ cat 2.txt |grep IP |wc -l  
12  
$ cat 3.txt |grep IP |wc -l  
13  
$ cat 4.txt |grep IP |wc -l  
12  
$ cat 5.txt |grep IP |wc -l  
12  
$ cat 6.txt |grep IP |wc -l  
13

- name: save output to a file  
connection: local  
lineinfile:  
line: “IP is {{ inventory\_hostname.split() | list | to\_yaml }} {{ result | list | to\_yaml }}”  
dest: /tmp/user.txt  
create: yes  
insertafter: EOF  
state: present  
delegate\_to: localhost

I tried copy module but the output saved only last output . that’s the reason opted for lineinfile.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [February 1, 2021, 2:37pm UTC](https://forum.ansible.com/t/save-debug-results-to-a-local-file-not-copying-all/34539/2 "2021-02-01T14:37:37Z")

</div>

if you are targeting more than one host at a time, you have a  
concurrency issue, multiple tasks trying to write to the same file at  
the same time. Use throttle to ensure only one process is doing so.
