Fixed ansible Syntax Error while loading YAML.

If you encounter error like this:

$ ansible-playbook debug.yml --syntax-check
ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: No JSON object could be decoded

Syntax Error while loading YAML.

  mapping values are not allowed in this context


The error appears to be in '/home/ec2-user/ansible/debug.yml': line 8, column 14, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

    - name: This command will show ip
        shell:
             ^ here

It is likely an indentation error, Yaml is very strict about the indentations and the spacing.


You need to make sure that you have two spaces as indentation for the error of your playbook.

Comments