Is there an easy way to log output from multiple remote hosts to a single file on the server running ansible-playbook
?
I have a variable called validate
which stores the output of a command executed on each server. I want to take validate.stdout_lines
and drop the lines from each host into one file locally.
Here is one of the snippets I wrote but did not work:
- name: Write results to logfile
blockinfile:
create: yes
path: "/var/log/ansible/log"
insertafter: BOF
block: "{{ validate.stdout }}"
delegate_to: localhost
When I executed my playbook w/ the above, it was only able to capture the output from one of the remote hosts. I want to capture the lines from all hosts in that single /var/log/ansible/log file.