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

David Karban
Linux server specialist/Specialista na správu linuxových serverů
www.karban.eu

2016-01-08 8:40 GMT+01:00 Afroz Hussain <[email protected]>:

> 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
> ---
> - hosts: local
>   vars:
>     http_port: 80
>     max_clients: 200
>   remote_user: root
>   tasks:
>   - name: ensure apache is at the latest version
>     yum: pkg=httpd state=latest
>   - name: write the apache config file
>     template: src=/etc/ansible/roles/webservers/templates/httpd.j2
> dest=/etc/httpd/conf/httpd.conf
>     notify:
>     - restart apache
>   - name: ensure apache is running (and enable it at boot)
>     service: name=httpd state=started enabled=yes
>
> cat /etc/ansible/roles/webservers/handlers/main.yml
> ---
> - name: restart apache
>   service: name=httpd state=restarted
>
> cat /etc/ansible/site.yml
> ---
> - hosts: local
>   roles:
>      - role: webservers
> #     - webservers
>
> ansible]# ansible-playbook site.yml
> ERROR: tasks is not a legal parameter in an Ansible task or handler
>
>
> Any help will be appreciated.
>
> Thank,
> Aforz
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/a50320dc-290f-4a86-9447-1a9518732019%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/a50320dc-290f-4a86-9447-1a9518732019%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAOBFM97g7z2P1wBL9jitvFYUq1dmqpwnuE2Mw_swCUZDq1qixw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to