2015-12-18 01:56:15 +00:00
|
|
|
# (c) 2015, Andrew Gaffney <andrew@agaffney.org>
|
2017-08-20 15:20:30 +00:00
|
|
|
# (c) 2017 Ansible Project
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
|
2017-09-08 18:08:31 +00:00
|
|
|
# Make coding more python3-ish
|
|
|
|
from __future__ import (absolute_import, division, print_function)
|
|
|
|
__metaclass__ = type
|
|
|
|
|
|
|
|
DOCUMENTATION = '''
|
2017-08-20 15:20:30 +00:00
|
|
|
callback: actionable
|
|
|
|
type: stdout
|
|
|
|
short_description: shows only items that need attention
|
|
|
|
description:
|
|
|
|
- Use this callback when you dont care about OK nor Skipped.
|
|
|
|
- This callback suppreses any non Failed or Changed status.
|
|
|
|
version_added: "2.1"
|
2017-09-15 18:14:47 +00:00
|
|
|
extends_documentation_fragment:
|
|
|
|
- default_callback
|
2017-08-20 15:20:30 +00:00
|
|
|
requirements:
|
|
|
|
- set as stdout callback in configuration
|
|
|
|
'''
|
2015-12-18 01:56:15 +00:00
|
|
|
|
|
|
|
from ansible.plugins.callback.default import CallbackModule as CallbackModule_default
|
|
|
|
|
2017-06-02 11:14:11 +00:00
|
|
|
|
2015-12-18 01:56:15 +00:00
|
|
|
class CallbackModule(CallbackModule_default):
|
|
|
|
|
|
|
|
CALLBACK_VERSION = 2.0
|
|
|
|
CALLBACK_TYPE = 'stdout'
|
2016-02-18 10:32:05 +00:00
|
|
|
CALLBACK_NAME = 'actionable'
|
2015-12-18 01:56:15 +00:00
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.super_ref = super(CallbackModule, self)
|
|
|
|
self.super_ref.__init__()
|
|
|
|
self.last_task = None
|
|
|
|
self.shown_title = False
|
|
|
|
|
2016-05-03 15:25:46 +00:00
|
|
|
def v2_playbook_on_handler_task_start(self, task):
|
|
|
|
self.super_ref.v2_playbook_on_handler_task_start(task)
|
|
|
|
self.shown_title = True
|
|
|
|
|
2015-12-18 01:56:15 +00:00
|
|
|
def v2_playbook_on_task_start(self, task, is_conditional):
|
|
|
|
self.last_task = task
|
|
|
|
self.shown_title = False
|
|
|
|
|
|
|
|
def display_task_banner(self):
|
|
|
|
if not self.shown_title:
|
|
|
|
self.super_ref.v2_playbook_on_task_start(self.last_task, None)
|
|
|
|
self.shown_title = True
|
|
|
|
|
|
|
|
def v2_runner_on_failed(self, result, ignore_errors=False):
|
|
|
|
self.display_task_banner()
|
|
|
|
self.super_ref.v2_runner_on_failed(result, ignore_errors)
|
|
|
|
|
|
|
|
def v2_runner_on_ok(self, result):
|
|
|
|
if result._result.get('changed', False):
|
|
|
|
self.display_task_banner()
|
|
|
|
self.super_ref.v2_runner_on_ok(result)
|
|
|
|
|
|
|
|
def v2_runner_on_unreachable(self, result):
|
|
|
|
self.display_task_banner()
|
|
|
|
self.super_ref.v2_runner_on_unreachable(result)
|
|
|
|
|
|
|
|
def v2_runner_on_skipped(self, result):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def v2_playbook_on_include(self, included_file):
|
|
|
|
pass
|
|
|
|
|
2016-03-18 19:15:59 +00:00
|
|
|
def v2_runner_item_on_ok(self, result):
|
2016-03-21 13:59:57 +00:00
|
|
|
if result._result.get('changed', False):
|
|
|
|
self.display_task_banner()
|
|
|
|
self.super_ref.v2_runner_item_on_ok(result)
|
2015-12-18 01:56:15 +00:00
|
|
|
|
2016-03-18 19:15:59 +00:00
|
|
|
def v2_runner_item_on_skipped(self, result):
|
2015-12-18 01:56:15 +00:00
|
|
|
pass
|
|
|
|
|
2016-03-18 19:15:59 +00:00
|
|
|
def v2_runner_item_on_failed(self, result):
|
2015-12-18 01:56:15 +00:00
|
|
|
self.display_task_banner()
|
2016-03-18 19:15:59 +00:00
|
|
|
self.super_ref.v2_runner_item_on_failed(result)
|