Skip to content

Commit

Permalink
Fix exception when serializing results to json
Browse files Browse the repository at this point in the history
Fix the 'Object of type AnsibleVaultEncryptedUnicode is not JSON serializable'
exception when serializing the results to json.

This happens when executing make test TEST="tests/test_callback.py"

Signed-off-by: Ruediger Pluem <[email protected]>
rpluem-vf authored and evgeni committed Jan 29, 2025
1 parent 48aa035 commit cf9972a
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion plugins/callback/foreman.py
Original file line number Diff line number Diff line change
@@ -146,7 +146,7 @@ def build_log_foreman(data_list):
'source': task.get('name'),
},
'messages': {
'message': json.dumps(result, sort_keys=True),
'message': json.dumps(result, sort_keys=True, cls=AnsibleNoVaultJSONEncoder),
},
'level': level,
}
Original file line number Diff line number Diff line change
@@ -73,7 +73,7 @@
"log": {
"level": "info",
"messages": {
"message": "{\"ansible_facts\": {\"geheim\": \"admin\"}, \"changed\": false, \"failed\": false, \"module\": \"set_fact\"}"
"message": "{\"ansible_facts\": {\"crypt\": \"ENCRYPTED_VAULT_VALUE_NOT_REPORTED\", \"geheim\": \"admin\", \"unsafe\": \"THIS IS {{ crypt }}\\n\"}, \"changed\": false, \"failed\": false, \"module\": \"set_fact\"}"
},
"sources": {
"source": "Vault fact"

0 comments on commit cf9972a

Please sign in to comment.