From 65ce4779887be675aa12d5f551a1371f57d45fa0 Mon Sep 17 00:00:00 2001 From: Oliver Walsh Date: Tue, 1 Sep 2020 21:43:16 +0100 Subject: [PATCH] Workaround tripleo_nova_cache issue in ansible 2.9.11 https://github.com/ansible/ansible/commit/99a37234b7393fd1d70e03c4687dad809c12a670 changes the core action plugin to assume task_vars has ansible_facts and ansible_delegated_vars keys when interpreter discovery is triggered. The tripleo_nova_cache action plugin passes custom task_vars dicts via self._exec_module that do not contain these keys. This looks like a regression in ansible. Workaround it for now while I take the issue upstream. Change-Id: I57dc24b8450f900ac1fb4e4c2f420f104618c609 (cherry picked from commit f38b4c97b9feeecaaf9071549a8d74023005563b) --- .../action/tripleo_nova_image_cache.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tripleo_ansible/ansible_plugins/action/tripleo_nova_image_cache.py b/tripleo_ansible/ansible_plugins/action/tripleo_nova_image_cache.py index bc887e7c9..9f7f7e470 100644 --- a/tripleo_ansible/ansible_plugins/action/tripleo_nova_image_cache.py +++ b/tripleo_ansible/ansible_plugins/action/tripleo_nova_image_cache.py @@ -79,7 +79,11 @@ class ActionModule(ActionBase): 'creates': cache_dir } - command_task_vars = {'become': True} + command_task_vars = { + 'become': True, + 'ansible_facts': task_vars.get('ansible_facts', {}), + 'ansible_delegated_vars': task_vars.get('ansible_delegated_vars', {}) + } command_result = self._execute_module( 'command', module_args=command_args, @@ -115,7 +119,11 @@ class ActionModule(ActionBase): "\"mkdir -p '{}'; chmod 755 '{}'\"" ).format(container_cli, cache_tmp, cache_tmp), } - command_task_vars = {'become': True} + command_task_vars = { + 'become': True, + 'ansible_facts': task_vars.get('ansible_facts', {}), + 'ansible_delegated_vars': task_vars.get('ansible_delegated_vars', {}) + } command_result = self._execute_module( 'command', module_args=command_args, @@ -133,7 +141,12 @@ class ActionModule(ActionBase): cache_tmp ) } - command_task_vars = {'become': True, 'ignore_errors': True} + command_task_vars = { + 'become': True, + 'ignore_errors': True, + 'ansible_facts': task_vars.get('ansible_facts', {}), + 'ansible_delegated_vars': task_vars.get('ansible_delegated_vars', {}) + } command_result = self._execute_module( 'command', module_args=command_args,