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
Kasra Jamshidi
slapos.package
Commits
ddb01dec
Commit
ddb01dec
authored
8 years ago
by
Alain Takoudjou
Committed by
Rafael Monnerat
8 years ago
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 @@
...
@@ -2,8 +2,9 @@
import os
import os
import time
import time
import json
import json
from ansible.plugins.callback import CallbackBase
class CallbackModule(
object
):
class CallbackModule(
CallbackBase
):
"""
"""
logs playbook results, per host, in /var/log/ansible/hosts
logs playbook results, per host, in /var/log/ansible/hosts
"""
"""
...
@@ -12,6 +13,8 @@ class CallbackModule(object):
...
@@ -12,6 +13,8 @@ class CallbackModule(object):
def __init__(self):
def __init__(self):
super(CallbackModule, self).__init__()
if not os.path.exists(self.log_path):
if not os.path.exists(self.log_path):
os.makedirs(self.log_path)
os.makedirs(self.log_path)
else:
else:
...
@@ -21,6 +24,7 @@ class CallbackModule(object):
...
@@ -21,6 +24,7 @@ class CallbackModule(object):
os.unlink(filepath)
os.unlink(filepath)
def log(self, host, category, data, ignore_errors=False):
def log(self, host, category, data, ignore_errors=False):
if type(data) == dict:
if type(data) == dict:
if '_ansible_verbose_override' in data:
if '_ansible_verbose_override' in data:
# avoid logging extraneous data
# avoid logging extraneous data
...
@@ -30,7 +34,7 @@ class CallbackModule(object):
...
@@ -30,7 +34,7 @@ class CallbackModule(object):
data = json.dumps(data)
data = json.dumps(data)
if ignore_errors:
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))
path = os.path.join("/var/log/ansible/hosts", '%s_%s' % (host, category))
with open(path, "a") as fd:
with open(path, "a") as fd:
fd.write(data)
fd.write(data)
...
...
This diff is collapsed.
Click to expand it.
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