aboutsummaryrefslogtreecommitdiff
path: root/content/blog/ansible/dump-all-vars.md
blob: d5991a37d4a0586f18ab7b5bf38c425c606a2d95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
---
title: "Dump all ansible variables"
linkTitle: "Dump all ansible variables"
date: 2019-10-15
description: >
  How to dump all variables used by ansible
---

Here is the task to use in order to achieve that :

{{< highlight yaml >}}
- name: Dump all vars
  action: template src=dumpall.j2 dest=ansible.all
{{< /highlight >}}

And here is the template to use with it :

{{< highlight jinja >}}
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 }}
{{< /highlight >}}