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.