From 03f09cc6adc32fa85b29f442735f7e78d2097d03 Mon Sep 17 00:00:00 2001 From: dprehn Date: Sun, 17 Dec 2023 17:52:46 -0500 Subject: [PATCH] fixed calling windows_auth.py for application auth --- .../gce/playbooks/tasks/create_windows_instance.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/molecule_plugins/gce/playbooks/tasks/create_windows_instance.yml b/src/molecule_plugins/gce/playbooks/tasks/create_windows_instance.yml index 57ba741f..755ab3ab 100644 --- a/src/molecule_plugins/gce/playbooks/tasks/create_windows_instance.yml +++ b/src/molecule_plugins/gce/playbooks/tasks/create_windows_instance.yml @@ -51,6 +51,15 @@ delay: 10 loop: "{{ server.results }}" +- name: Set env vars for auth script + ansible.builtin.set_fact: + script_env_vars: + GOOGLE_APPLICATION_CREDENTIALS: "{{ service_account_file }}" + vars: + auth_kind: "{{ molecule_yml.driver.auth_kind | default(lookup('env', 'GCP_AUTH_KIND')) }}" + service_account_file: "{{ molecule_yml.driver.service_account_file | default(lookup('env', 'GCP_SERVICE_ACCOUNT_FILE'), true) }}" + when: auth_kind == 'serviceaccount' + - name: Prepare Windows User ansible.builtin.script: > ./files/windows_auth.py @@ -60,8 +69,7 @@ --username molecule_usr args: executable: python3 - environment: - GOOGLE_APPLICATION_CREDENTIALS: "{{ molecule_yml.driver.service_account_file | default(lookup('env', 'GCP_SERVICE_ACCOUNT_FILE'), true) }}" + environment: "{{ script_env_vars | default({}) }}" loop: "{{ molecule_yml.platforms }}" changed_when: - password.rc == 0