Interview Prep/Ansible/YAML, Syntax and Jinja2 Errors

CI fails on ansible-lint with `yaml[truthy]`, `fqcn[action-core]`, `name[missing]` and `no-changed-when`

IntermediateTroubleshootingYAML, Syntax and Jinja2 Errors
Answer

Likely causes → The lint profile was raised (for example to production), or ansible-lint was upgraded and added rules.

Diagnose →

ansible-lint --version
ansible-lint -p        # parseable output, one violation per line

Fix →

  • yaml[truthy]: use true/false instead of yes/no.
  • fqcn[action-core]: write ansible.builtin.copy instead of copy.
  • name[missing]: give every task a name.
  • no-changed-when: add changed_when to command and shell tasks.

For a large legacy codebase, run ansible-lint --fix first, then review the diff.

Prevent → Pin the ansible-lint version in requirements-dev.txt, and set the profile in .ansible-lint. Use --generate-ignore to accept the existing violations and stop new ones.

All Ansible questions Roadmap: Ansible

More on YAML, Syntax and Jinja2 Errors