diff --git a/lib/ansible/modules/extras/cloud/google/gce_img.py b/lib/ansible/modules/extras/cloud/google/gce_img.py index 270ae827ddf..031539bf5f4 100644 --- a/lib/ansible/modules/extras/cloud/google/gce_img.py +++ b/lib/ansible/modules/extras/cloud/google/gce_img.py @@ -166,7 +166,8 @@ def create_image(gce, name, module): return True except ResourceExistsError: return False - except GoogleBaseError, e: + except GoogleBaseError: + e = get_exception() module.fail_json(msg=str(e), changed=False) finally: gce.connection.timeout = old_timeout diff --git a/lib/ansible/modules/extras/cloud/google/gce_tag.py b/lib/ansible/modules/extras/cloud/google/gce_tag.py index cb1f2a2c3ed..8f280a9ef30 100644 --- a/lib/ansible/modules/extras/cloud/google/gce_tag.py +++ b/lib/ansible/modules/extras/cloud/google/gce_tag.py @@ -156,7 +156,8 @@ def remove_tags(gce, module, instance_name, tags): node = gce.ex_get_node(instance_name, zone=zone) except ResourceNotFoundError: module.fail_json(msg='Instance %s not found in zone %s' % (instance_name, zone), changed=False) - except GoogleBaseError, e: + except GoogleBaseError: + e = get_exception() module.fail_json(msg=str(e), changed=False) node_tags = node.extra['tags']