7

So I just started a new company, and while familiarizing myself with the ansible repository, I was wondering if there's any way to see the variables that come from group_vars, host_vars and all that together in one place, it's non-trivial to gather all the facts about a host. For example if I have a hosts file like

[foo:children]
bar

[bar]
baz

and so I have two group_vars files foo.yml

---
app: kyle

and bar.yml

---
env: prod

and then I have a host_vars file baz.yml

---
type: app-server

is there any way to get an out put like the following:

Host: baz
app = kyle
env = prod
type = app-server

I've looked into the setup module, but when I run the equivalent of ansible all -m setup it returns all of the ansible_* variables but none of my defined variables.

Luis F Hernandez
  • 633
  • 1
  • 7
  • 9

1 Answers1

7

Found an answer, from here.

ansible all -m debug -a "var=hostvars[inventory_hostname]"

Luis F Hernandez
  • 633
  • 1
  • 7
  • 9