diff --git a/changelogs/fragments/73429-inventory-sanitization-constructed-features.yml b/changelogs/fragments/73429-inventory-sanitization-constructed-features.yml new file mode 100644 index 00000000000..7afbfb1ea0a --- /dev/null +++ b/changelogs/fragments/73429-inventory-sanitization-constructed-features.yml @@ -0,0 +1,4 @@ +bugfixes: + - inventory plugins - Let plugins define the sanitization method for the constructed ``groups`` feature. +minor_changes: + - constructed inventory plugin - Sanitize group names created from the ``groups`` option silently. diff --git a/lib/ansible/plugins/inventory/__init__.py b/lib/ansible/plugins/inventory/__init__.py index e0e334e40a9..3748a80fa50 100644 --- a/lib/ansible/plugins/inventory/__init__.py +++ b/lib/ansible/plugins/inventory/__init__.py @@ -389,7 +389,7 @@ class Constructable(object): self.templar.available_variables = variables for group_name in groups: conditional = "{%% if %s %%} True {%% else %%} False {%% endif %%}" % groups[group_name] - group_name = original_safe(group_name, force=True) + group_name = self._sanitize_group_name(group_name) try: result = boolean(self.templar.template(conditional)) except Exception as e: