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

2,227 views
Skip to first unread message

Afroz Hussain

unread,
Jan 8, 2016, 10:26:21 AM1/8/16
to Ansible Project
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

David Karban

unread,
Jan 8, 2016, 11:24:29 AM1/8/16
to ansible...@googlegroups.com
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

--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a50320dc-290f-4a86-9447-1a9518732019%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages