I've been crafting a lookup plugin recently to fetch information from
Hiera, as we're heavily a Puppet shop but are investigating Ansible for
managing small one-off systems that would be too complicated to manage with
Puppet. To do so, I got a pull request merged in the Hiera project that
allows the 'hiera' client to optionally return data in JSON, which I then
parse and return from a lookup plugin.
In order to keep from hardcoding Hiera lookups in templates and such, I
load them (and clean up the names) in a variables file like:
---
nrpe_server_port: "{{ lookup('hiera', 'nrpe_server_port') }}"
nrpe_user: "{{ lookup('hiera', 'nrpe_user') }}"
nrpe_group: "{{ lookup('hiera', 'nrpe_group') }}"
nrpe_allowed_hosts: "{{ lookup('hiera', 'nrpe::allowed_hosts') }}"
nrpe_commands: "{{ lookup('hiera', 'icinga::nrpe::commands') }}"
However, I've encountered a couple of issues with this. As you might be
able to infer from the example above, our Hiera data contains all sorts of
types (strings, ints, lists, hashes). While developing this, I've
encountered errors such as some underlying, unexposed Python bit expecting
a string and getting an int or dict (wish I could remember specifically
what scenario that was in), etc. The issue with the above variable
declarations is that some of that data is of a complex type
('nrpe::allowed_hosts' returns a list, 'icinga::nrpe::commands' returns a
dictionary), and it seems that I'm unable to store complex types coming
from a lookup plugin in this way.
Does anyone have a suggestion as to how to reference / store data resulting
from a lookup in a variables file as something other than a string?
Thanks in advance!
--
Michael Porter
--
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].
For more options, visit https://groups.google.com/groups/opt_out.