【问题标题】:YAML Issue in Ansible 2.3.0Ansible 2.3.0 中的 YAML 问题
【发布时间】:2017-08-11 05:10:34
【问题描述】:

我让这个剧本在运行 Ansible 2.3.1 的 VM 上运行,没有任何错误,但是,我在其他版本 2.3.0 和更早版本中遇到了第一个字符的问题,我看不到我在哪里出错了。

格式完全遵循 cl-license 文档中给出的示例,这非常普通,因为此 YAML 没有逻辑或条件语句或任何东西。

---
- hosts: accton_as6712_32x
  tasks:
    - name: install_license_for_6712
      cl_license:
        src: "http://10.43.255.182/cumulus/license-4x5712-4x6712.txt"

- hosts: accton_as4610_54
  tasks:
    - name: install_license_for_4610
      cl_license:
        src: "http://10.43.255.182/cumulus/license-2x4600.txt"

- hosts: mlnx_x86_MSN2410B
  tasks:
    - name: install_license_for_2410
      cl_license:
        src: "http://10.43.255.182/cumulus/license-2x2410.txt"

- hosts: mlnx_x86_MSN2700
  tasks:
    - name: install_license_for_2700
      cl_license:
        src: "http://10.43.255.182/cumulus/license-mellanox-demo-2700.txt"

这是我从 Jenkins/Ansible 得到的错误:

The offending line appears to be:
---
- hosts: accton_as6712_32x
  ^ here

如果我使用 YAML Lint,我会收到以下错误:

(<unknown>): did not find expected '-' indicator while parsing a block collection at line 2 column 1 

我对 Ansible 还很陌生,如果有人能指出我哪里出错了,我会很高兴?

【问题讨论】:

  • 检查是否有损坏的缩进。该错误表示它无法解析第一个列表,因为可能存在一些损坏的缩进或意外字符(可能位于文件的最末尾),但错误指针设置为损坏元素的开头。

标签: ansible yaml


【解决方案1】:

我并不是说cl-license 模块是错误的方式,但您是否考虑过使用ZTP 在您的 Cumulus 交换机上安装许可证?

顺便说一句,缩进看起来是正确的,但请确保您的文件中有实际的空格而不是制表符。另外,检查任何奇怪的尾随空格。

【讨论】:

    猜你喜欢
    • 2017-01-14
    • 1970-01-01
    • 1970-01-01
    • 2014-08-17
    • 2022-01-21
    • 1970-01-01
    • 2015-03-29
    • 2021-12-07
    • 2020-09-29
    相关资源
    最近更新 更多