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/offbecome booleans, and0644can become an octal-looking int. Quote file modes:mode: "0644". - A colon followed by a space inside a string needs quotes.
- Versions like
3.10parse as the float 3.1 unless quoted.
ansible-playbook --syntax-check and ansible-lint catch most of these before a run.
More on Fundamentals and Architecture
What is Ansible and what problem does it solve?BeginnerWhat does "agentless" mean in Ansible?BeginnerWhat are the requirements for the control node?BeginnerWhat does a managed node need?BeginnerIs Ansible push-based or pull-based?BeginnerWalk through what happens when you run `ansible-playbook site.yml`.Intermediate