diff --git a/changelogs/fragments/60912-constructed-groups-option-sanitization.yaml b/changelogs/fragments/60912-constructed-groups-option-sanitization.yaml new file mode 100644 index 00000000000..0cc2c7e9d28 --- /dev/null +++ b/changelogs/fragments/60912-constructed-groups-option-sanitization.yaml @@ -0,0 +1,2 @@ +bugfixes: + - constructed - Add a warning for the change in behavior in the sanitization of the groups option. diff --git a/lib/ansible/plugins/inventory/__init__.py b/lib/ansible/plugins/inventory/__init__.py index 21bdac360d8..9e9ec3990f3 100644 --- a/lib/ansible/plugins/inventory/__init__.py +++ b/lib/ansible/plugins/inventory/__init__.py @@ -372,7 +372,7 @@ class Constructable(object): self.templar.set_available_variables(variables) for group_name in groups: conditional = "{%% if %s %%} True {%% else %%} False {%% endif %%}" % groups[group_name] - group_name = self._sanitize_group_name(group_name) + group_name = original_safe(group_name, force=True) try: result = boolean(self.templar.template(conditional)) except Exception as e: