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

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

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