Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Commit

Permalink
Accepts service account definition the created VM
Browse files Browse the repository at this point in the history
  • Loading branch information
nkakouros committed May 23, 2022
1 parent 9d8866c commit 0a45b0c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/molecule_gce/playbooks/tasks/create_linux_instance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@
access_configs: "{{ [{'name': 'instance_ip', 'type': 'ONE_TO_ONE_NAT'}] if molecule_yml.driver.external_access else [] }}"
tags: "{{ item.tags | default(omit) }}"
zone: "{{ item.zone | default(molecule_yml.driver.region + '-b') }}"
service_accounts: >-
[
{% for account in molecule_yml.driver.service_accounts | d([]) %}
{
{% if account.email == 'same-as-driver' and molecule_yml.driver.service_account_email is defined %}
'email': '{{ molecule_yml.driver.service_account_email }}',
{% elif account.email == 'same-as-driver' and molecule_yml.driver.service_account_file is defined %}
'email': '{{ (lookup('file', molecule_yml.driver.service_account_file) | from_json)['client_email'] }}',
{% else %}
'email': '{{ account.email }}',
{% endif %}
{% if account.scopes is defined %}
'scopes': {{ account.scopes }},
{% endif %}
},
{% endfor %}
]
project: "{{ gcp_project_id }}"
scopes: "{{ molecule_yml.driver.scopes | default(['https://www.googleapis.com/auth/compute'], True) }}"
service_account_email: "{{ molecule_yml.driver.service_account_email | default (omit, true) }}"
Expand Down

0 comments on commit 0a45b0c

Please sign in to comment.