From af1e22d4e12a474ae123fe9657a9df075b4cb46a Mon Sep 17 00:00:00 2001 From: Steven Robertson Date: Mon, 3 Feb 2020 14:36:47 -0800 Subject: [PATCH] able to propagate ansible_python_interpreter fact but still doesn't save between task runs --- ansible_mitogen/mixins.py | 18 ++++++++++++++++++ ansible_mitogen/transport_config.py | 3 +++ 2 files changed, 21 insertions(+) diff --git a/ansible_mitogen/mixins.py b/ansible_mitogen/mixins.py index 55c19f5d..b48d4887 100644 --- a/ansible_mitogen/mixins.py +++ b/ansible_mitogen/mixins.py @@ -374,6 +374,24 @@ class ActionModuleMixin(ansible.plugins.action.ActionBase): # on _execute_module(). self._remove_tmp_path(tmp) + # taken from _execute_module of ansible 2.8.6 + # propagate interpreter discovery results back to the controller + if self._discovered_interpreter_key: + if result.get('ansible_facts') is None: + result['ansible_facts'] = {} + + result['ansible_facts'][self._discovered_interpreter_key] = self._discovered_interpreter + + if self._discovery_warnings: + if result.get('warnings') is None: + result['warnings'] = [] + result['warnings'].extend(self._discovery_warnings) + + if self._discovery_deprecation_warnings: + if result.get('deprecations') is None: + result['deprecations'] = [] + data['deprecations'].extend(self._discovery_deprecation_warnings) + return wrap_var(result) def _postprocess_response(self, result): diff --git a/ansible_mitogen/transport_config.py b/ansible_mitogen/transport_config.py index 2754f0cb..f555dc6a 100644 --- a/ansible_mitogen/transport_config.py +++ b/ansible_mitogen/transport_config.py @@ -105,6 +105,9 @@ def run_interpreter_discovery_if_necessary(s, task_vars, action): # cache discovered interpreter task_vars['ansible_facts'][discovered_interpreter_config] = s action._connection.has_pipelining = False + # propagate discovered interpreter as fact + action._discovered_interpreter_key = discovered_interpreter_config + action._discovered_interpreter = s else: s = task_vars['ansible_facts'][discovered_interpreter_config]