mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 19:31:26 -07:00
parent
de18bcb95f
commit
5d3d9cfe0d
3 changed files with 29 additions and 18 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue