gce_instance_template: fix allow the setting of the service account (#29154)

pull/31789/head
evancarter-iex 7 years ago committed by René Moser
parent 01b6c7c9c6
commit d6520c64b3

@ -290,6 +290,7 @@ def create_instance_template(module, gce):
external_ip = module.params.get('external_ip') external_ip = module.params.get('external_ip')
service_account_permissions = module.params.get( service_account_permissions = module.params.get(
'service_account_permissions') 'service_account_permissions')
service_account_email = module.params.get('service_account_email')
on_host_maintenance = module.params.get('on_host_maintenance') on_host_maintenance = module.params.get('on_host_maintenance')
automatic_restart = module.params.get('automatic_restart') automatic_restart = module.params.get('automatic_restart')
preemptible = module.params.get('preemptible') preemptible = module.params.get('preemptible')
@ -369,7 +370,10 @@ def create_instance_template(module, gce):
bad_perms.append(perm) bad_perms.append(perm)
if len(bad_perms) > 0: if len(bad_perms) > 0:
module.fail_json(msg='bad permissions: %s' % str(bad_perms)) module.fail_json(msg='bad permissions: %s' % str(bad_perms))
ex_sa_perms.append({'email': "default"}) if service_account_email is not None:
ex_sa_perms.append({'email': str(service_account_email)})
else:
ex_sa_perms.append({'email': "default"})
ex_sa_perms[0]['scopes'] = service_account_permissions ex_sa_perms[0]['scopes'] = service_account_permissions
gce_args['service_accounts'] = ex_sa_perms gce_args['service_accounts'] = ex_sa_perms

Loading…
Cancel
Save