I have about 10 hosts that I run a playbook for them with serial:1
. in this playbook there is this code which append output of all commands in one file:
- name: copy the output to a local file
lineinfile:
dest: "{{ myshell_output4.stdout }}"
line: "{{ item }}"
insertafter: EOF
with_items:
- "########################################################"
- "###############HOSTNAME:{{ inventory_hostname }}################"
- "{{ myshell_output3.stdout }}"
- "########################END#############################"
delegate_to: localhost
it is always working for the first host but for others it only insert second and third line and skip first and last line. the out put of file is like this:
########################################################
###############HOSTNAME:12.15.1.1################
(some output here)
########################END#############################
###############HOSTNAME:12.15.2.2################
(some output here)
###############HOSTNAME:12.15.3.3################
(some output here)
.
.
why this happen and how i can prevent it?