I want to use ansible_runner to do some parsing on hosts. I have a script which gathers a list of hosts from a database and then I want to pass that list to ansible_runner python module without writing the "inventory" to disk.
I tried to do like this based on what I could understand from the documentation:
>> import ansible_runner
>> hostlist = ['host1', 'host2']
>>> r = ansible_runner.run(private_data_dir='.',inventory=hostlist, playbook='check_ping.yml')
I appears that each element in the list that I pass is taken as if it was an inventory file located in the inventory directory. I just would like to use the elements of the list as hosts to be used and in this case do a ping.
my question is how to pass to the ansible_runner python module an inventory variable whether is a json file, list, dictionary that it does not exists anywhere on disk? and let ansible connect to those.