From 7eca0c70e388cf07badb5e13e89fc7e1938b82dd Mon Sep 17 00:00:00 2001 From: Alex Schultz Date: Mon, 14 Sep 2020 10:40:17 -0600 Subject: [PATCH] Fix compatibility issue in tripleo callback The default callback sets some compatibility options but does not properly do it in both the ways that are used. The show_per_host_start is a compatibility option but the default callback uses get_option(...) which checks for the existance in _plugin_options. Since it is not defined there, the callback fails hard and the function no longer works. This change adds our own compatibility layer to ensure the compatibility options are set in _plugin_options until we can get a fix upstream. Change-Id: I476aee9863ad63ce6d7ccf9350dae8540a37f017 Closes-Bug: #1895571 --- .../ansible_plugins/callback/tripleo.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tripleo_ansible/ansible_plugins/callback/tripleo.py b/tripleo_ansible/ansible_plugins/callback/tripleo.py index 6dfc701db..9a3de911d 100644 --- a/tripleo_ansible/ansible_plugins/callback/tripleo.py +++ b/tripleo_ansible/ansible_plugins/callback/tripleo.py @@ -16,9 +16,25 @@ __metaclass__ = type from ansible import constants as C from ansible.plugins.callback.default import CallbackModule as BASE +from ansible.plugins.callback.default import COMPAT_OPTIONS class CallbackModule(BASE): + def set_options(self, task_keys=None, var_options=None, direct=None): + super(CallbackModule, self).set_options(task_keys=task_keys, + var_options=var_options, + direct=direct) + # NOTE(mwhahaha): work around for bug in ansible's default callback + # where it sets the attr on the object but not in the plugin options + # for the compatibility options. Need to submit this upstream. + for option, constant in COMPAT_OPTIONS: + try: + value = self.get_option(option) + except (AttributeError, KeyError): + value = constant + if option not in self._plugin_options: + self._plugin_options[option] = value + def v2_runner_retry(self, result): task_name = result.task_name or result._task retry_count = result._result['retries'] - result._result['attempts']