Ansible Lint尾随空间

问题描述

即使没有尾随空格,我也对下面的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

如果我的猜测是正确的,则说明您患有a bugfixed

升级ansible-lint,您的问题将消失:

pip install --upgrade ansible-lint

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