linux - 使用剧本的 YAML 语法错误 (Ansible)

标签 linux centos ansible yaml

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

我有这个代码:

---

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

关于linux - 使用剧本的 YAML 语法错误 (Ansible),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55457792/

相关文章:

linux - 如何将 C 代码链接到 BoringSSL?

Linux:在 Bash 中查找默认 PDF 查看器的路径

linux - 在目录中的文件内查找字符串然后复制它们

CentOS 上带有 docker-compose.yml 的 Wordpress

node.js - Ansible 和 npm 安装失败并显示 "rc -9"。这是什么意思?

file - 如何使用远程系统上的 Ansible 任务 move/重命名文件

php - UTF-8贯穿始终

c - 如何不以二进制格式 write()

linux - RPM 二进制文件中的退出代码是什么?

R 从 Shell 安装包