# outputting result of boto call

**URL:** <https://forum.ansible.com/t/outputting-result-of-boto-call/20910>\
**Category:** Ansible Developer\
**Created:** [March 17, 2016, 11:39pm UTC](https://forum.ansible.com/t/outputting-result-of-boto-call/20910 "2016-03-17T23:39:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Baydoun](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@Michael\_Baydoun](https://forum.ansible.com/u/Michael_Baydoun)\
**Post date:** [March 17, 2016, 11:39pm UTC](https://forum.ansible.com/t/outputting-result-of-boto-call/20910/1 "2016-03-17T23:39:27Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![willthames](https://avatars.discourse-cdn.com/v4/letter/w/8dc957/32.png) [@willthames](https://forum.ansible.com/u/willthames)\
**Post date:** [March 22, 2016, 1:45am UTC](https://forum.ansible.com/t/outputting-result-of-boto-call/20910/2 "2016-03-22T01:45:11Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Jonathan\_Davila](https://avatars.discourse-cdn.com/v4/letter/j/e0b2c6/32.png) [@Jonathan\_Davila](https://forum.ansible.com/u/Jonathan_Davila)\
**Post date:** [March 22, 2016, 5:29pm UTC](https://forum.ansible.com/t/outputting-result-of-boto-call/20910/3 "2016-03-22T17:29:17Z")

</div>

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
