How to do syntax check of yml or ansible playbook file ?

Lets see how to verify if our ansible YML playbook syntax is fine and has no errors in it.

To do this check we need to add “–syntax-check” option after the playbook run command.

1. Ansible YML Playbook Syntax Check

$ ansible-playbook playbooks/thirdplay.yml  --syntax-check

playbook: playbooks/thirdplay.yml

2. Check Result in case of an error

$ ansible-playbook playbooks/thirdplay.yml  --syntax-check
ERROR! Syntax Error while loading YAML.
  mapping values are not allowed here

The error appears to have been in '/Users/saket1447583/ansible/playbooks/thirdplay.yml': line 2, column 8, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

 - name: "Copying test.html file"
       ^ here
5 1 vote
Article Rating
1 Comment
Oldest Most Voted
Inline Feedbacks
View all comments
3 years ago


Very couple of websites that occur to become in depth beneath, from our point of view are undoubtedly well worth checking out.