Skip to content

Unable to load module / resolve FQCN for module on initial run of ansible-lint #4398

Open
@dbrennand

Description

Summary

Invoking ansible-lint 24.9.2 on my example collection, ansible-lint shows warnings about being unable to load module and resolve FQCN for a dependent collection module:

In this example, it's community.general.pip_package_info:

INFO     Set ANSIBLE_LIBRARY=/Users/dab/.cache/ansible-compat/0cb87f/modules:/Users/dab/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Set ANSIBLE_ROLES_PATH=/Users/dab/.cache/ansible-compat/0cb87f/roles:roles:/Users/dab/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
INFO     Provisioning collection community.general:10.0.1 from galaxy.yml
INFO     Running from /Users/dab/repos/repro/ansible : ansible-galaxy collection install -vvv community.general:10.0.1
INFO     Running from /Users/dab/repos/repro/ansible : ansible-galaxy collection install -vvv --force /Users/dab/repos/repro/ansible
WARNING  Unable to load module community.general.pip_package_info at roles/example/tasks/main.yml:3 for options validation
WARNING  Unable to resolve FQCN for module community.general.pip_package_info

The dependent collection is successfully installed to the ansible-compat cache during the initial run:

❯ ls -lah /Users/dab/.cache/ansible-compat/0cb87f/collections/ansible_collections 
Permissions Size User Date Modified Name
drwxr-xr-x     - dab  11 Nov 21:21  community
drwxr-xr-x     - dab  11 Nov 21:21  community.general-10.0.1.info
drwxr-xr-x     - dab  11 Nov 21:21  dbrennand

This only happends on the first run of ansible-lint, once the ~/.cache/ansible-compat/ is established, the warning disappears. This is not ideal when running ansible-lint in one-shot scenarios such as a CI/CD pipeline.

Issue Type
  • Bug Report
OS / ENVIRONMENT
ansible-lint 24.9.2 using ansible-core:2.18.0 ansible-compat:24.9.1 ruamel-yaml:0.18.6 ruamel-yaml-clib:0.2.12
  • ansible installation method: pip
  • ansible-lint installation method: pip
STEPS TO REPRODUCE
git clone [email protected]:dbrennand/repro.git
cd repro
mkdir -pv ~/.virtualenvs/
python -m venv ~/.virtualenvs/repro
source ~/.virtualenvs/repro/bin/activate
pip install -r requirements.txt
cd ansible/
ansible-lint -v
# Observe WARNINGs
Desired Behavior

No warnings are shown and the module and FQCN are resolved.

Actual Behavior

Minimal repro example:

❯ ansible-lint -v
INFO     Identified /Users/dab/repos/repro as project root due .git directory.
INFO     Set ANSIBLE_LIBRARY=/Users/dab/.cache/ansible-compat/0cb87f/modules:/Users/dab/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Set ANSIBLE_ROLES_PATH=/Users/dab/.cache/ansible-compat/0cb87f/roles:roles:/Users/dab/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
INFO     Provisioning collection community.general:10.0.1 from galaxy.yml
INFO     Running from /Users/dab/repos/repro/ansible : ansible-galaxy collection install -vvv community.general:10.0.1
INFO     Running from /Users/dab/repos/repro/ansible : ansible-galaxy collection install -vvv --force /Users/dab/repos/repro/ansible
INFO     Executing syntax check on playbook roles/example/tests/test.yml (0.24s)
INFO     Executing syntax check on role roles/example (0.24s)
...
WARNING  Unable to load module community.general.pip_package_info at roles/example/tasks/main.yml:3 for options validation
WARNING  Unable to resolve FQCN for module community.general.pip_package_info

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions