From 4315e1880742eedc5b65fdc51fdc6a94afa61bd1 Mon Sep 17 00:00:00 2001 From: Michael Shnit <11436882+msh111@users.noreply.github.com> Date: Fri, 5 Feb 2021 00:25:08 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20regression=20introduced=20in=20b77abd0491?= =?UTF-8?q?=20causing=20bug=20in=20inventory=20modu=E2=80=A6=20(#73429)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix regression introduced in b77abd0491 causing bug in inventory modules which break functionality in user setting use_contrib_script_compatible_sanitization parameter. * Add changelog Co-authored-by: s-hertel <19572925+s-hertel@users.noreply.github.com> --- .../73429-inventory-sanitization-constructed-features.yml | 4 ++++ lib/ansible/plugins/inventory/__init__.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/73429-inventory-sanitization-constructed-features.yml 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: