# Running a simple playbook

**URL:** <https://forum.ansible.com/t/running-a-simple-playbook/11757>\
**Category:** Ansible Project\
**Created:** [August 3, 2012, 2:34pm UTC](https://forum.ansible.com/t/running-a-simple-playbook/11757 "2012-08-03T14:34:11Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![James8](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@James8](https://forum.ansible.com/u/James8)\
**Post date:** [August 3, 2012, 2:34pm UTC](https://forum.ansible.com/t/running-a-simple-playbook/11757/1 "2012-08-03T14:34:11Z")

</div>

I'm running my first playbook:

- hosts: CL400  
&nbsp;&nbsp;user: jmarcus  
&nbsp;&nbsp;sudo: True

- name: no iptables  
&nbsp;&nbsp;action: service name=iptables state=stopped

ERROR: action is not a legal parameter in an Ansible Playbook

if the service stat was already stopped would I get this message? Or  
is this really related to "action"

Thanks,  
James

---

<div class="post-metadata">

**Author:** ![Lorin\_Hochstein1](https://avatars.discourse-cdn.com/v4/letter/l/ce73a5/32.png) [@Lorin\_Hochstein1](https://forum.ansible.com/u/Lorin_Hochstein1)\
**Post date:** [August 3, 2012, 2:39pm UTC](https://forum.ansible.com/t/running-a-simple-playbook/11757/2 "2012-08-03T14:39:16Z")

</div>

James:

You’re missing “tasks:”. Try this:

- hosts: CL400  
user: jmarcus  
sudo: True

tasks:

- name: no iptables  
action: service name=iptables state=stopped

Take care,

Lorin

---

<div class="post-metadata">

**Author:** ![James8](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@James8](https://forum.ansible.com/u/James8)\
**Post date:** [August 3, 2012, 2:44pm UTC](https://forum.ansible.com/t/running-a-simple-playbook/11757/3 "2012-08-03T14:44:16Z")

</div>

Thanks, that gets me a little further, but I get: ERROR: hosts  
declaration is required

Do I need hosts after tasks?

- hosts: CL400  
&nbsp;&nbsp;user: jmarcus  
&nbsp;&nbsp;sudo: True

- tasks:

- name: no nfslock  
&nbsp;&nbsp;action: service name=nfslock state=stopped enabled=no

Thanks,  
James

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [August 3, 2012, 2:48pm UTC](https://forum.ansible.com/t/running-a-simple-playbook/11757/4 "2012-08-03T14:48:35Z")

</div>

Absolutely.

Please see the examples directory in the git checkout.

examples/playbooks/\*

all of these are valid playbook syntax.

---

<div class="post-metadata">

**Author:** ![Lorin\_Hochstein1](https://avatars.discourse-cdn.com/v4/letter/l/ce73a5/32.png) [@Lorin\_Hochstein1](https://forum.ansible.com/u/Lorin_Hochstein1)\
**Post date:** [August 3, 2012, 2:49pm UTC](https://forum.ansible.com/t/running-a-simple-playbook/11757/5 "2012-08-03T14:49:04Z")

</div>

James:

You do, indeed, need to specify hosts. Also, don’t put the “-” before tasks.

Take care,

Lorin

---

<div class="post-metadata">

**Author:** ![James8](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@James8](https://forum.ansible.com/u/James8)\
**Post date:** [August 3, 2012, 3:24pm UTC](https://forum.ansible.com/t/running-a-simple-playbook/11757/6 "2012-08-03T15:24:43Z")

</div>

Ok thats what I don't understand, I feel like I have read most of  
these examples. Who do I get the hosts message?  
Isn't my first line legitimate?

- hosts: CL400  
&nbsp;&nbsp;user: jmarcus  
&nbsp;&nbsp;sudo: True

&nbsp;&nbsp;tasks:

- name: no nfslock  
&nbsp;&nbsp;action: service name=nfslock state=stopped enabled=no

---

<div class="post-metadata">

**Author:** ![James8](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@James8](https://forum.ansible.com/u/James8)\
**Post date:** [August 3, 2012, 3:26pm UTC](https://forum.ansible.com/t/running-a-simple-playbook/11757/7 "2012-08-03T15:26:15Z")

</div>

and when I try to run with out - tasks it fails with:

expected \<block end\>, but found '?'  
&nbsp;&nbsp;in "\<string\>", line 18, column 1:  
&nbsp;&nbsp;&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;^

---

<div class="post-metadata">

**Author:** ![Lorin\_Hochstein1](https://avatars.discourse-cdn.com/v4/letter/l/ce73a5/32.png) [@Lorin\_Hochstein1](https://forum.ansible.com/u/Lorin_Hochstein1)\
**Post date:** [August 3, 2012, 3:41pm UTC](https://forum.ansible.com/t/running-a-simple-playbook/11757/8 "2012-08-03T15:41:41Z")

</div>

James:

I think you’re running into whitespace problems. YAML files are sensitive to indentation. Try doing a copy-paste of this:

- hosts: CL400  
user: jmarcus  
sudo: True

tasks:

- name: no nfslock  
action: service name=nfslock state=stopped enabled=no

Take care,

Lorin

---

<div class="post-metadata">

**Author:** ![James8](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@James8](https://forum.ansible.com/u/James8)\
**Post date:** [August 5, 2012, 7:12pm UTC](https://forum.ansible.com/t/running-a-simple-playbook/11757/9 "2012-08-05T19:12:35Z")

</div>

Thanks Lorin this worked!

James

---

<div class="post-metadata">

**Author:** ![max2](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@max2](https://forum.ansible.com/u/max2)\
**Post date:** [August 21, 2013, 11:49am UTC](https://forum.ansible.com/t/running-a-simple-playbook/11757/10 "2013-08-21T11:49:19Z")

</div>

Hello everyone,

we have use cloudformation to create a stack in aws. We are now trying to figure out how to get the actual edx platform code to deploy and run on those newly configured servers. We have figured out we have to run main.yml in playbooks/roles/edxapp/tasks/ to have the code deploy on the servers, but we get:

**_ERROR: file is not a legal parameter in an Ansible Playbook_**

when running the command: **_ansible-playbook -vvv ~/repos/edx-configuration/playbooks/roles/edxapp/tasks/main.yml -e ‘region=eu-west-1 key=edX name=edx-configuration’_**

Any advice would be extremely appreciated!!

Thanks to all

---

<div class="post-metadata">

**Author:** ![Patrick\_Regan](https://avatars.discourse-cdn.com/v4/letter/p/7cd45c/32.png) [@Patrick\_Regan](https://forum.ansible.com/u/Patrick_Regan)\
**Post date:** [August 21, 2013, 12:15pm UTC](https://forum.ansible.com/t/running-a-simple-playbook/11757/11 "2013-08-21T12:15:59Z")

</div>

> Hello everyone,
> 
> we have use cloudformation to create a stack in aws. We are now trying to  
> figure out how to get the actual edx platform code to deploy and run on  
> those newly configured servers. We have figured out we have to run main.yml  
> in playbooks/roles/edxapp/tasks/ to have the code deploy on the servers,  
> but we get:
> 
> \*ERROR: file is not a legal parameter in an Ansible Playbook\*
> 
> when running the command: \* \*\*ansible-playbook -vvv  
> ~/repos/edx-configuration/playbooks/roles/edxapp/tasks/main.yml -e  
> 'region=eu-west-1 key=edX name=edx-configuration'\*

I'm assuming you're using the main.yml from this :  
[https://github.com/edx/configuration/blob/master/playbooks/roles/edxapp/tasks/main.yml](https://github.com/edx/configuration/blob/master/playbooks/roles/edxapp/tasks/main.yml)

What's happening here is that you're attempting to run a role as a full  
playbook, but that's not exactly how it works. The tasks in roles are not  
full plays, but rather a list of actions. The reason you're getting the  
error about "file" is because Ansible doesn't know you're attempting to run  
tasks yet.

What you can do instead is build a play that uses the role.  
[http://www.ansibleworks.com/docs/playbooks.html#roles](http://www.ansibleworks.com/docs/playbooks.html#roles) By just creating a  
wrapper play, you should be able to get around this error.
