Ansible - 错误!字段'hosts'是必需的,但未设置

时间:2016-04-19 17:00:54

标签: ansible

我发布剧本时出错,但我找不到原因......

  

ERROR!字段'hosts'是必需的但未设置

有我的main.yml:

[hosts]
10.23.108.182
10.23.108.183
10.23.108.184
10.23.108.185

我的/ etc / ansible / hosts:

[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" }

当我测试ping时,一切都很好:

// First you get the MonoScript of your MonoBehaviour
MonoScript monoScript = MonoScript.FromMonoBehaviour(yourMonoBehaviour);

// Getting the current execution order of that MonoScript
int currentExecutionOrder = MonoImporter.GetExecutionOrder(monoScript);

// Changing the MonoScript's execution order
MonoImporter.SetExecutionOrder(monoScript, x);

请帮帮我:) 的问候,

3 个答案:

答案 0 :(得分:20)

您的剧本中存在语法错误。

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

请参阅:https://docs.ansible.com/ansible/playbooks_intro.html

答案 1 :(得分:2)

---
- hosts: all

  remote_user: root

  tasks:

答案 2 :(得分:-1)

在任务执行前删除连字符,因为这是单人游戏的一部分:

---
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

根据YAML spec

  

块序列用破折号(“-”)指示每个成员。块映射使用冒号标记每个(键:值)对。