@@ -167,6 +167,7 @@ def __init__(self):
167
167
# Define defaults
168
168
self .cache_path = '.'
169
169
self .cache_max_age = 0
170
+ self .use_private_network = False
170
171
171
172
# Read settings, environment variables, and CLI arguments
172
173
self .read_settings ()
@@ -256,6 +257,9 @@ def read_settings(self):
256
257
if config .has_option ('digital_ocean' , 'cache_max_age' ):
257
258
self .cache_max_age = config .getint ('digital_ocean' , 'cache_max_age' )
258
259
260
+ # Private IP Address
261
+ if config .has_option ('digital_ocean' , 'use_private_network' ):
262
+ self .use_private_network = config .get ('digital_ocean' , 'use_private_network' )
259
263
260
264
def read_environment (self ):
261
265
''' Reads the settings from environment variables '''
@@ -345,8 +349,8 @@ def build_inventory(self):
345
349
346
350
# add all droplets by id and name
347
351
for droplet in self .data ['droplets' ]:
348
- #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
349
- if 'private_networking' in droplet ['features' ]:
352
+ #when using private_networking, the API reports the private one in "ip_address".
353
+ if 'private_networking' in droplet ['features' ] and not self . use_private_network :
350
354
for net in droplet ['networks' ]['v4' ]:
351
355
if net ['type' ]== 'public' :
352
356
dest = net ['ip_address' ]
0 commit comments