Supply missing error message on S3 upload failure
The `fail_json()` method of the Ansible module expects a msg argument. https://docs.ansible.com/ansible/latest/reference_appendices/module_utils.html Traceback (most recent call last): File \\"<stdin>\\", line 102, in <module> File \\"<stdin>\\", line 94, in _ansiballz_main File \\"<stdin>\\", line 40, in invoke_module File \\"/usr/local/lib/python3.10/runpy.py\\", line 224, in run_module return _run_module_code(code, init_globals, run_name, mod_spec) File \\"/usr/local/lib/python3.10/runpy.py\\", line 96, in _run_module_code _run_code(code, mod_globals, init_globals, File \\"/usr/local/lib/python3.10/runpy.py\\", line 86, in _run_code exec(code, run_globals) File \\"/var/cache/zuul-executor/jobs/2f077ccd11b844e587a4d220ed22f36c/work/tmp/ansible_zuul_s3_upload_payload_l3h9evxc/ansible_zuul_s3_upload_payload.zip/ansible/modules/zuul_s3_upload.py\\", line 366, in <module> File \\"/var/cache/zuul-executor/jobs/2f077ccd11b844e587a4d220ed22f36c/work/tmp/ansible_zuul_s3_upload_payload_l3h9evxc/ansible_zuul_s3_upload_payload.zip/ansible/modules/zuul_s3_upload.py\\", line 313, in ansible_main File \\"/var/cache/zuul-executor/jobs/2f077ccd11b844e587a4d220ed22f36c/work/tmp/ansible_zuul_s3_upload_payload_l3h9evxc/ansible_zuul_s3_upload_payload.zip/ansible/module_utils/basic.py\\", line 2183, in fail_json AssertionError: implementation error -- msg to explain the error is required Change-Id: I30a50ebd3c4a2553142a67ecb1bbb1faa2b3c527
This commit is contained in:
parent
2bc6d7b9c3
commit
f2ccc45c06
@ -27,6 +27,7 @@ Utility to upload files to s3
|
||||
import argparse
|
||||
import logging
|
||||
import os
|
||||
import pprint
|
||||
try:
|
||||
import queue as queuelib
|
||||
except ImportError:
|
||||
@ -259,7 +260,9 @@ def ansible_main():
|
||||
aws_access_key=p.get('aws_access_key'),
|
||||
aws_secret_key=p.get('aws_secret_key'))
|
||||
if failures:
|
||||
module.fail_json(changed=True,
|
||||
failure_msg = pprint.pformat(failures)
|
||||
module.fail_json(msg=f"Failure(s) during log upload:\n{failure_msg}",
|
||||
changed=True,
|
||||
url=url,
|
||||
failures=failures)
|
||||
module.exit_json(changed=True,
|
||||
|
Loading…
Reference in New Issue
Block a user