Ansible Lint 尾随 space

Ansible Lint trailing space

我已经对下面的 yml 代码执行了 ansible lint 检查,即使没有尾随空格,我也收到了尾随空格警告,提示已给出缩进。你能就如何克服这个问题提出建议吗

---
- hosts: localhost
  gather_facts: false
  tasks:
  - block:
    - name: Which python is running
      command: "which python"
      register: result

    - name: Debug
      debug: var=result.stdout

ansible-lint test.yml

[201] Trailing whitespace
test.yml:1
---

[201] Trailing whitespace
test.yml:2
- hosts: localhost

[201] Trailing whitespace
test.yml:3
 gather_facts: false

每一行依此类推

我会在这里大胆猜测(如果我完全错了,我会删除我的答案):

  • 您的文件有 CRLF 行结尾(即 windows 样式行结尾)
  • 你是 运行 ansible-lint < 4.0.0

如果我的猜测是正确的,那么您患有 a bug which has been fixed

升级 ansible-lint 您的问题应该会消失:

pip install --upgrade ansible-lint

如果没有快速路径来执行此升级,您始终可以将行结尾仅转换为 LF,直到您的管理员可以完成这项工作。