Hello
First question:
Is there any possibility to pass dynamic inventory as a pure json structure?
I have got a small app that is written in python and flask, that listen for
some data (finally it is in json format) from other system. Based on this
data I prepare _meta structure like below:
'hosts': {
'hosts': ['host001', 'host001'],
'vars': {
'var01': "value01",
}
},
'_meta': {
'hostvars': {
'host001': { 'var001' : "value02" },
'host002': { 'var002': "value03" }
}
}
Using this structure I'm creating inventory script
<https://docs.ansible.com/ansible/latest/dev_guide/developing_inventory.html#developing-inventory-scripts>
that returns above code. Than based on ansible Python API
<https://docs.ansible.com/ansible/latest/dev_guide/developing_api.html#python-api>
documentation I run ansible task using some playbook and inventory script.
In above documentation you can find: "# create inventory, use path to host
config file as source or hosts in a comma separated string inventory =
InventoryManager(loader=loader, sources=sources)"
And now is my question: is there any easy way to pass above inventory not
as a "/path/to/inventory_script" but as a pure json structure?
I have read about ansible-runner <https://github.com/ansible/ansible-runner>
project which can be simpler implementation of creating and runnning
ansible task (instead of pure API) but there I still have to pass
"/path/to/file" as inventory.
Now I'm reading about writing my own plugin for ansible but maybe there is
an easier way to do what I mentioned above. Maybe you have some other
suggestions.
Best Regards
Filip
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/02d060c1-1a7b-4ef6-ac99-03cae2e903can%40googlegroups.com.