Hi all, 

I am looking for a way to list all variables referenced by a playbook 
without executing any tasks. Ideally, I would also be able to spit out the 
values of those variables for each host matched in the play. 

My use case for this is for when I inherit a complex playbook or role from 
a colleague that is not well documented. 

I know that I can do this: 
ansible -m debug -a "var=hostvars[inventory_hostname]" 
to spit out the variables set for each host in inventory. This works fine, 
but lists every variable defined for those hosts.

I'm only interested in the variables that are used by a given playbook or 
role. Is there a built-in way to do this? 

I know, of course, that I could just read through the playbook/role to pick 
out the variables, maybe there will be a defaults/main.yml, etc. I also 
know that I could just execute the playbook and wait until it complains 
about a missing value. But I'd love a one-stop solution showing me what 
variables are expected (and, ideally, their values when given an 
inventory). 

If there's not a built-in way to do all of this, is there another built-in 
way to get part of the way there?  

We're on Ansible 1.9.4 still, but will be moving to Ansible 2 soon, so help 
on either is appreciated. 

Thanks,
Kevin

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/fd1248ac-23eb-48fd-b9f1-44ef6a08b61d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to