# Simple YAMl File syntax errors

**URL:** <https://forum.ansible.com/t/simple-yaml-file-syntax-errors/26579>\
**Category:** Ansible Project\
**Created:** [January 28, 2018, 9:39am UTC](https://forum.ansible.com/t/simple-yaml-file-syntax-errors/26579 "2018-01-28T09:39:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mallireddy\_Gangadhar](https://avatars.discourse-cdn.com/v4/letter/m/a587f6/32.png) [@Mallireddy\_Gangadhar](https://forum.ansible.com/u/Mallireddy_Gangadhar)\
**Post date:** [January 28, 2018, 9:39am UTC](https://forum.ansible.com/t/simple-yaml-file-syntax-errors/26579/1 "2018-01-28T09:39:22Z")

</div>

Hi ,

I have written a simple yaml file to install httpd package

---

<div class="post-metadata">

**Author:** ![dch](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dch/32/7132_2.png) [@dch](https://forum.ansible.com/u/dch)\
**Post date:** [January 28, 2018, 10:19am UTC](https://forum.ansible.com/t/simple-yaml-file-syntax-errors/26579/2 "2018-01-28T10:19:11Z")

</div>

Welcome Mallireddy.

Your yaml file is a \_role\_ and the playbook command requires a \_playbook\_ as well as an inventory file. You just need to add a playbook (lets call that site.yml) and include your role from above (web.yml).

I tweaked your role a little (use separate lines so that git diffs are easy to read, add a name for readability during playbook runs, and tags to allow targeting tasks easily) but its basically the same as what you already have. I keep all of this together in a single git repo, along with ansible.cfg and hosts inventory file.

Your ansible structure should look like this inside your ansible repo:

```auto
# ./site.yml:
---
- hosts: all
  roles:
    - web

# ./roles/web/tasks/main.yml:
--- 
- name: ensure web server is installed
  yum:
    name: httpd
    state: installed
  tags:
    - web
    - yum

```

I use the following a lot - what would the play change, and then actually apply it:

ansible-playbook site.yml --diff -v --check  
ansible-playbook site.yml --diff -v

[https://github.com/ansible/ansible-examples/tree/master/lamp\_simple](https://github.com/ansible/ansible-examples/tree/master/lamp_simple) is a nice simple example pretty close to what you are using - enjoy.

A+  
Dave

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [February 6, 2018, 3:28am UTC](https://forum.ansible.com/t/simple-yaml-file-syntax-errors/26579/3 "2018-02-06T03:28:43Z")

</div>

Boht plays are tasks are lists, you are passing a dictionaries, just  
need 1 character to 'fix it'

- hosts: all  
&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;- yum: "name=httpd state=installed"

^ see the dashes?

That is what 'playbook must be a list of plays' means, if you only fix  
- hosts, next would be 'tasks needs to be a list of tasks'.

Your file is still valid YAML, it just does not return the data types  
Ansible expects for plays and tasks.
