From b77abd049161d797013909e4263dabfa7fba612a Mon Sep 17 00:00:00 2001 From: Sloane Hertel Date: Tue, 20 Aug 2019 11:32:02 -0400 Subject: [PATCH] Warn when transforming constructed groups (#60912) * Warn when transforming constructed groups The `keyed_groups` field has used sanitization since 2.6, but `groups` only started doing so in 2.8. This adds a warning for the change in behavior. * changelog (cherry picked from commit 3247626ac7a3e22739e4e343ebf5919b33784c8e) --- .../fragments/60912-constructed-groups-option-sanitization.yaml | 2 ++ lib/ansible/plugins/inventory/__init__.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/60912-constructed-groups-option-sanitization.yaml 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: