Ryan, I am facing the same issue as you. In your case you can actually reference your hosts from a play like this :
*hosts: hbase0:hbase1:hbase2 (and so on)* Which is not ideal but it does "work". In my case I need to create servers in DO and I need to reference them with groups like "prod" and "prod-appname". The solution I came up with involves making changes to the *digital_ocean.py* inventory script. The changes were quite simple and you can follow a similar approach. See here https://gist.github.com/boris317/5fc7bf6d003c7df3ae74 In your case you would do something like this: *if the droplet['name'].startswith('hbase'):* * self.push(self.inventory, "hbase", dest)* On Thursday, February 5, 2015 at 1:02:02 AM UTC-5, Ryan Rawson wrote: > > 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. > > The background here is I'm doing a little bit of a hbase thing. So I have > created some hosts using the digital ocean commands, but first I had to fix > the private networking bug ( > https://github.com/ansible/ansible-modules-core/pull/677) > > 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. > > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d18d7723-aedd-4254-9f9b-1901c6c4c409%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
