So I am doing a digital ocean thing. I saw the dynamic inventory scripts and thought my problems were solved. But turns out, it only covers the simplest case and doesn't help you further.
So I create my hosts with a standalone playbook:
---
- hosts: localhost
vars:
ssh_keys: 1234
connection: local
tasks:
- name: create droplets
digital_ocean: >
state=present
wait=no
private_networking=true
command=droplet
name={{ item }}
unique_name=yes
size_id=65
region_id=8
ssh_key_ids="{{ ssh_keys }}"
image_id=9801950
with_items:
- hbase0
- hbase1
- hbase2
- hbase3
- hbase4
- hbase5
- hbase6
- hbase7
- hbase8
And this seems to work. So I have 9 hosts, hooray!
I can even do:
ansible hbase0 -i digital_ocean.py -m ping
and i can ping just that 1 host
and I can do:
ansible all -i digital_ocean.py -m ping
and that works. And that's great.
But now I need to do groups. Since this is HBase, we need some hosts to be slightly different than other hosts. Pretty standard ansible stuff.
So I will:
mkdir inventory
cp digital_ocean.py inventory
vim inventory/groups
And put stuff in this new 'groups' file.
Except that it's nearly impossible to do anything smart here.
Some facts:
- you can't use 'host names' -- do_name, or ansible_hostname in the facts
- you can't use globs: hbase[0:8]
- you can't really identify these 9 servers via anything other than their size, or their image id. No tags - digital ocean's fault here, but still.
- you might be able to use raw IP addresses, but I don't know which IP is hbase0.
So I gave up on digital_ocean.py. I now generate a file i can paste into /etc/hosts, and use raw names hbase0, hbase1, etc, in a static file. Basically I use dynamic inventory for generating the data I use to drive static hosts.
I have tried googling, asking irc. As far as I can tell, if anyone else has a similar problem, google doesn't know.
In the mean time, I am back using static inventory.