4

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.

4

Found an answer, from here.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.