able to propagate ansible_python_interpreter fact but still doesn't save between task runs

This commit is contained in:
Steven Robertson 2020-02-03 14:36:47 -08:00
parent 119e1c24aa
commit af1e22d4e1
2 changed files with 21 additions and 0 deletions

View File

@ -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):

View File

@ -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]