Hi, everyone.
I have an Ansible project that has a number of roles, along with several different playbooks. Several roles require certain variables to be set in order for the roles to execute properly. These variables may be set in a number of different places, such as command line (extra vars), inventory files, other roles, or in playbook vars.
Some of our playbooks can take hours to execute fully, so we would like a way to fail fast if required variables are not set. My initial thought was to check that requirements are met in a callback plugin, with the validation occurring in ‘v2_playbook_on_start’.
When a playbook starts, is there one place where I could find all variables that have been defined? I would like to get something of a “master list” of defined variables for the playbook run, compare it to my list of required variables, and determine whether any required variables are not set. For the master list, I am thinking of something like you would get with {{ vars }} in a debug. However, after looking online and looking at the code, I do not believe such a master list exists - I am hoping someone could tell me otherwise or confirm that the only way to get all variables is to cycle through host vars, play vars, role vars, etc. individually.
Any help or feedback would be very much appreciated!
Thanks,
Nick