Ability to run a playbook against a list of hosts not in inventory is implemented

It is a likely cloud bootstrapping use case to want to run a playbook against a list of newly provisioned hosts and those hosts may have not been added to /etc/ansible/hosts just yet. You may also have no wish to ever add those hosts to inventory. For example, you might be spinning up some VMs from a software management system and never really want to manage them with Ansible again. Heck, you could be using another configuration management system and want to use Ansible to bootstrap that. This would be really sad, but I want to make it possible.

So, I’ve made it such that the host does not need to be in the inventory file when using “-O” (–override-hosts) with /usr/bin/ansible-playbook.

It looks like this:

ansible-playbook foo.playbook -O “newhost.example.org,newhost2.example.org

The option is uppercase to indicate you are doing something especially weird :slight_smile:

When using --override-hosts, patterns (“hosts:”) in the playbook file will be ignored (meaning the host will be treated as if it were matched by all patterns), and existing hosts in the inventory file will also be ignored. External variable scripts (external inventory) will also not be consulted, even for variables, because if you had the host in inventory, you wouldn’t be using “-O”. This also means you can technically omit the “host:” line from the playbook, though without “-o”, Ansible will warn about this.

I have not added a similar option to /bin/ansible, as I’m trying to keep the amount of options sane, and don’t want to confuse the CLI option design, or the user documentation. For this reason, we probably won’t mention this in the man docs and just leave it in the manpage docs. It’s for niche cases anyway.

–Michael

Hi
How about the ability to specify a database connection and query rather than a config file?

Regards

This has already been done.

http://ansible.github.com/api.html#external-inventory

Cool!