修复 yaml lint 大括号中空格过多错误?

问题描述 投票:0回答:1

您好,我在 Runbook 上遇到 yamlint 错误,无论我尝试什么,我都无法传递错误,您能帮忙租赁吗? 错误在循环中

我尝试删除空格或用双引号或单引号包裹项目,但似乎没有任何效果。我希望有人能帮助我

- name: Rename directories to be replaced by symbolic links
  ansible.builtin.shell:
  command: "mv {{ item.original }} {{ item.new }}"
  args:
    chdir: /xx/tt/ll/
  loop:
    - { original: 'backup', new: backupbkp }
    - { original: 'db', new:'dbbkp' }
    - { original: "ini", new: "inibkp" }
    - { original: "lock", new: "lockbkp" }
    - { original: "log", new: "logbkp" }

 26:8      error    too many spaces inside braces  (braces)
  26:43     error    too many spaces inside braces  (braces)
  27:8      error    too many spaces inside braces  (braces)
  27:36     error    too many spaces inside braces  (braces)
  28:8      error    too many spaces inside braces  (braces)
  28:39     error    too many spaces inside braces  (braces)
  29:8      error    too many spaces inside braces  (braces)
  29:41     error    too many spaces inside braces  (braces)

enter code here
azure ansible yaml pipeline lint
1个回答
0
投票

您在 YAML 文件中遇到的错误与格式有关,特别是与大括号内的空格有关。 这是 YAML 片段的更正版本:

- name: Rename directories to be replaced by symbolic links
  ansible.builtin.shell:
    command: "mv {{ item.original }} {{ item.new }}"
    args:
      chdir: /opt/aptitude/aptitude-21.1.1/
    loop:
      - { original: 'backup', new: 'backupbkp' }
      - { original: 'db', new: 'dbbkp' }
      - { original: 'ini', new: 'inibkp' }
      - { original: 'lock', new: 'lockbkp' }
      - { original: 'log', new: 'logbkp' }

所做的更改:

  • 为了保持一致性,我在字典中的所有值周围添加了单引号
    '
  • 我检查了缩进并确保它符合 YAML 的要求。

请在您的 YAML 文件中尝试这个更正后的版本。如果您仍然遇到错误,使用 YAML linter 或验证器检查整个文件是否存在任何其他潜在问题可能会有所帮助,如下所示 - enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.