Skip to content

Instantly share code, notes, and snippets.

@tima
Created May 8, 2015 23:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tima/8c6c36b65fa77f219c08 to your computer and use it in GitHub Desktop.
Save tima/8c6c36b65fa77f219c08 to your computer and use it in GitHub Desktop.
ansible-callback-echo
import pprint
import inspect
def dump(data=None):
meth = inspect.currentframe().f_back.f_code.co_name
pprint.pprint({meth: data})
class CallbackModule(object):
def __init__(self):
dump(self)
def on_any(self, *args, **kwargs):
# this is called after each and every callback though
# it doesn't tell you which one one.
# dump([args, kwargs])
pass
def runner_on_failed(self, host, res, ignore_errors=False):
dump(res)
def runner_on_ok(self, host, res):
dump([host, res])
def runner_on_error(self, host, msg):
dump([host, msg])
def runner_on_skipped(self, host, item=None):
dump([host, item])
def runner_on_unreachable(self, host, res):
dump(res)
def runner_on_no_hosts(self):
dump()
def runner_on_async_poll(self, host, res, jid, clock):
pass
def runner_on_async_ok(self, host, res, jid):
pass
def runner_on_async_failed(self, host, res, jid):
pass
def playbook_on_start(self):
dump()
def playbook_on_notify(self, host, handler):
dump([host, handler])
def playbook_on_no_hosts_matched(self):
dump()
def playbook_on_no_hosts_remaining(self):
dump()
def playbook_on_task_start(self, name, is_conditional):
dump([name, is_conditional])
def playbook_on_vars_prompt(self, varname, private=True, prompt=None, encrypt=None, confirm=False, salt_size=None, salt=None, default=None):
pass
def playbook_on_setup(self):
dump()
def playbook_on_import_for_host(self, host, imported_file):
dump([host, imported_file])
def playbook_on_not_import_for_host(self, host, missing_file):
dump([host, missing_file])
def playbook_on_play_start(self, pattern):
dump(pattern)
def playbook_on_stats(self, stats):
s = dict()
for h in stats.processed:
s[h] = stats.summarize(h)
dump(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment