# Ansible error : ERROR! The tasks/main.yml file for role 'xyz' must contain a list of tasks

**URL:** <https://forum.ansible.com/t/ansible-error-error-the-tasks-main-yml-file-for-role-xyz-must-contain-a-list-of-tasks/27252>\
**Category:** Ansible Project\
**Created:** [April 11, 2018, 8:01pm UTC](https://forum.ansible.com/t/ansible-error-error-the-tasks-main-yml-file-for-role-xyz-must-contain-a-list-of-tasks/27252 "2018-04-11T20:01:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Irfan\_Sayed](https://avatars.discourse-cdn.com/v4/letter/i/a4c791/32.png) [@Irfan\_Sayed](https://forum.ansible.com/u/Irfan_Sayed)\
**Post date:** [April 11, 2018, 8:01pm UTC](https://forum.ansible.com/t/ansible-error-error-the-tasks-main-yml-file-for-role-xyz-must-contain-a-list-of-tasks/27252/1 "2018-04-11T20:01:30Z")

</div>

Hello,  
i have following simple YAML play file

```auto
 ---
 tasks:
 - name: Execute the command in remote shell; stdout goes to the specified file on the remote.
   shell: echo hi

```

but when running ansible-playbook command: getting following error

> ERROR! The tasks/main.yml file for role ‘xyz’ must contain a list of tasks
> 
> The error appears to have been in ‘/home/cdkubemaster1/plabook\_structure/roles/xyz/tasks/main.yml’: line 2, column 1, but may  
> be elsewhere in the file depending on the exact syntax problem.
> 
> The offending line appears to be:
> 
> * * *
> 
> tasks:  
> ^ here
> 
> exception type: \<type ‘exceptions.AssertionError’\>  
> exception: {u’tasks’: [{u’shell’: u’echo hi’, u’name’: u’Execute the command in remote shell; stdout goes to the specified file on the remote.'}]} should be a list or None but is \<class ‘ansible.parsing.yaml.objects.AnsibleMapping’\>

what is expected:  
All the tasks mentioned in the playbook should be executed …  
i have here just one tasks , but the error says , need to have all the list of tasks …  
Not getting what is mean to that ?  
please suggest

Regards,

---

<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:** [April 11, 2018, 9:56pm UTC](https://forum.ansible.com/t/ansible-error-error-the-tasks-main-yml-file-for-role-xyz-must-contain-a-list-of-tasks/27252/2 "2018-04-11T21:56:30Z")

</div>

`tasks:` should only appear in a play, not a tasks list for a role,  
remove it and it should work.

---

<div class="post-metadata">

**Author:** ![Irfan\_Sayed](https://avatars.discourse-cdn.com/v4/letter/i/a4c791/32.png) [@Irfan\_Sayed](https://forum.ansible.com/u/Irfan_Sayed)\
**Post date:** [April 12, 2018, 10:46am UTC](https://forum.ansible.com/t/ansible-error-error-the-tasks-main-yml-file-for-role-xyz-must-contain-a-list-of-tasks/27252/3 "2018-04-12T10:46:54Z")

</div>

Thanks. Got it 🙂
