Skip to content

Instantly share code, notes, and snippets.

@czunker
Forked from steinim/human_log.py
Last active August 29, 2015 14:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save czunker/becbc36f6b129c2c0d96 to your computer and use it in GitHub Desktop.
Save czunker/becbc36f6b129c2c0d96 to your computer and use it in GitHub Desktop.
This is special variant of the human_log.py, to just get output when something changed.
FIELDS = ['stdout']
def human_log(res):
if type(res) == type(dict()):
for field in FIELDS:
if field in res.keys():
encoded_field = res[field].encode('utf-8')
print '\n{0}:\n{1}'.format(field, encoded_field)
class CallbackModule(object):
def on_any(self, *args, **kwargs):
pass
def runner_on_ok(self, host, res):
# inspiration from this gist: https://gist.github.com/alekstorm/6350729
if res.pop('changed', False):
human_log(res)
else:
pass
def runner_on_failed(self, host, res):
pass
def runner_on_error(self, host, msg):
pass
def runner_on_skipped(self, host, item=None):
pass
def runner_on_unreachable(self, host, res):
pass
def runner_on_no_hosts(self):
pass
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):
# inspiration from this gist: https://gist.github.com/alekstorm/6350729
if res.pop('changed', False):
human_log(res)
else:
pass
def playbook_on_start(self):
pass
def playbook_on_notify(self, host, handler):
pass
def playbook_on_no_hosts_matched(self):
pass
def playbook_on_no_hosts_remaining(self):
pass
def playbook_on_task_start(self, name, is_conditional):
pass
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):
pass
def playbook_on_import_for_host(self, host, imported_file):
pass
def playbook_on_not_import_for_host(self, host, missing_file):
pass
def playbook_on_play_start(self, pattern):
pass
def playbook_on_stats(self, stats):
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment