Skip to content

Commit

Permalink
Bug ansible#11830, keep working even if we use private_networking
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcos Garcia committed Aug 2, 2015
1 parent cf35bdb commit 7bd1749
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion contrib/inventory/digital_ocean.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
- do_id
- do_image - object
- do_ip_address
- do_private_ip_address
- do_kernel - object
- do_locked
- de_memory
Expand Down Expand Up @@ -344,7 +345,15 @@ def build_inventory(self):

# add all droplets by id and name
for droplet in self.data['droplets']:
dest = droplet['ip_address']
#when using private_networking, the API reports the private one in "ip_address", which is useless. We need the public one for Ansible to work
if 'private_networking' in droplet['features']:
for net in droplet['networks']['v4']:
if net['type']=='public':
dest=net['ip_address']
else:
continue
else:
dest = droplet['ip_address']

self.inventory[droplet['id']] = [dest]
self.push(self.inventory, droplet['name'], dest)
Expand Down

0 comments on commit 7bd1749

Please sign in to comment.