Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.package
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Romain Courteaud
slapos.package
Commits
ddb01dec
Commit
ddb01dec
authored
Jun 16, 2016
by
Alain Takoudjou
Committed by
Rafael Monnerat
Jun 23, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Ansible log_parse callback plugins compatible with version 2
parent
76b94485
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
playbook/roles/install-script/files/log_parse
playbook/roles/install-script/files/log_parse
+6
-2
No files found.
playbook/roles/install-script/files/log_parse
View file @
ddb01dec
...
...
@@ -2,8 +2,9 @@
import os
import time
import json
from ansible.plugins.callback import CallbackBase
class CallbackModule(
object
):
class CallbackModule(
CallbackBase
):
"""
logs playbook results, per host, in /var/log/ansible/hosts
"""
...
...
@@ -12,6 +13,8 @@ class CallbackModule(object):
def __init__(self):
super(CallbackModule, self).__init__()
if not os.path.exists(self.log_path):
os.makedirs(self.log_path)
else:
...
...
@@ -21,6 +24,7 @@ class CallbackModule(object):
os.unlink(filepath)
def log(self, host, category, data, ignore_errors=False):
if type(data) == dict:
if '_ansible_verbose_override' in data:
# avoid logging extraneous data
...
...
@@ -30,7 +34,7 @@ class CallbackModule(object):
data = json.dumps(data)
if ignore_errors:
category = '%s_I
NG
ORED' % category
category = '%s_I
GN
ORED' % category
path = os.path.join("/var/log/ansible/hosts", '%s_%s' % (host, category))
with open(path, "a") as fd:
fd.write(data)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment