Skip to content

Instantly share code, notes, and snippets.

@ymartin59
Created February 1, 2021 17:28
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 ymartin59/0705a7803b12cfed2590aec3639e526f to your computer and use it in GitHub Desktop.
Save ymartin59/0705a7803b12cfed2590aec3639e526f to your computer and use it in GitHub Desktop.
Ansible playbook to dump host environment, groups and variables
# Standalone easy-to-use one-file playbook
# Inspired from https://coderwall.com/p/13lh6w/dump-all-variables
- hosts: all
gather_facts: yes
become: no
connection: local
vars:
debug_file: "debug_env_{{ inventory_hostname }}.log"
tasks:
- name: Dump all host variables
copy:
dest: ./{{ debug_file }}
content: |
Module Variables ("vars"):
--------------------------------
{{ vars | to_nice_json }}
Environment Variables ("environment"):
--------------------------------
{{ environment | to_nice_json }}
GROUP NAMES Variables ("group_names"):
--------------------------------
{{ group_names | to_nice_json }}
GROUPS Variables ("groups"):
--------------------------------
{{ groups | to_nice_json }}
HOST Variables ("hostvars"):
--------------------------------
{{ hostvars | to_nice_json }}
- debug:
msg="Look at content of local file ./{{ debug_file }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment