Skip to content
Latchkey

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.

ansible
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: min

Common 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

  1. Read each rule[id] and the file/line it names.
  2. Apply the fix (use FQCNs, add task names, tighten modes).
  3. Re-run ansible-lint until it exits zero.
Terminal
ansible-lint site.yml

Configure 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
# .ansible-lint
profile: moderate
skip_list:
  - risky-file-permissions

How 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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →