I would like to create an Ansible Module that can be used to lookup
variables of a given role.
Background:
Our build Git repository is organized in away that we have one Ansible role
per micro service (built repo). Those roles have the "default/main.yml",
through which we define a number of default values for the role itself and
the variables we override for the "dependencies" roles.
For example, numerious roles have the variable "myrole.python.version",
which typically holds a reference to the respective global version variable
that lives in our global variables file. Note, this variable file is
available during runtime by the use of the "vars_files" module directive in
the initial playbook. So typically, such variable in "default/main.yml"
would look like.
myrole:
python:
version: "{{ our.global.vars.python.version }}"
This all works fine when we execute a playbook to build a particular
service as it can interpolate those values.
Note, although the majority of those version values are referenced as
outline above, some of them are hard coded by assigning a string value
(i.e. "1.2.3") instead of the global variable reference.
Use Case:
In our particular use case, we would like to implement version auditing so
we have a complete overview on which versions are used across all our micro
services. In order to do this reliably, we need to lookup and interpolate
the variables in the same way as a playbook play would do.
Questions:
How would you implement this?
We thought of creating an Ansible module that plays a give playbook
programmatically with the "--check" option, then somehow capture a given
variable and return it. There are quite a few unknowns for us as to how we
can achieve this with such approach. In addition it would require quite a
bit of computing to produce one variable value as output. What's your
opinion?
Is there a way of interpolating variables, exactly the way Ansible does
when playing a playbook, without actually playing an entire playbook?
Your help is much appreciated!
--
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/bf627d2e-6ae0-4b8f-84e9-59bdfc9a45ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.