# syntax error while loading yaml script

**URL:** <https://forum.ansible.com/t/syntax-error-while-loading-yaml-script/19437>\
**Category:** Ansible Project\
**Created:** [October 5, 2015, 8:29am UTC](https://forum.ansible.com/t/syntax-error-while-loading-yaml-script/19437 "2015-10-05T08:29:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ansible\_novice1](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@ansible\_novice1](https://forum.ansible.com/u/ansible_novice1)\
**Post date:** [October 5, 2015, 8:29am UTC](https://forum.ansible.com/t/syntax-error-while-loading-yaml-script/19437/1 "2015-10-05T08:29:04Z")

</div>

I`m trying to launch one playbook:

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [October 5, 2015, 12:09pm UTC](https://forum.ansible.com/t/syntax-error-while-loading-yaml-script/19437/2 "2015-10-05T12:09:45Z")

</div>

it should look like this

tasks:  
- name: ensure update  
&nbsp;&nbsp;&nbsp;apt:update\_cache=yes  
- apt:upgrade=full

You cannot have multiple tasks per task, name is optional but - is not  
as it indicates when the 'next task' starts

---

<div class="post-metadata">

**Author:** ![ansible\_novice1](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@ansible\_novice1](https://forum.ansible.com/u/ansible_novice1)\
**Post date:** [October 6, 2015, 7:33am UTC](https://forum.ansible.com/t/syntax-error-while-loading-yaml-script/19437/3 "2015-10-06T07:33:23Z")

</div>

Ok, now I have another code in playbook

---

<div class="post-metadata">

**Author:** ![David\_Karban](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@David\_Karban](https://forum.ansible.com/u/David_Karban)\
**Post date:** [October 6, 2015, 7:41am UTC](https://forum.ansible.com/t/syntax-error-while-loading-yaml-script/19437/4 "2015-10-06T07:41:54Z")

</div>

Hi,

tasks should have more spaces, it should be aligned to user, sudo, etc. keywords:

---

<div class="post-metadata">

**Author:** ![pixel\_fairy](https://avatars.discourse-cdn.com/v4/letter/p/6f9a4e/32.png) [@pixel\_fairy](https://forum.ansible.com/u/pixel_fairy)\
**Post date:** [October 6, 2015, 11:37am UTC](https://forum.ansible.com/t/syntax-error-while-loading-yaml-script/19437/5 "2015-10-06T11:37:29Z")

</div>

theres an intro to yaml syntax here. [http://docs.ansible.com/ansible/YAMLSyntax.html](http://docs.ansible.com/ansible/YAMLSyntax.html)

be carefull cutting and pasting from groups because things can get reformatted. heres an example with the code highlighting. i hope it comes out ok. also, you can put multiple variables in a single module call like this.

`

---

<div class="post-metadata">

**Author:** ![ansible\_novice1](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@ansible\_novice1](https://forum.ansible.com/u/ansible_novice1)\
**Post date:** [October 6, 2015, 12:40pm UTC](https://forum.ansible.com/t/syntax-error-while-loading-yaml-script/19437/6 "2015-10-06T12:40:34Z")

</div>

I`m trying to run your example, but I have a message of error again. Now this is another position. I thougth there could be a problem with spaces, but changes doesn`t work too.

ERROR: Syntax Error while loading YAML script, test1.yml  
Note: The error may actually appear before this position: line 10, column 1  
apt:update\_cache=yes upgrade=full cache\_valid\_time=3600

^

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [October 6, 2015, 12:42pm UTC](https://forum.ansible.com/t/syntax-error-while-loading-yaml-script/19437/7 "2015-10-06T12:42:06Z")

</div>

you need a space after :

apt: update\_cache=yes upgrade=full cache\_valid\_time=3600

---

<div class="post-metadata">

**Author:** ![ansible\_novice1](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@ansible\_novice1](https://forum.ansible.com/u/ansible_novice1)\
**Post date:** [October 7, 2015, 7:47am UTC](https://forum.ansible.com/t/syntax-error-while-loading-yaml-script/19437/8 "2015-10-07T07:47:32Z")

</div>

Thank you. Now playbook doesn`t have syntax errors, but I have a permission error.

`

PLAY [group1] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
\<172.17.251.236\> ESTABLISH CONNECTION FOR USER: user1  
\<172.17.251.236\> REMOTE\_MODULE setup  
\<172.17.251.236\> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=“/root/.ansible/cp/ansible-ssh-%h-%p-%r” -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=user1 -o ConnectTimeout=10 172.17.251.236 /bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1444203780.43-167481022998325 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1444203780.43-167481022998325 && echo $HOME/.ansible/tmp/ansible-tmp-1444203780.43-167481022998325’  
fatal: [172.17.251.236] =\> SSH Error: Permission denied (publickey,password).  
while connecting to 172.17.251.236:22  
It is sometimes useful to re-run the command using -vvvv, which prints SSH debug output to help diagnose the issue.

TASK: [ensure update] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
FATAL: no hosts matched or all hosts have already failed – aborting

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
to retry, use: --limit @/root/test1.retry

172.17.251.236 : ok=0 changed=0 unreachable=1 failed=0

`

I guess there might ba problem with SSH key and I have to make it and save in directory /root/.ansible/cp/. But SSH agent can`t open a connection to my authentication agent. Do you know, where does the trouble lie?
