mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00:00
@@ -19,6 +19,7 @@ import os
|
||||
import time
|
||||
import json
|
||||
|
||||
from ansible.utils.unicode import to_bytes
|
||||
from ansible.plugins.callback import CallbackBase
|
||||
|
||||
# NOTE: in Ansible 1.2 or later general logging is available without
|
||||
@@ -60,9 +61,10 @@ class CallbackModule(CallbackBase):
|
||||
|
||||
path = os.path.join("/var/log/ansible/hosts", host)
|
||||
now = time.strftime(self.TIME_FORMAT, time.localtime())
|
||||
fd = open(path, "a")
|
||||
fd.write(self.MSG_FORMAT % dict(now=now, category=category, data=data))
|
||||
fd.close()
|
||||
|
||||
msg = to_bytes(self.MSG_FORMAT % dict(now=now, category=category, data=data))
|
||||
with open(path, "ab") as fd:
|
||||
fd.write(msg)
|
||||
|
||||
def runner_on_failed(self, host, res, ignore_errors=False):
|
||||
self.log(host, 'FAILED', res)
|
||||
|
||||
Reference in New Issue
Block a user