Open floot opened 4 years ago
This looks related to https://github.com/philpep/testinfra/issues/345 where I suggested to add a playbook
argument to ansible.get_variables()
. Not sure how it will be complex to handle lookup plugins here too.
Unfortunately I don't have much time to work on this :/
Works with workarround
Use a specific ansible cfg for testinfra: ansible.testinfra.cfg
with lookup_plugins
params
...
[defaults]
lookup_plugins = roles/<role>/lookup_plugins
...
And run:
ANSIBLE_CONFIG=ansible.testinfra.cfg py.test testinfra/ ...
Hi,
Inside our Testinfra test suite, we would like to make checks against values that make calls to custom Ansible lookup plugins. The fact is, I could not find a way of enabling a custom lookup plugin in Testinfra like we already do in our playbooks.
What we usually do in our playbooks looks like this:
...so that when a variable with the form
foo: {{ lookup('custom_lookup_plugin', param1, param2 }}
is used inactual_role
, it is indeed evaluated by calling the lookup plugin.Then when I use inventory's host/group vars containing such vars in Testinfra, I write a Pytest fixture like this one:
But when I use this fixture in a test method, it just fails with finding my lookup plugin:
So my question is: how can I use a custom Ansible lookup plugin properly in Testinfra, when it is provided/loaded/activated by a (third-party) role?
Thanks!