--check (check mode) and --diff to preview changes without applying them — those help verify what changes would happen. Ansible-lint complements that by verifying how the playbooks are written, helping keep them readable, consistent, and maintainable as projects grow.

- Scans playbooks, roles, and collections for common mistakes and style inconsistencies.
- Reports rule violations with file and line numbers, plus an identifying tag (e.g.
name[casing]) so you know what to fix. - Can be run locally, in pre-commit hooks, or as part of CI pipelines to enforce standards automatically.

style-example.yml that installs and configures NGINX but intentionally includes a few style problems:
- Inconsistent indentation (some tasks use two spaces, one uses four).
- Inconsistent or missing task
namefields (mixed case and some unnamed tasks). - Using the
shellmodule wherecommandor a dedicated module would be safer and faster.
name[casing]), and the output points to the offending line. Common rules you’ll see include task naming rules, YAML indentation issues, and warnings about unnecessary shell usage — when shell features (like pipes or expansions) aren’t required, prefer command or a specialised module.

- If ansible-lint prints nothing and exits with code 0, it found no issues:
- Non-zero exit codes indicate one or more linting failures — useful for failing CI jobs or blocking merges when used in automation.
Integrating ansible-lint into your workflow
- Run it locally during development to catch issues early.
- Add it to pre-commit hooks so every commit is checked automatically.
- Include it in CI pipelines so pull requests are validated before merging.
Integrate ansible-lint into pre-commit hooks or CI jobs so lint failures block merges until issues are resolved. This enforces consistent style and prevents regressions across the team.
- Prevents style and correctness regressions in large automation codebases.
- Saves time by turning ad-hoc reviews into automated checks.
- Improves maintainability and readability of playbooks, roles, and collections.

- Official docs: https://ansible-lint.readthedocs.io/
- Ansible best practices: https://docs.ansible.com/
- Pre-commit: https://pre-commit.com/