Return useful error messages on requests exception
We need to be able to debug this. Change-Id: Ie20bc1293d80bbbd45479c12dd65314b27c61e40
This commit is contained in:
parent
c64119b530
commit
36916f8622
@ -120,10 +120,25 @@ def main():
|
||||
payload_dump = p['logfile'][:-4] + "facts_payload.json"
|
||||
with open(payload_dump, 'w') as f:
|
||||
f.write(json.dumps(payload))
|
||||
r = requests.post(endpoint, json=payload, **requests_kwargs)
|
||||
try:
|
||||
r = requests.post(endpoint, json=payload, **requests_kwargs)
|
||||
except Exception as e:
|
||||
module.fail_json(
|
||||
msg="Exception: {e}".format(e=e),
|
||||
puppetdb=p['puppetdb'],
|
||||
endpoint=endpoint,
|
||||
logfile=payload_dump)
|
||||
|
||||
log_data = json.load(open(p['logfile'], 'r'))
|
||||
r = requests.post(endpoint, json=log_data, **requests_kwargs)
|
||||
try:
|
||||
r = requests.post(endpoint, json=log_data, **requests_kwargs)
|
||||
except Exception as e:
|
||||
module.fail_json(
|
||||
msg="Exception: {e}".format(e=e),
|
||||
puppetdb=p['puppetdb'],
|
||||
endpoint=endpoint,
|
||||
logfile=p['logfile'])
|
||||
|
||||
if r.status_code != 200:
|
||||
module.fail_json(
|
||||
rc=r.status_code,
|
||||
|
Loading…
x
Reference in New Issue
Block a user