outputting result of boto call

Writing my first module, first python, first use of boto.
Running my module via test-module, almost works, but to troubleshoot I need to see what a boto call is returning.

My boto call below. How can I “print” gacg without test-module complaining it’s not json?

gacg = c.get_all_customer_gateways(customer_gateway_ids=None, filters=None, dry_run=False)

You could use a debugger just after that line by including the following
import pdb
pdb.set_trace()

and then print gacg at the debug point

Or if you’re just trying to see what it’s returning for development purposes, module.exit_json(**gacg) assuming gacg is a dict (and module.fail_json(msg=gacg) should work otherwise)

Cpl things, if you’re planning to contribute, it should be boto3 not boto that you use. And for module dev this is a ‘trick’ that I use is to code like this

`
def main():
if ‘–interactive’ in sys.argv:

early import the module and reset the complex args

import ansible.module_utils.basic
ansible.module_utils.basic.MODULE_COMPLEX_ARGS = json.dumps(dict(
param1=‘foo’,
param2=‘bar’,
state=‘present’
))

module = AnsibleModule(argument_spec=dict(
param1=dict(required=True, type=‘str’),
param2=dict(required=False, type=‘str’),
state=dict(required=True, type=‘str’),
)

`

Simply place that right below def main() and make sure to still instantiate your AnsibleModule() object below just like above

then you can execute the module directly via

python modulefile.py --interactive

And now you can do print style debugging or any other output based debug stuff, including Will’s suggestion