Ansible error: "ERROR: hosts is not a legal parameter in an Ansible task or handler"

I have just add spark_master and spark_workers to the site.yml file. However, when I ran the ansible-playbook with my inventory file, I keep getting this error: ERROR: hosts is not a legal parameter in an Ansible task or handler. If I remove the spark_master and spark_workers, it will run fine. My ansible version is 1.9.4, python version 2.7.10

site.yml:

---
# The main playbook to deploy the site

- hosts: hadoop_all
  sudo: yes
  roles:
   - hadoop_common

- hosts: hadoop_master_primary
  roles:
  - { role: hadoop_primary }

- hosts: hadoop_slaves
  roles:
  - { role: hadoop_slaves }

- hosts: spark_master
  roles:
  - { role: spark_master }

- hosts: spark_workers
  roles:
  - { role: spark_workers }

inventory_file:

[hadoop_all:children]
hadoop_masters
hadoop_slaves
hadoop_clients

[hadoop_master_primary]
hadoopmaster ansible_ssh_host=192.168.50.11

[hadoop_master_secondary]

[hadoop_masters:children]
hadoop_master_primary
hadoop_master_secondary

[hadoop_slaves]
hadoopslave1 ansible_ssh_host=192.168.50.12
hadoopslave2 ansible_ssh_host=192.168.50.13
hadoopslave3 ansible_ssh_host=192.168.50.14

[hadoop_clients]
hadoopclient1 ansible_ssh_host=192.168.50.15

[spark_master]
hadoopmaster

[spark_workers]
hadoopslave1
hadoopslave2
hadoopslave3

Answers


There is nothing wrong with your site.yml file. However, I definitely think that you may have placed "- hosts:" parameter in one of the roles' "tasks/main.yml" file. Since you are saying that your play runs fine without spark_master and spark_workers, I suspect that the culprit is "tasks/main.yml" file in one of those two roles.

I was able to reproduce your problem by running your site.yml, but adding the unnecessary "- Hosts:" parameter in a local role.

Let me know how it goes.


Need Your Help

how to use PuTTY's PLINK with Node.js?

node.js ssh putty plink

i am trying to develop a browser based interface with node.js to execute commands on remote servers, same as PuTTY on browser. is there any library available or something for a reference?

Achieving a centered well in Bootstrap CSS

html css twitter-bootstrap css3 laravel-5.1

I want to center the well; here is my code and screenshot. The well I have added should appear in the middle. what should I do? Here is the complete body of the page I'm using. I'm new in Bootstrap...