Provide more debug output on failures (#35961)

This PR includes:
- payload output on failure, when requested
- add additional kwargs to aci.exit_json()

We may want to enable some of this debug output by default on failure ?
This commit is contained in:
Dag Wieers 2018-02-09 17:06:59 +01:00 committed by GitHub
parent 80e1e0b017
commit 3693e560dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -918,7 +918,7 @@ class ACIModule(object):
self.result['changed'] = True
self.method = 'POST'
def exit_json(self):
def exit_json(self, **kwargs):
if self.params['output_level'] in ('debug', 'info'):
self.result['previous'] = self.existing
@ -947,6 +947,7 @@ class ACIModule(object):
self.result['sent'] = self.config
self.result['proposed'] = self.proposed
self.result.update(**kwargs)
self.module.exit_json(**self.result)
def fail_json(self, msg, **kwargs):
@ -955,6 +956,9 @@ class ACIModule(object):
if self.error['code'] is not None and self.error['text'] is not None:
self.result['error'] = self.error
if self.params['output_level'] in ('debug', 'info'):
self.result['previous'] = self.existing
# Return the gory details when we need it
if self.params['output_level'] == 'debug':
if self.imdata is not None:
@ -969,5 +973,9 @@ class ACIModule(object):
self.result['status'] = self.status
self.result['url'] = self.url
if self.params['output_level'] in ('debug', 'info'):
self.result['sent'] = self.config
self.result['proposed'] = self.proposed
self.result.update(**kwargs)
self.module.fail_json(msg=msg, **self.result)