deprecate invalid variable names in inventory (#85377)

* deprecate invalid variable names in inventory

* was previously a hard error for `Host`
* added missing check to `Group`
* swapped blanket Python keyword prohibition with Jinja singleton and `not` check

Co-authored-by: Matt Clay <matt@mystile.com>

* fix invalid variable name test

---------

Co-authored-by: Matt Clay <matt@mystile.com>
(cherry picked from commit 3c52b14c9e)
This commit is contained in:
Matt Davis
2025-06-24 15:18:17 -07:00
committed by Matt Clay
parent 223546bf76
commit 0ce6b45db2
8 changed files with 61 additions and 6 deletions
@@ -92,7 +92,6 @@ breaking_changes:
- templating - Access to ``_`` prefixed attributes and methods, and methods with known side effects, is no longer permitted.
In cases where a matching mapping key is present, the associated value will be returned instead of an error.
This increases template environment isolation and ensures more consistent behavior between the ``.`` and ``[]`` operators.
- inventory - Invalid variable names provided by inventories result in an inventory parse failure. This behavior is now consistent with other variable name usages throughout Ansible.
- internals - The ``ansible.utils.native_jinja`` Python module has been removed.
- internals - The ``AnsibleLoader`` and ``AnsibleDumper`` classes for working with YAML are now factory functions and cannot be extended.
- public API - The ``ansible.vars.fact_cache.FactCache`` wrapper has been removed.
+7
View File
@@ -0,0 +1,7 @@
bugfixes:
- variables - Added Jinja scalar singletons (``true``, ``false``, ``none``) to invalid Ansible variable name detection.
Previously, variables with these names could be assigned without error, but could not be resolved.
minor_changes:
- variables - Removed restriction on usage of most Python keywords as Ansible variable names.
deprecated_features:
- inventory plugins - Setting invalid Ansible variable names in inventory plugins is deprecated.