# ERROR: tasks is not a legal parameter in an Ansible task or handler

**URL:** <https://forum.ansible.com/t/error-tasks-is-not-a-legal-parameter-in-an-ansible-task-or-handler/20150>\
**Category:** Ansible Project\
**Created:** [January 8, 2016, 7:40am UTC](https://forum.ansible.com/t/error-tasks-is-not-a-legal-parameter-in-an-ansible-task-or-handler/20150 "2016-01-08T07:40:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Afroz\_Hussain](https://avatars.discourse-cdn.com/v4/letter/a/e0b2c6/32.png) [@Afroz\_Hussain](https://forum.ansible.com/u/Afroz_Hussain)\
**Post date:** [January 8, 2016, 7:40am UTC](https://forum.ansible.com/t/error-tasks-is-not-a-legal-parameter-in-an-ansible-task-or-handler/20150/1 "2016-01-08T07:40:27Z")

</div>

Hello All,

I am getting “ERROR: tasks is not a legal parameter in an Ansible task or handler” while running play book with roles but the same code is running fine with plain yaml.

cat /etc/ansible/roles/webservers/tasks/main.yml

---

<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:** [January 8, 2016, 4:24pm UTC](https://forum.ansible.com/t/error-tasks-is-not-a-legal-parameter-in-an-ansible-task-or-handler/20150/2 "2016-01-08T16:24:07Z")

</div>

Hi,

you cannot have - hosts: , nor vars: in /etc/ansible/roles/webservers/tasks/main.yml, there is place only for tasks. Look into documentation: [http://docs.ansible.com/ansible/playbooks\_roles.html#task-include-files-and-encouraging-reuse](http://docs.ansible.com/ansible/playbooks_roles.html#task-include-files-and-encouraging-reuse)
