ACloudGuru-Resources / Course_Introduction_to_Ansible

Learn how to setup, develop, and utilize ansible automation.
MIT License
129 stars 442 forks source link

syntax error #1

Closed krunalcc1 closed 4 years ago

krunalcc1 commented 5 years ago

getting error while running this script.

uname.yml


ansible-playbook uname.yml ERROR! Syntax Error while loading YAML. mapping values are not allowed here

The error appears to have been in '/home/XYZ/.ansible/uname.yml': line 7, column 13, but may be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  -name: Get OS type
   shell: uname
        ^ here
brocktubre commented 5 years ago

Hi @krunalcc1, the issue is happening because of the YAML syntax. Below is the formatting that the uname.yml file should have. As you can see the tabbing is a bit different than what you posted in the comment.

  - hosts: webservers:loadbalancers
    tasks:
      - name: Get OS type
        shell: uname

And this is what you have, which will throw a syntax error:

hosts: webservers:loadbalancers
tasks:
-name: Get OS type
shell: uname

I went ahead and added an .editorconfig file to the repository so the end users text editor knows how to format the YAML code. Please let me know if you are still having issues?

Good luck!

brocktubre commented 4 years ago

Closing issue due to longevity of issue.