I have a simple inventory in hosts
:
dockermachine ansible_host=10.10.10.10
I need to be able to provide any other IP I wish from the command line, overwriting the default, something like:
ansible-playbook -i hosts@dockermachine.ansible_host=11.11.11.11 site.yml
How can I do this?
If your inventory is really that simple, you can probably live without the hostname. Remove the entry from your current default inventory. Make sure your playbook is targeted against the all
group and launch your playbook with a single host ip inventory:
ansible-playbook -i 10.10.10.11, my_playbook.yml
Note: the trailing comma after the IP is not a mistake, it needs to be there so that the IP after -i
parameter is interpreted as a comma separated list of hosts and not as an inventory file path.