Interview Prep/Ansible/YAML, Syntax and Jinja2 Errors

`did not find expected '-' indicator while parsing a block collection`

BeginnerTroubleshootingYAML, Syntax and Jinja2 Errors
Answer

Likely causes → Items in a list have mixed indentation, or a key line was inserted between list items at the wrong level:

tasks:
  - name: one
    ansible.builtin.ping:
   - name: two        # one space off

Diagnose → The error points to the line where the parser expected a -. Compare the column of every - in that list.

Fix → Line up all list items at the same column.

Prevent → Use 2-space indentation consistently, and run yamllint -d '{rules: {indentation: {spaces: 2}}}'.

All Ansible questions Roadmap: Ansible

More on YAML, Syntax and Jinja2 Errors