Updating an object that exists within ansible_facts across modules

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

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