mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* [plugins/callback/syslog_json.py] use v2 api, add option to skip syslog on gather_facts
* Update plugins/callback/syslog_json.py
Add version
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update plugins/callback/syslog_json.py
consistency for description
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update plugins/callback/syslog_json.py
ANSIBLE_ environment variable prefix
Co-authored-by: Felix Fontein <felix@fontein.de>
* add changelog fragment for PR 4223
* Update changelogs/fragments/4223-syslog-json-skip-syslog-option.yml
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 9c3704bd00
)
Co-authored-by: andrewroffey <36812998+andrewroffey@users.noreply.github.com>
This commit is contained in:
parent
70a7f66d4c
commit
d7b31655c4
2 changed files with 33 additions and 8 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
minor_changes:
|
||||||
|
- syslog_json - add option to skip logging of ``gather_facts`` playbook tasks; use v2 callback API (https://github.com/ansible-collections/community.general/pull/4223).
|
|
@ -41,6 +41,16 @@ DOCUMENTATION = '''
|
||||||
ini:
|
ini:
|
||||||
- section: callback_syslog_json
|
- section: callback_syslog_json
|
||||||
key: syslog_facility
|
key: syslog_facility
|
||||||
|
setup:
|
||||||
|
description: Log setup tasks.
|
||||||
|
env:
|
||||||
|
- name: ANSIBLE_SYSLOG_SETUP
|
||||||
|
type: bool
|
||||||
|
default: true
|
||||||
|
ini:
|
||||||
|
- section: callback_syslog_json
|
||||||
|
key: syslog_setup
|
||||||
|
version_added: 4.5.0
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -86,23 +96,36 @@ class CallbackModule(CallbackBase):
|
||||||
self.logger.addHandler(self.handler)
|
self.logger.addHandler(self.handler)
|
||||||
self.hostname = socket.gethostname()
|
self.hostname = socket.gethostname()
|
||||||
|
|
||||||
def runner_on_failed(self, host, res, ignore_errors=False):
|
def v2_runner_on_failed(self, result, ignore_errors=False):
|
||||||
|
res = result._result
|
||||||
|
host = result._host.get_name()
|
||||||
self.logger.error('%s ansible-command: task execution FAILED; host: %s; message: %s', self.hostname, host, self._dump_results(res))
|
self.logger.error('%s ansible-command: task execution FAILED; host: %s; message: %s', self.hostname, host, self._dump_results(res))
|
||||||
|
|
||||||
def runner_on_ok(self, host, res):
|
def v2_runner_on_ok(self, result):
|
||||||
self.logger.info('%s ansible-command: task execution OK; host: %s; message: %s', self.hostname, host, self._dump_results(res))
|
res = result._result
|
||||||
|
host = result._host.get_name()
|
||||||
|
if result._task.action != "gather_facts" or self.get_option("setup"):
|
||||||
|
self.logger.info('%s ansible-command: task execution OK; host: %s; message: %s', self.hostname, host, self._dump_results(res))
|
||||||
|
|
||||||
def runner_on_skipped(self, host, item=None):
|
def v2_runner_on_skipped(self, result):
|
||||||
|
host = result._host.get_name()
|
||||||
self.logger.info('%s ansible-command: task execution SKIPPED; host: %s; message: %s', self.hostname, host, 'skipped')
|
self.logger.info('%s ansible-command: task execution SKIPPED; host: %s; message: %s', self.hostname, host, 'skipped')
|
||||||
|
|
||||||
def runner_on_unreachable(self, host, res):
|
def v2_runner_on_unreachable(self, result):
|
||||||
|
res = result._result
|
||||||
|
host = result._host.get_name()
|
||||||
self.logger.error('%s ansible-command: task execution UNREACHABLE; host: %s; message: %s', self.hostname, host, self._dump_results(res))
|
self.logger.error('%s ansible-command: task execution UNREACHABLE; host: %s; message: %s', self.hostname, host, self._dump_results(res))
|
||||||
|
|
||||||
def runner_on_async_failed(self, host, res, jid):
|
def v2_runner_on_async_failed(self, result):
|
||||||
|
res = result._result
|
||||||
|
host = result._host.get_name()
|
||||||
|
jid = result._result.get('ansible_job_id')
|
||||||
self.logger.error('%s ansible-command: task execution FAILED; host: %s; message: %s', self.hostname, host, self._dump_results(res))
|
self.logger.error('%s ansible-command: task execution FAILED; host: %s; message: %s', self.hostname, host, self._dump_results(res))
|
||||||
|
|
||||||
def playbook_on_import_for_host(self, host, imported_file):
|
def v2_playbook_on_import_for_host(self, result, imported_file):
|
||||||
|
host = result._host.get_name()
|
||||||
self.logger.info('%s ansible-command: playbook IMPORTED; host: %s; message: imported file %s', self.hostname, host, imported_file)
|
self.logger.info('%s ansible-command: playbook IMPORTED; host: %s; message: imported file %s', self.hostname, host, imported_file)
|
||||||
|
|
||||||
def playbook_on_not_import_for_host(self, host, missing_file):
|
def v2_playbook_on_not_import_for_host(self, result, missing_file):
|
||||||
|
host = result._host.get_name()
|
||||||
self.logger.info('%s ansible-command: playbook NOT IMPORTED; host: %s; message: missing file %s', self.hostname, host, missing_file)
|
self.logger.info('%s ansible-command: playbook NOT IMPORTED; host: %s; message: missing file %s', self.hostname, host, missing_file)
|
||||||
|
|
Loading…
Reference in a new issue