I want to run Ansible in Python without specifying the inventory file through (ANSIBLE_HOST) but just by:
ansible.run.Runner(
module_name='ping',
host='www.google.com'
)
I can actually do this in fabric easily but just wonder how to do this in Python. On the other hand, documentation of the Ansible API for python is not really complete.
Surprisingly, the trick is to append a ,
# Host and IP address
ansible all -i example.com,
ansible all -i 93.184.216.119,
or
# Requires 'hosts: all' in your playbook
ansible-playbook -i example.com, playbook.yml
The host parameter preceding the ,
can be either a hostname or an IPv4/v6 address.