Ansible lint component
Runs ansible-lint for an Ansible project or collection. The component searches from the configured path up to the repository root for ansible.cfg, local sibling collections, Python dependency files, and Ansible requirements.yml or requirements.yaml files. Ansible Galaxy dependencies are installed below .ansible/, which is cached between pipeline runs.
The component tests lint both a nested collection playbook and a project-root playbook that use a local collection role. Separate jobs exercise collection-level and project-level discovery.
Run Ansible lint before committing
Install pre-commit and Python 3.14, which the pinned hook requires. Then create .pre-commit-config.yaml in the repository root:
---
repos:
- repo: https://github.com/ansible/ansible-lint
rev: v26.9.0
hooks:
- id: ansible-lint
Install the Git hook and check the complete repository:
pre-commit install
pre-commit run --all-files
The hook exits with an error when ansible-lint reports a violation. Pin rev to the release used by your project and update it deliberately.
Inputs
| Name | Description | Default | Type |
| --- | --- | --- | --- |
| allow-failure | Should the pipeline continue if linting fails? | false | boolean |
| args | -v | string | |
| environment | The environment name for variables e.g. to unlock secrets. | int | string |
| image | The image to use for the job. | ${CI_TOOLS_REPO}/ansible-ee:${CI_TOOLS_COMPONENT_VERSION} | string |
| name | ansible | string | |
| needs | The jobs that this job depends on. | [] | array |
| path | Ansible project root | . | string |
| rules | The rules that this job depends on. | [{"if":"$CI_PIPELINE_SOURCE == \"schedule\"","when":"never"},{"if":"$CI_PIPELINE_SOURCE == \"merge_request_event\"","when":"always"},{"when":"always"}] | array |
| stage | The pipeline stage that the job will belong to. | lint | string |