Generating Lists & Dictionaries on the fly? Is it possible?

Hey,

I’m interested in generating variables/facts on the fly. I want to gather those facts from the server and put them into an iteratable list of dictionaries.

Is it possible?

I know about register. But I don’t know how to create dicts by using it.

Is there a filter that can get a JAML/JSON input and convert it into an ansible friendly data structure?

Any ideas of how should I approach this?

Thanks.

I’d like to understand more about the use case first, before making suggestions about what you should do.

Can you walk me through what the end user scenario of things you are doing is (i.e. the why, not the how)?

Hey,

I want to fetch some internal data that was generated by some of our apps. The data can be stored in files.

Thanks.

What do you want to do with that data?

What format is that data in, etc?

Hey again,

I want to allocate resources dynamically on the php-fpm pools.

I can provide the data in whatever way needed. The app that provides the data was coded inhouse, so I basically can do whatever format that is needed.

Thanks.

If you want to absorb some data about the remote system into your application, I would look into writing a custom fact module.

See the “module development” page for details.

Thanks for the answer. I’ll check it out.

Regarding generating lists & dictionaries on the fly. Maybe merging dicts/lists? Is it possible?

Thanks.

There’s some ability to merge variables in inventory together via the merge_behavior setting in ansible.cfg, but it’s limited.