# Updating an object that exists within ansible\_facts across modules

**URL:** <https://forum.ansible.com/t/updating-an-object-that-exists-within-ansible-facts-across-modules/20051>\
**Category:** Ansible Project\
**Created:** [December 20, 2015, 12:52pm UTC](https://forum.ansible.com/t/updating-an-object-that-exists-within-ansible-facts-across-modules/20051 "2015-12-20T12:52:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_Edelman](https://avatars.discourse-cdn.com/v4/letter/j/c37758/32.png) [@Jason\_Edelman](https://forum.ansible.com/u/Jason_Edelman)\
**Post date:** [December 20, 2015, 12:52pm UTC](https://forum.ansible.com/t/updating-an-object-that-exists-within-ansible-facts-across-modules/20051/1 "2015-12-20T12:52:11Z")

</div>

Hi,

I’m looking to return ansible\_facts from multiple modules but have the results be updated to be in a common value within ansible\_facts. (just like ansible\_facts already does)

For example, in module 1, I want to have;

results = {}  
results[‘nxos’] = dict(neighbors=neighbors)  
module.exit\_json(ansible\_facts=results)

and module 2, I’d like to have:

results = {}  
results[‘nxos’] = dict(interfaces=interfaces)  
module.exit\_json(ansible\_facts=results)

But it seems the second overwrites the first so I’m just left with nxos having a single key which is interfaces. Is it possible to _update_ the ‘nxos’ dictionary in this example and not treat it as a new object? Clearly, I can just use ansible\_facts, but it would be preferred to keep them within the same “key” here.

Or is there another way to accomplish this?

Thanks,  
Jason

---

<div class="post-metadata">

**Author:** ![psprygada](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@psprygada](https://forum.ansible.com/u/psprygada)\
**Post date:** [December 21, 2015, 3:28am UTC](https://forum.ansible.com/t/updating-an-object-that-exists-within-ansible-facts-across-modules/20051/2 "2015-12-21T03:28:26Z")

</div>

Hi Jason,

No way to do what you are asking for today. You would have to build a “running fact” in the playbook to achieve this. I think the better and more preferred way would be to prepend your facts (nxos\_neighbors, nxos\_interfaces, etc).

Peter
