Skip to content

False positive for partial-become #4493

@zjpeterson

Description

@zjpeterson
Summary

When using become_user on a task, with become=true at play level, partial-become is triggered stating "become_user should have a corresponding become at the play or task level." - when that is already true. There should be no need to repeat become=true on the task.

Issue Type
  • Bug Report
OS / ENVIRONMENT
ansible-lint 25.1.0 using ansible-core:2.18.1 ansible-compat:24.10.0 ruamel-yaml:0.18.10 ruamel-yaml-clib:None
  • ansible installation method: pip
  • ansible-lint installation method: pip
STEPS TO REPRODUCE
---
- name: Example
  hosts: pgsql
  gather_facts: false
  become: true

  tasks:
    - name: Initialize postgres
      ansible.builtin.command: postgresql-setup --initdb
      args:
        creates: /var/lib/pgsql/data/postgresql.conf
      become_user: postgres
Desired Behavior

Playbook passes lint

Actual Behavior
ansible-lint example.yml
WARNING  Listing 1 violation(s) that are fatal
partial-become[task]: ``become_user`` should have a corresponding ``become`` at the play or task level.
example.yml:8 Task/Handler: Initialize postgres

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

# Rule Violation Summary

  1 partial-become profile:basic tags:unpredictability

Failed: 1 failure(s), 0 warning(s) on 1 files. Last profile that met the validation criteria was 'min'.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions