summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBrian Coca <bcoca@users.noreply.github.com>2025-01-18 03:33:25 +0100
committerGitHub <noreply@github.com>2025-01-18 03:33:25 +0100
commit3398c102b5c41d48d0cbc2d81f9c004f07ac3fcb (patch)
treeb2a1ff8d4c7b862f811cb35e0eec228ddfaad232 /lib
parentfix template (#84563) (diff)
downloadansible-3398c102b5c41d48d0cbc2d81f9c004f07ac3fcb.tar.xz
ansible-3398c102b5c41d48d0cbc2d81f9c004f07ac3fcb.zip
reserved vars, avoid gather_subset (#84575)HEADdevel
Diffstat (limited to 'lib')
-rw-r--r--lib/ansible/vars/manager.py6
-rw-r--r--lib/ansible/vars/reserved.py12
2 files changed, 8 insertions, 10 deletions
diff --git a/lib/ansible/vars/manager.py b/lib/ansible/vars/manager.py
index aa84681a4d..d25d63730b 100644
--- a/lib/ansible/vars/manager.py
+++ b/lib/ansible/vars/manager.py
@@ -559,8 +559,7 @@ class VariableManager:
if not isinstance(facts, Mapping):
raise AnsibleAssertionError("the type of 'facts' to set for host_facts should be a Mapping but is a %s" % type(facts))
- # NOTE: will ignore gather_subset until we can deprecate/remove this as a return from setup.py
- warn_if_reserved(facts.keys(), ignores=['gather_subset'])
+ warn_if_reserved(facts.keys())
try:
host_cache = self._fact_cache[host]
except KeyError:
@@ -584,8 +583,7 @@ class VariableManager:
if not isinstance(facts, Mapping):
raise AnsibleAssertionError("the type of 'facts' to set for nonpersistent_facts should be a Mapping but is a %s" % type(facts))
- # NOTE: will ignore gather_subset until we can deprecate/remove this as a return from setup.py
- warn_if_reserved(facts.keys(), ignores=['gather_subset'])
+ warn_if_reserved(facts.keys())
try:
self._nonpersistent_fact_cache[host] |= facts
except KeyError:
diff --git a/lib/ansible/vars/reserved.py b/lib/ansible/vars/reserved.py
index 4799b307a3..89850bd417 100644
--- a/lib/ansible/vars/reserved.py
+++ b/lib/ansible/vars/reserved.py
@@ -60,10 +60,14 @@ def get_reserved_names(include_private: bool = True) -> set[str]:
else:
result = public
+ # due to Collectors always adding, need to ignore this
+ # eventually should remove after we deprecate it in setup.py
+ result.remove('gather_subset')
+
return result
-def warn_if_reserved(myvars: list[str], additional: list[str] | None = None, ignores: list[str] | None = None) -> None:
+def warn_if_reserved(myvars: list[str], additional: list[str] | None = None) -> None:
""" this function warns if any variable passed conflicts with internally reserved names """
if additional is None:
@@ -71,14 +75,10 @@ def warn_if_reserved(myvars: list[str], additional: list[str] | None = None, ign
else:
reserved = _RESERVED_NAMES.union(additional)
- if ignores is None:
- ignores = []
-
varnames = set(myvars)
varnames.discard('vars') # we add this one internally, so safe to ignore
for varname in varnames.intersection(reserved):
- if varname not in ignores:
- display.warning('Found variable using reserved name: %s' % varname)
+ display.warning('Found variable using reserved name: %s' % varname)
def is_reserved_name(name: str) -> bool: