How to run Ansible without specifying the inventory but the host directly?

Question:

I want to run Ansible in Python without specifying the inventory file through (ANSIBLE_HOST) but just by:

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.

Answer:

Surprisingly, the trick is to append a ,

or

The host parameter preceding the , can be either a hostname or an IPv4/v6 address.

Leave a Reply