繁体   English   中英

使用playbooks的YAML语法错误(Ansible)

[英]YAML syntax error (Ansible) using playbooks

我使用ansible-module-vcloud,我想通过Ansible创建VM。 例如,我想创建最简单的剧本。

我有这个代码:

---

- name: vCloudDirectorAnsible
  hosts: localhost
  environment:
    env_user: admin
    env_password: admin
    env_host: vcloud.vmware.ru
    env_org: test
    env_api_version: 30.0
    env_verify_ssl_certs: false

- name: create catalog
  vcd_catalog:
        catalog_name: "test"
        catalog_description: "test_Descr"
        state: "present"

但是我得到了错误:

ERROR! 'vcd_catalog' is not a valid attribute for a Play

The error appears to have been in '/root/ansible-module-vcloud-director/main.yml': line 14, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name: create catalog
  ^ here

如果我删除这部分:

- name: create catalog
  vcd_catalog:
        catalog_name: "test"
        catalog_description: "test_Descr"
        state: "present"

我的剧本将运行并成功完成。

如何解决这个问题?

你错过了tasks关键字。

---

- name: vCloudDirectorAnsible
  hosts: localhost
  environment:
    env_user: admin
    env_password: admin
    env_host: vcloud.vmware.ru
    env_org: test
    env_api_version: 30.0
    env_verify_ssl_certs: false
  tasks:
    - name: create catalog
      vcd_catalog:
        catalog_name: "test"
        catalog_description: "test_Descr"
        state: "present"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM