Skip to content

Instantly share code, notes, and snippets.

@sivel
Created February 9, 2016 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sivel/594035c77510dd633e41 to your computer and use it in GitHub Desktop.
Save sivel/594035c77510dd633e41 to your computer and use it in GitHub Desktop.
Create Ansible host vars dump for all hosts
{
{% for host in groups.all %}
"{{ host }}": {{ hostvars[host]|to_json }}{{ ',' if not loop.last else '' }}
{% endfor %}
}
---
- hosts: all
gather_facts: true
tasks:
- name: Create hostvars dump
copy:
content: "{{ lookup('template', 'dump.j2')|from_json|to_nice_json }}"
dest: ./dump.json
run_once: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment