Merge pull request #11511 from galindro/syslog_json_improvement
syslog_json call plugin improvements
This commit is contained in:
commit
aa095df19c
1 changed files with 10 additions and 8 deletions
|
@ -4,6 +4,7 @@ import json
|
||||||
import logging
|
import logging
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
|
|
||||||
|
import socket
|
||||||
|
|
||||||
class CallbackModule(object):
|
class CallbackModule(object):
|
||||||
"""
|
"""
|
||||||
|
@ -26,22 +27,23 @@ class CallbackModule(object):
|
||||||
os.getenv('SYSLOG_PORT',514)),
|
os.getenv('SYSLOG_PORT',514)),
|
||||||
facility=logging.handlers.SysLogHandler.LOG_USER
|
facility=logging.handlers.SysLogHandler.LOG_USER
|
||||||
)
|
)
|
||||||
self.logger.addHandler(handler)
|
self.logger.addHandler(self.handler)
|
||||||
|
self.hostname = socket.gethostname()
|
||||||
|
|
||||||
def on_any(self, *args, **kwargs):
|
def on_any(self, *args, **kwargs):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def runner_on_failed(self, host, res, ignore_errors=False):
|
def runner_on_failed(self, host, res, ignore_errors=False):
|
||||||
self.logger.info('RUNNER_ON_FAILED ' + host + ' ' + json.dumps(res, sort_keys=True))
|
self.logger.error('%s ansible-command: task execution FAILED; host: %s; message: %s' % (self.hostname,host,json.dumps(res, sort_keys=True)))
|
||||||
|
|
||||||
def runner_on_ok(self, host, res):
|
def runner_on_ok(self, host, res):
|
||||||
self.logger.info('RUNNER_ON_OK ' + host + ' ' + json.dumps(res, sort_keys=True))
|
self.logger.info('%s ansible-command: task execution OK; host: %s; message: %s' % (self.hostname,host,json.dumps(res, sort_keys=True)))
|
||||||
|
|
||||||
def runner_on_skipped(self, host, item=None):
|
def runner_on_skipped(self, host, item=None):
|
||||||
self.logger.info('RUNNER_ON_SKIPPED ' + host + ' ...')
|
self.logger.info('%s ansible-command: task execution SKIPPED; host: %s; message: %s' % (self.hostname,host,json.dumps(res, sort_keys=True)))
|
||||||
|
|
||||||
def runner_on_unreachable(self, host, res):
|
def runner_on_unreachable(self, host, res):
|
||||||
self.logger.info('RUNNER_UNREACHABLE ' + host + ' ' + json.dumps(res, sort_keys=True))
|
self.logger.error('%s ansible-command: task execution UNREACHABLE; host: %s; message: %s' % (self.hostname,host,json.dumps(res, sort_keys=True)))
|
||||||
|
|
||||||
def runner_on_no_hosts(self):
|
def runner_on_no_hosts(self):
|
||||||
pass
|
pass
|
||||||
|
@ -53,7 +55,7 @@ class CallbackModule(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def runner_on_async_failed(self, host, res):
|
def runner_on_async_failed(self, host, res):
|
||||||
self.logger.info('RUNNER_SYNC_FAILED ' + host + ' ' + json.dumps(res, sort_keys=True))
|
self.logger.error('%s ansible-command: task execution FAILED; host: %s; message: %s' % (self.hostname,host,json.dumps(res, sort_keys=True)))
|
||||||
|
|
||||||
def playbook_on_start(self):
|
def playbook_on_start(self):
|
||||||
pass
|
pass
|
||||||
|
@ -77,10 +79,10 @@ class CallbackModule(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def playbook_on_import_for_host(self, host, imported_file):
|
def playbook_on_import_for_host(self, host, imported_file):
|
||||||
self.logger.info('PLAYBOOK_ON_IMPORTED ' + host + ' ' + json.dumps(res, sort_keys=True))
|
self.logger.info('%s ansible-command: playbook IMPORTED; host: %s; message: %s' % (self.hostname,host,json.dumps(res, sort_keys=True)))
|
||||||
|
|
||||||
def playbook_on_not_import_for_host(self, host, missing_file):
|
def playbook_on_not_import_for_host(self, host, missing_file):
|
||||||
self.logger.info('PLAYBOOK_ON_NOTIMPORTED ' + host + ' ' + json.dumps(res, sort_keys=True))
|
self.logger.info('%s ansible-command: playbook NOT IMPORTED; host: %s; message: %s' % (self.hostname,host,json.dumps(res, sort_keys=True)))
|
||||||
|
|
||||||
def playbook_on_play_start(self, name):
|
def playbook_on_play_start(self, name):
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in a new issue