ansible / ansible-lint

ansible-lint checks playbooks for practices and behavior that could potentially be improved and can fix some of the most common ones for you
https://ansible.readthedocs.io/projects/lint/
GNU General Public License v3.0
3.47k stars 654 forks source link

Ansible-Lint Pre-Commit Hook - couldn't resolve module/action #4365

Closed Cust0mfirmware closed 1 week ago

Cust0mfirmware commented 1 week ago
Summary

If I try to commit something and the ansible-lint pre-commit hook is triggered, i am getting the following error message:

couldn't resolve module/action 'community.general.lxc_container'.

I have installed the community.general collection via ansible-galxy and if I execute ansible-lint manually, the module can be resolved.

Issue Type
OS / ENVIRONMENT
ansible-lint 6.17.2 using ansible-core:2.16.3 ansible-compat:4.1.11 ruamel-yaml:0.17.21 ruamel-yaml-clib:0.2.8
STEPS TO REPRODUCE
  1. Make a commit
  2. Pre-commit hook is triggered
  3. Ansible-lint is executed automatically
Desired Behavior

Module community.general.lxc_container should be resolved.

Actual Behavior

Error: couldn't resolve module/action 'community.general.lxc_container'.

Cust0mfirmware commented 1 week ago

Fixed by adding the following to the pre-commit config file:

# Uncomment if you need the full Ansible community bundle instead of ansible-core:
  additional_dependencies:
    - ansible

Source: https://ansible.readthedocs.io/projects/lint/configuring/#pre-commit-setup