Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible - ERROR! the field 'hosts' is required but was not set

Tags:

ansible

I've an error when I launch a playbook but I don't found why....

ERROR! the field 'hosts' is required but was not set

There is my main.yml :

---
- hosts: hosts
- vars: 
  - elasticsearch_java_home: /usr/lib/jmv/jre-1.7.0
  - elasticsearch_http_port: 8443

- tasks: 
  - include: tasks/main.yml

- handlers:
  - include: handlers/main.yml

And my /etc/ansible/hosts :

[hosts]
10.23.108.182
10.23.108.183
10.23.108.184
10.23.108.185

When I test a ping, all is good :

[root@poste08-08-00 elasticsearch]# ansible hosts -m ping
10.23.108.183 | SUCCESS => {
    "changed": false, 
    "ping": "pong" }
10.23.108.182 | SUCCESS => {
    "changed": false, 
    "ping": "pong" }
10.23.108.185 | SUCCESS => {
    "changed": false, 
    "ping": "pong" }
10.23.108.184 | SUCCESS => {
    "changed": false, 
    "ping": "pong" }

Please, help me :) Regards,

like image 686
Rémy BRILLET Avatar asked Apr 19 '16 17:04

Rémy BRILLET


2 Answers

You have a syntax error in your playbook.

---
- hosts: webservers
  vars:
    http_port: 80
    max_clients: 200

See: https://docs.ansible.com/ansible/playbooks_intro.html

like image 191
flxPeters Avatar answered Nov 18 '22 17:11

flxPeters


---
- hosts: all

  remote_user: root

  tasks:
like image 3
SJP Avatar answered Nov 18 '22 17:11

SJP