summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrmarsa <rlmarsa@mac.com>2017-01-18 13:13:59 -0600
committerRyan Brown <sb@ryansb.com>2017-01-18 14:13:59 -0500
commit32f39a195befdc0a656cbaf8f3ce287a12e0246a (patch)
tree47893cd438886f7592180ff11ceb603e47af833a
parentd3c17d632b23e4ce5552e43e44b91ee138fc6aa4 (diff)
downloadansible-32f39a195befdc0a656cbaf8f3ce287a12e0246a.tar.gz
Fixed bug where it was impossible to set non-ephemeral external ips. (#19701)
* Fixed bug where it was impossible to set non-ephemeral external ips. * Fixed variable reference.
-rw-r--r--lib/ansible/modules/cloud/google/gce.py21
1 files changed, 9 insertions, 12 deletions
diff --git a/lib/ansible/modules/cloud/google/gce.py b/lib/ansible/modules/cloud/google/gce.py
index 6c95b6eeb8..2fd855bcbe 100644
--- a/lib/ansible/modules/cloud/google/gce.py
+++ b/lib/ansible/modules/cloud/google/gce.py
@@ -155,7 +155,7 @@ options:
external_ip:
version_added: "1.9"
description:
- - type of external ip, ephemeral by default; alternatively, a list of fixed gce ips or ip names can be given (if there is not enough specified ip, 'ephemeral' will be used). Specify 'none' if no external ip is desired.
+ - type of external ip, ephemeral by default; alternatively, a fixed gce ip or ip name can be given. Specify 'none' if no external ip is desired.
required: false
default: "ephemeral"
disk_auto_delete:
@@ -397,18 +397,15 @@ def create_instances(module, gce, instance_names, number):
if external_ip == "none":
instance_external_ip = None
- elif not isinstance(external_ip, basestring):
+ elif external_ip != "ephemeral":
+ instance_external_ip = external_ip
try:
- if len(external_ip) != 0:
- instance_external_ip = external_ip.pop(0)
- # check if instance_external_ip is an ip or a name
- try:
- socket.inet_aton(instance_external_ip)
- instance_external_ip = GCEAddress(id='unknown', name='unknown', address=instance_external_ip, region='unknown', driver=gce)
- except socket.error:
- instance_external_ip = gce.ex_get_address(instance_external_ip)
- else:
- instance_external_ip = 'ephemeral'
+ # check if instance_external_ip is an ip or a name
+ try:
+ socket.inet_aton(instance_external_ip)
+ instance_external_ip = GCEAddress(id='unknown', name='unknown', address=instance_external_ip, region='unknown', driver=gce)
+ except socket.error:
+ instance_external_ip = gce.ex_get_address(instance_external_ip)
except GoogleBaseError as e:
module.fail_json(msg='Unexpected error attempting to get a static ip %s, error: %s' % (external_ip, e.value))
else: