I am using this:
Specify docker containers in /etc/ansible/hosts file
to run my ansible playbooks against a docker container.
But is there any way to avoid having a physical /etc/ansible/hosts
file with the information about the container? E.g. run it from code where this information can be configured?
I looked at:
Running ansible-playbook using Python API
but when looking at the answers I see variables pointing to physical files, e.g.:
inventory = Inventory(loader=loader, sources='/home/slotlocker/hosts2')
playbook_path = '/home/slotlocker/ls.yml'
So not really sure why that is better than simply just calling from command line without using the Python ansible API.