Is there any way to see the group_vars, host_vars, etc. available to a host in ansible?
6,069
Found an answer, from here.
ansible all -m debug -a "var=hostvars[inventory_hostname]"
Related videos on Youtube
Author by
Luis F Hernandez
Updated on September 18, 2022Comments
-
Luis F Hernandez over 1 year
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 theansible_*
variables but none of my defined variables.