From a4077537e00169364ba9fb9e500f9d62433bd760 Mon Sep 17 00:00:00 2001 From: Tom Melendez Date: Thu, 13 Oct 2016 05:33:13 -0700 Subject: [PATCH] Added libcloud guard for Managed Instance Groups. (#4911) --- lib/ansible/modules/cloud/google/gce_mig.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/cloud/google/gce_mig.py b/lib/ansible/modules/cloud/google/gce_mig.py index 7762eaed23f..bb44be1f25b 100644 --- a/lib/ansible/modules/cloud/google/gce_mig.py +++ b/lib/ansible/modules/cloud/google/gce_mig.py @@ -596,7 +596,6 @@ def get_mig(gce, name, zone): def main(): - module = AnsibleModule(argument_spec=dict( name=dict(required=True), template=dict(), @@ -619,7 +618,13 @@ def main(): msg="GCE module requires python's 'ast' module, python v2.6+") if not HAS_LIBCLOUD: module.fail_json( - msg='libcloud with GCE Managed Instance Group support (1.1+) required for this module.') + msg='libcloud with GCE Managed Instance Group support (1.2+) required for this module.') + + gce = gce_connect(module) + if not hasattr(gce, 'ex_create_instancegroupmanager'): + module.fail_json( + msg='libcloud with GCE Managed Instance Group support (1.2+) required for this module.', + changed=False) params = {} params['state'] = module.params.get('state') @@ -634,7 +639,6 @@ def main(): if not valid_autoscaling: module.fail_json(msg=as_msg, changed=False) - gce = gce_connect(module) changed = False json_output = {'state': params['state'], 'zone': params['zone']} mig = get_mig(gce, params['name'], params['zone'])