# NOOB needs help with small ansible script.

**URL:** <https://forum.ansible.com/t/noob-needs-help-with-small-ansible-script/24282>\
**Category:** Ansible Project\
**Created:** [April 21, 2017, 1:35pm UTC](https://forum.ansible.com/t/noob-needs-help-with-small-ansible-script/24282 "2017-04-21T13:35:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raymond\_Nonya](https://avatars.discourse-cdn.com/v4/letter/r/b9e5f3/32.png) [@Raymond\_Nonya](https://forum.ansible.com/u/Raymond_Nonya)\
**Post date:** [April 21, 2017, 1:35pm UTC](https://forum.ansible.com/t/noob-needs-help-with-small-ansible-script/24282/1 "2017-04-21T13:35:15Z")

</div>

I am two days now into ansible and I love everything it can do. My problem is that ansible does not like my yaml :-). My below playbook keeps throwing errors when I run a --check on it. Basically I want the update rpm pulled down and put in /tmp. Then I want to check if a user account exists. If not I want it to stop and inform me that the user doesn’t exist. I looked at the fail instructions and I followed it but I guess I am missing something. Thank you in advanced for your help.

**error**

**The offending line appears to be:**

**- fail:**  
**msg: “User Splunk does not exist, stopping install”**  
**^ here**

playbook

- name: install splunk forwarder Binaries  
hosts: all  
gather\_facts: True

tasks:

- name: download splunk forwarder RPM  
get\_url:  
url: [http://server/RPM/update-6.5.3-36937ad027d4-linux-2.6-x86\_64.rpm](http://server/RPM/update-6.5.3-36937ad027d4-linux-2.6-x86_64.rpm)  
dest: /tmp/update-6.5.3-36937ad027d4-linux-2.6-x86\_64.rpm  
mode: 777

action: shell /usr/bin/getent passwd nix| /usr/bin/wc -l | tr -d ‘’  
register: user\_exist

# when: user\_exist.stdout == 0

- fail:  
msg: “User nix does not exist, stopping install”  
when: user\_exist.stdout == 0

---

<div class="post-metadata">

**Author:** ![Paul\_Markham](https://avatars.discourse-cdn.com/v4/letter/p/9d8465/32.png) [@Paul\_Markham](https://forum.ansible.com/u/Paul_Markham)\
**Post date:** [April 24, 2017, 12:48am UTC](https://forum.ansible.com/t/noob-needs-help-with-small-ansible-script/24282/2 "2017-04-24T00:48:07Z")

</div>

Try indenting the msg line. YAML is very fussy about spacing and indentation.

---

<div class="post-metadata">

**Author:** ![Raymond\_Nonya](https://avatars.discourse-cdn.com/v4/letter/r/b9e5f3/32.png) [@Raymond\_Nonya](https://forum.ansible.com/u/Raymond_Nonya)\
**Post date:** [April 26, 2017, 7:55pm UTC](https://forum.ansible.com/t/noob-needs-help-with-small-ansible-script/24282/3 "2017-04-26T19:55:53Z")

</div>

Still having issues. I completely started over and no luck. Ansible still complains, it is complaining about action and every time I change something it complains about another stanza.  
Here is the error

ansible-playbook TEST -i hosts -C  
ERROR! Syntax Error while loading YAML.

The error appears to have been in ‘/root/SPLUNK/TEST’: line 5, column 10, but may  
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- name: Installs splunk  
action: shell wget -O /tmp/splunk.rpm [http://example.com/file](http://example.com/file)  
^ here

Here is my YAML playbook

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [May 1, 2017, 6:46pm UTC](https://forum.ansible.com/t/noob-needs-help-with-small-ansible-script/24282/4 "2017-05-01T18:46:36Z")

</div>

You have problem with indentation, I do recommend reading the docs, start with this one,  
[https://docs.ansible.com/ansible/YAMLSyntax.html](https://docs.ansible.com/ansible/YAMLSyntax.html)

And then read this one,  
[https://docs.ansible.com/ansible/playbooks\_intro.html](https://docs.ansible.com/ansible/playbooks_intro.html)

Do look at the indentation that is 2 spaces in the examples.  
In YAML, indentation is is essential.

---

<div class="post-metadata">

**Author:** ![Paul\_Markham](https://avatars.discourse-cdn.com/v4/letter/p/9d8465/32.png) [@Paul\_Markham](https://forum.ansible.com/u/Paul_Markham)\
**Post date:** [May 3, 2017, 12:31am UTC](https://forum.ansible.com/t/noob-needs-help-with-small-ansible-script/24282/5 "2017-05-03T00:31:25Z")

</div>

Your indentation is still all over the place. Try:

`
