From 722cf0ea8dad765774b7771ec292b37fe7ca69c3 Mon Sep 17 00:00:00 2001 From: Steven Robertson Date: Tue, 11 Feb 2020 17:21:47 -0800 Subject: [PATCH] handle ansible 2.3.3 remove_internal_keys --- ansible_mitogen/mixins.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ansible_mitogen/mixins.py b/ansible_mitogen/mixins.py index 7c2d7975..a6f4ec6f 100644 --- a/ansible_mitogen/mixins.py +++ b/ansible_mitogen/mixins.py @@ -61,9 +61,15 @@ except ImportError: from ansible.vars.unsafe_proxy import wrap_var try: + # ansible 2.8 moved remove_internal_keys to the clean module from ansible.vars.clean import remove_internal_keys except ImportError: - from ansible.vars.manager import remove_internal_keys + try: + from ansible.vars.manager import remove_internal_keys + except ImportError: + # ansible 2.3.3 has remove_internal_keys as a protected func on the action class + # we'll fallback to calling self._remove_internal_keys in this case + remove_internal_keys = lambda a: None LOG = logging.getLogger(__name__) @@ -385,7 +391,8 @@ class ActionModuleMixin(ansible.plugins.action.ActionBase): self._remove_tmp_path(tmp) # prevents things like discovered_interpreter_* or ansible_discovered_interpreter_* from being set - remove_internal_keys(result) + # handle ansible 2.3.3 that has remove_internal_keys in a different place + remove_internal_keys(result) or self._remove_internal_keys(result) # taken from _execute_module of ansible 2.8.6 # propagate interpreter discovery results back to the controller