ansible_local should not trigger deprecation (#86234) (#86302)

* ansible_local should not trigger deprecation

fixes #86228

(cherry picked from commit ca6dc93dcc)
This commit is contained in:
Brian Coca
2026-01-14 14:16:47 -08:00
committed by GitHub
parent 5cb8ed99a8
commit e9a8a448dd
4 changed files with 17 additions and 1 deletions
@@ -0,0 +1,2 @@
bugfixes:
- ansible_local will no longer trigger variable injection default value deprecation.
+1 -1
View File
@@ -297,7 +297,7 @@ class VariableManager:
# push facts to main namespace
if C.INJECT_FACTS_AS_VARS:
deprecated_facts_vars = {k: _deprecate_top_level_fact(v) for k, v in clean_facts(facts).items()}
deprecated_facts_vars = {k: (_deprecate_top_level_fact(v) if k != 'ansible_local' else v) for k, v in clean_facts(facts).items()}
all_vars = _combine_and_track(all_vars, deprecated_facts_vars, "facts")
else:
# always 'promote' ansible_local
@@ -0,0 +1,8 @@
- hosts: localhost
gather_facts: true
tasks:
- debug:
msg: '{{ansible_distribution}}'
- debug:
msg: '{{ansible_local}}'
tags: alocal
@@ -56,3 +56,9 @@ export ANSIBLE_CACHE_PLUGIN=notjsonfile
# check for plugin deprecation
[ "$(ansible-doc -t cache notjsonfile --playbook-dir ./ | grep -c 'DEPRECATED:')" -eq "1" ]
# Injection default is deprecated
[ "$(ANSIBLE_INJECT_FACT_VARS=1 ansible-playbook injectfacts.yml 2>&1 | grep -c 'INJECT_FACTS_AS_VARS')" -eq "0" ]
# Injection default is deprecated but not ansible_local
[ "$(ansible-playbook injectfacts.yml --tags alocal 2>&1 | grep -c 'INJECT_FACTS_AS_VARS')" -eq "0" ]