Interview Prep/Ansible/Fundamentals and Architecture

What are the common YAML pitfalls when writing playbooks?

IntermediateConceptFundamentals and Architecture
Answer
  • Indentation uses spaces only; tabs are a syntax error.
  • A value starting with {{ must be quoted: msg: "{{ var }}", otherwise YAML reads it as a dict.
  • Unquoted yes/no/on/off become booleans, and 0644 can become an octal-looking int. Quote file modes: mode: "0644".
  • A colon followed by a space inside a string needs quotes.
  • Versions like 3.10 parse as the float 3.1 unless quoted.

ansible-playbook --syntax-check and ansible-lint catch most of these before a run.

All Ansible questions Roadmap: Ansible

More on Fundamentals and Architecture