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

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

Open
dbrennand opened this issue Nov 11, 2024 · 2 comments
Labels

Comments

@dbrennand
Copy link
Contributor

dbrennand commented Nov 11, 2024

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 git@github.com: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
@ssbarnea
Copy link
Member

#4402 is likely to fix that. Either update ansible-compat manually and test again or wait till we make the next linter release and check if this is sorted.

@dbrennand
Copy link
Contributor Author

dbrennand commented Nov 15, 2024

Hi @ssbarnea - Tested the latest ansible-lint release - unfortunately, I'm still seeing this issue.

# Ensure ansible-compat cache is clear
rm -rf ~/.cache/ansible-compat/
❯ cat requirements.txt 
ansible-core==2.18.0
ansible-lint==24.10.0
❯ pip install -r requirements.txt
❯ pip list | grep -E 'ansible-lint|ansible-compat'
ansible-compat            24.10.0
ansible-lint              24.10.0
❯ cd ansible
❯ ansible-lint -v
INFO     Identified /Users/dab/repos/repro as project root due .git directory.
WARNING  <unknown>:1: SyntaxWarning: invalid decimal literal

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  Ignored exception from CheckRequiresAnsibleVersion.matchyaml while processing meta/runtime.yml (meta-runtime): 'NoneType' object has no attribute 'get'
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

Please let me know how I can assist further with troubleshooting this.

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

No branches or pull requests

3 participants