Most of the articles from Ansible says it’s very simple to write and play an playbook. But i tried to write an simple playbooks and run it’s shows me an syntax error what..!! All the playbook is well written and nothing wrong in it. But you know i missed out an alignment it’s failed to execute. Let’s see HowTo Write Ansible Playbook for the first Time Guide.
HowTo Write Ansible Playbook
ansible playbook writing
If you see at above playbook alignment is exactly correct and when i execute it it runs perfect
executed playbook successfully
Let’s see the same playbook without proper alignment it shows an syntax error
Yaml syntax error while loading
shown above is the same playbook as we executed previously, what changed is only i have added few spaces in hosts and tasks lines and it failed to execute.
Do remember to write the playbook with right alignment or else you will end up with YAML syntax errors
A few rules you need to follow is, when you want include : (colon) in statement you have to enable quotations (” “) from start to end shown example is below
-name: Incorrect: Method: to Write
- name: "Testing: Production and UAT"
you can still write paths as like
to tell you further on writing ansible variables and there examples