Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ansible lookup not found starting with pytest-ansible version 24.1.4 #403

Open
andy-maier opened this issue Nov 10, 2024 · 0 comments
Open

Comments

@andy-maier
Copy link

I am developing an Ansible lookup, and test that using pytest and pytest-ansible.

The pytest test function looks like this (simplified):

import pytest

@pytest.mark.ansible(host_pattern='localhost', connection='local')
def test_mylookup(ansible_module):
    expr = "lookup('myorg.mycoll.mylookup', 'someterm')"
    contacted = ansible_module.set_fact(result=f"{{{{ {expr} }}}}")
    contacted_host = contacted['localhost']
    assert 'failed' not in contacted_host
    result = contacted_host['ansible_facts']['result']
    # assertions on result

Up to pytest-ansible version 24.1.3, this worked fine.

Starting with pytest-ansible version 24.1.4, this fails because the lookup plugin is no longer found, and I get:

contacted_host={
    'failed': True,
    'msg': 'lookup plugin (ibm.zvpc.image_filename) not found',
    '_ansible_no_log': False
}

The lookup plugin is installed and available for Ansible. ansible-galaxy collection list shows the collection with the lookup plugin as installed in /Users/maiera/.ansible/collections/ansible_collections and I did verify that up to version 24.1.3, the code in that install directory gets control during the test. I have no ANSIBLE env vars set, and no ansible.cfg file. ansible-config dump reports:

COLLECTIONS_PATHS(default) = ['/Users/maiera/.ansible/collections', '/usr/share/ansible/collections']

So my collection is found by Ansible using this default configuration.

Pytest command line:

pytest --cov=myproject --cov-config .coveragerc --cov-append --cov-report=term-missing  -s --ansible-host-pattern localhost test

Why is the lookup no longer found starting with pytest-ansible version 24.1.4?
Is this something I can fix, or does this require a fix by pytest-ansible?

As a workaround, I am pinning pytest-ansible<=24.1.4 at the moment, to have my tests working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant