Add tripleo callback

The default calback has the worst UX messaging for async tasks ever.
We're creating a tripleo callback that can be configured to replace the
standard 'FAILED - RETRYING: %s (%d retries left).' with the more
userfriendly 'WAITING FOR COMPLETION: %s (%d retries left).' when it's
an async task and a 'RETRY: %s (%d retries left).' when it's a failure

The tripleo callback inherits everything else from the ansible default
callback that is currently used and overrides the individual functions
as necessary.

See also

Change-Id: I3582c5ed80f755e2206782823457338d1fb42213
Alex Schultz 3 years ago
parent 801c11ca02
commit e3e80b8d43

@ -0,0 +1,37 @@
# Copyright 2020 Red Hat, Inc.
# All Rights Reserved.
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible import constants as C
from ansible.plugins.callback.default import CallbackModule as BASE
class CallbackModule(BASE):
def v2_runner_retry(self, result):
task_name = result.task_name or result._task
retry_count = result._result['retries'] - result._result['attempts']
if (getattr(result, '_task', False)
and (getattr(result._task, 'action', False)
in ['async_status'])):
state = "RETRYING"
msg = "%s: %s (%d retries left)." % (state, task_name, retry_count)
if self._run_is_verbose(result, verbosity=2):
msg += "Result was: %s" % self._dump_results(result._result)
self._display.display(msg, color=color)