Open cla86 opened 11 months ago
I think this issue makes the ansible-lint GitHub action unusable if you are using any module outside Ansible core. There's no opportunity to run ansible-galaxy by hand between the installation and execution of ansible-lint, so you need to rely on its implicit processing of requirements.yml
to download any dependencies. Is the only workaround to bypass the action and install the dependencies and linter yourself?
I can confirm this happening in latest ansible-lint
version 24.6.0
too. Using ansible
version 2.17.0
.
Workaround is to run ansible-galaxy install -r requirements.yml
before running ansible-lint
.
I think this issue makes the ansible-lint GitHub action unusable if you are using any module outside Ansible core. There's no opportunity to run ansible-galaxy by hand between the installation and execution of ansible-lint, so you need to rely on its implicit processing of
requirements.yml
to download any dependencies. Is the only workaround to bypass the action and install the dependencies and linter yourself?
In Issue #3942 user veksh also showed an alternative solution for this when using the GitHub Action, which was to do as you suggested. Since @cla86 found that running it a second time works, I tested that in my GitHub workflow with success. Is it faster than writing a command to update packages, install pip, install Ansible, and then running the command? Probably, I didn't try to be honest, but this is working well for me now in my runners. We know that a second run will work, and all it takes is running ansible-lint
once to trigger it to download any required collections and roles. In order to make the first ansible-lint action go faster, I am passing an argument to only look at a single file. On the second pass it's running against the entire repository.
jobs:
build:
name: Ansible Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# This runs twice, once to install the collections and roles, because
# the current action is unable to resolve FQCN for modules on first pass
- name: Install required collections and roles
uses: ansible/ansible-lint@v24
with:
args: "collections/requirements.yml -v"
- name: Run ansible-lint
uses: ansible/ansible-lint@v24
with:
args: "-v"
Summary
ansible-lint doesn't make use of collection installed for the first time
Issue Type
OS / ENVIRONMENT
This is docker image setup for CI/CD pipeline based on docker.io/library/python:3.11.4-bullseye only with ansible-core and ansible-lint
STEPS TO REPRODUCE
Desired Behavior
ansible-lint should analyze ansible content upon installed collections.
Possible security bugs should be reported via email to
security@ansible.com
Actual Behavior
Running ansible-lint for the first time it installs collections from requirements.yml file, but doesn't make use of it producing warnings about not being able to resolve module from collections.
Running ansible-lint second time works as expected