Skip to content

no-tabs Rule Does Not Recognize lineinfile Inside block #4719

@mischif

Description

@mischif
Summary

I have a lineinfile task with a tab that initially passed linting without issue, but after putting the task inside a block I now get a lint error about no-tabs.

Issue Type
  • Bug Report
OS / ENVIRONMENT
ansible-lint 25.7.0 using ansible-core:2.17.13 ansible-compat:25.6.0 ruamel-yaml:0.18.14 ruamel-yaml-clib:0.2.7
  • ansible installation method: pip
  • ansible-lint installation method: pip
STEPS TO REPRODUCE
---
- name: Example playbook
  hosts: all
  tasks:
    - name: Example block
      block:
        - name: Do not trigger the rule
          ansible.builtin.lineinfile:
            path: some.txt
            regexp: "^\t$"
            line: "string with \t inside"
Desired Behavior

The playbook should have no linting failures.

Actual Behavior

Please give some details of what is happening. Include a minimum complete
verifiable example
with:

  • minimized playbook to reproduce the error
  • the output of running ansible-lint including the command line used
  • if you're getting a stack trace, also the output of
    ansible-playbook --syntax-check playbook
$ ansible-lint --profile production badbook.yml 

WARNING  Listing 2 violation(s) that are fatal
no-tabs: Most files should not contain tabs.
badbook.yml:10:21 Task/Handler: Example block

no-tabs: Most files should not contain tabs.
badbook.yml:11:19 Task/Handler: Example block

Read documentation for instructions on how to ignore specific rule violations.

# Rule Violation Summary

  2 no-tabs profile:basic tags:formatting

Failed: 2 failure(s), 0 warning(s) on 1 files. Profile 'production' was required, but 'min' profile passed.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions