Skip to content

New INJECT_FACTS_AS_VARS deprecation in 2.20 is not reported by linter #4857

@marcelmamula

Description

@marcelmamula
Summary

New ansible-core 2.20 brought deprecation of using ansible facts without dictionary, but linter does not show it in warning, making it difficult to find it.

Issue Type
  • Bug Report
OS / ENVIRONMENT
ansible-lint 25.11.1 using ansible-core:2.20.0 ansible-compat:25.11.0 ruamel-yaml:0.18.16 ruamel-yaml-clib:0.2.15
  • ansible installation method: pip3 inside of python 3.13 VENV
  • ansible-lint installation method: pip3 inside of python 3.13 VENV
STEPS TO REPRODUCE

Execute linter for small playbook using ansible_hostname.

    - name: Test ansible_hostname
      ansible.builtin.debug:
        msg: "{{ ansible_hostname}}"
Desired Behavior

Show warning in linter output, same like ansible-playbook generates.

[WARNING]: Deprecation warnings can be disabled by setting `deprecation_warnings=False` in ansible.cfg.
[DEPRECATION WARNING]: INJECT_FACTS_AS_VARS default to `True` is deprecated, top-level facts will not be auto injected after the change. This feature will be removed from ansible-core version 2.24.
Origin: /home/mmamula/workspace/tests/debug.yml:23:14

21     - name: Test ansible_hostname
22       ansible.builtin.debug:
23         msg: "{{ ansible_hostname }}"
                ^ column 14

Use `ansible_facts["fact_name"]` (no `ansible_` prefix) instead.
Actual Behavior

Linter does not show any warnings for this tiny playbook using ansible_hostname.

Passed: 0 failure(s), 0 warning(s) in 1 files processed of 1 encountered.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugnewTriage required

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions