Last active
October 15, 2023 14:36
-
-
Save krushik/751f7a7abc6515c0eeee41a1c5409ab2 to your computer and use it in GitHub Desktop.
ansible callback plugin that warns you of --check mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import (absolute_import, division, print_function) | |
__metaclass__ = type | |
DOCUMENTATION = ''' | |
callback: check_mode_indicator | |
type: aggregate | |
short_description: shows a warning if you run ansible in check mode | |
description: | |
- This callback module shows a big WARNING when you run ansible in check mode. | |
''' | |
from ansible.plugins.callback import CallbackBase | |
from ansible import context | |
class CallbackModule(CallbackBase): | |
""" | |
This callback module shows a big WARNING when you run ansible in check mode. | |
""" | |
CALLBACK_VERSION = 2.0 | |
CALLBACK_TYPE = 'aggregate' | |
CALLBACK_NAME = 'check_mode_indicator' | |
CALLBACK_NEEDS_WHITELIST = False | |
def __init__(self): | |
super(CallbackModule, self).__init__() | |
def v2_playbook_on_stats(self, stats): | |
#print(context.CLIARGS) | |
if context.CLIARGS['check']: | |
self._display.warning("*** THIS WAS ONLY A CHECK MODE RUN ***") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you need to include its path into your .ansible.cfg like this: