Skip to content

Instantly share code, notes, and snippets.

@Pr1meSuspec7
Created June 4, 2024 21:11
Show Gist options
  • Save Pr1meSuspec7/339ed7f2fafbde69aa9ead76d0793729 to your computer and use it in GitHub Desktop.
Save Pr1meSuspec7/339ed7f2fafbde69aa9ead76d0793729 to your computer and use it in GitHub Desktop.
Ansible loop output in one file
- name: Save output
ansible.builtin.copy:
content: |-
{% for host in ansible_play_hosts_all %}
{{ '### ' }}{{ host }}{{ ' ###' }}
{{ hostvars[host]['result']['stdout_lines'] | to_nice_json }}
{% endfor %}
dest: output.log
mode: "0644"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment