ansible-lint violations (exit code 2) blocking CI
ansible-lint found one or more rule violations and exited non-zero (code 2 for matched rules), which fails the CI step. The output names each rule, file, and line so you can fix or explicitly skip it.
What this error means
The lint step fails with a list of findings like "fqcn[action-core]" or "risky-file-permissions" and "Failed: N failure(s)", and the job exits 2.
site.yml:7: fqcn[action-core]: Use FQCN for builtin module actions (apt).
Failed: 1 failure(s), 0 warning(s) on 1 files. Last profile that met the validation: minCommon causes
Real rule violations in the playbook
Findings such as missing FQCN, risky permissions, or a missing task name are genuine issues the linter is flagging.
A stricter profile than the code targets
The configured profile (for example production) enforces rules the repo has not adopted yet, so existing files fail.
How to fix it
Fix the reported rules
- Read each
rule[id]and the file/line it names. - Apply the fix (use FQCNs, add task names, tighten modes).
- Re-run
ansible-lintuntil it exits zero.
ansible-lint site.ymlConfigure the profile and explicit skips
Pin the profile you intend to meet and skip only rules you have consciously accepted, so the gate is honest.
# .ansible-lint
profile: moderate
skip_list:
- risky-file-permissionsHow to prevent it
- Run ansible-lint locally and in pre-commit before pushing.
- Adopt a profile and raise it incrementally as the repo improves.
- Skip rules explicitly in
.ansible-lint, not by ignoring exit codes.