Ansible Lint trailing space

5.6k views Asked by At

I have performed ansible lint check on the below yml code, even though there is no trailing spaces, I'm receiving trailing whitespace warning for the indentation that has been given. Can you advice on how that can be overcome

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

and so on for each line

1

There are 1 answers

0
Zeitounator On BEST ANSWER

I'll make wild guesses here (and will remove my answer if I'm totally wrong):

  • Your file has CRLF line endings (i.e. windows style line endings)
  • You are running ansible-lint < 4.0.0

If my guesses are correct, you are suffering from a bug which has been fixed.

Upgrade ansible-lint and your problem should go away:

pip install --upgrade ansible-lint

In case there is no fast path to perform this upgrade, you can always transform your line endings to LF only until your admin can do the job.