# pass objects between modules

**URL:** <https://forum.ansible.com/t/pass-objects-between-modules/12042>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [October 27, 2012, 8:52pm UTC](https://forum.ansible.com/t/pass-objects-between-modules/12042 "2012-10-27T20:52:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [October 27, 2012, 8:52pm UTC](https://forum.ansible.com/t/pass-objects-between-modules/12042/1 "2012-10-27T20:52:18Z")

</div>

In general, modules take simple key=value pairs as arguments.

However, they return JSON. It's generally best to pass on just what  
you need in particular.

Here is a trivial example of accessing variables from previous commands.

- command: /usr/bin/uptime  
&nbsp;&nbsp;register: uptime\_result

- command: echo Hi I have been up for ${uptime\_result.stdout}

You can also get an entire variable result inside a template by doing:

{{ uptime\_result | to\_json }}

So should you want to really write a module that requires structured  
inputs there are workarounds. In general though, while variables do  
allow all the structure you want in the world, we strive to have all  
the core modules have a really simple interface and not need to define  
nested data structures to use them.

Hope that answers the question!
