Skip to content

Commit dadf37e

Browse files
Update log handling in playbooks and mock data for JSON compatibility (#34)
1 parent a9a5bf4 commit dadf37e

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,3 +406,5 @@ FodyWeavers.xsd
406406
WORKSPACES/*
407407
.ppk
408408
VMWPASSWORD
409+
.coverage.*
410+
*.ini

src/roles/misc/tasks/post-validations-db.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@
1919
{{
2020
(
2121
hostvars[cluster_status_pre.primary_node]['var_log_messages_output'].filtered_logs
22-
| default([])
22+
| default('[]')
23+
| from_json
2324
)
2425
+
2526
(
2627
hostvars[cluster_status_pre.secondary_node]['var_log_messages_output'].filtered_logs
27-
| default([])
28+
| default('[]')
29+
| from_json
2830
)
2931
}}
3032

src/roles/misc/tasks/post-validations-scs.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@
1919
{{
2020
(
2121
hostvars[cluster_status_pre.ascs_node]['var_log_messages_output'].filtered_logs
22-
| default([])
22+
| default('[]')
23+
| from_json
2324
)
2425
+
2526
(
2627
hostvars[cluster_status_pre.ers_node]['var_log_messages_output'].filtered_logs
27-
| default([])
28+
| default('[]')
29+
| from_json
2830
)
2931
}}
3032

src/roles/misc/tasks/rescue.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
{{
2222
(
2323
hostvars[first_node]['var_log_messages_output'].filtered_logs
24-
| default([])
24+
| default('[]')
25+
| from_json
2526
)
2627
+
2728
(
2829
hostvars[second_node]['var_log_messages_output'].filtered_logs
29-
| default([])
30+
| default('[]')
31+
| from_json
3032
)
3133
}}
3234

tests/roles/mock_data/log_parser.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/python3
22
# -*- coding: utf-8 -*-
33

4+
import json
45
from ansible.module_utils.basic import AnsibleModule
56

67
def main():
@@ -17,7 +18,7 @@ def main():
1718
# Return a mock cluster status
1819
module.exit_json(
1920
changed=False,
20-
filtered_logs=["Mock log entry 1", "Mock log entry 2"],
21+
filtered_logs=json.dumps(["Mock log entry 1", "Mock log entry 2"]),
2122
status="PASSED",
2223
keywords=module.params['keywords'],
2324
start_time=module.params['start_time'],

0 commit comments

Comments
 (0)