From 3c6c7bae9d66ae58c3609b0b33abe8dfb38b89a4 Mon Sep 17 00:00:00 2001 From: Alex Stephen Date: Thu, 30 Aug 2018 10:27:29 -0400 Subject: [PATCH] Allow home path expansion on GCP service account files (#44863) * Allowing home path expansion on GCP service account files #42974 * wrong name for changelog --- changelogs/fragments/gcp_service_account_home_path.yaml | 2 ++ lib/ansible/module_utils/gcp_utils.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/gcp_service_account_home_path.yaml diff --git a/changelogs/fragments/gcp_service_account_home_path.yaml b/changelogs/fragments/gcp_service_account_home_path.yaml new file mode 100644 index 0000000000..8d9523ff93 --- /dev/null +++ b/changelogs/fragments/gcp_service_account_home_path.yaml @@ -0,0 +1,2 @@ +minor_changes: + - GCP Modules will do home path expansion on service account file paths diff --git a/lib/ansible/module_utils/gcp_utils.py b/lib/ansible/module_utils/gcp_utils.py index 584a6d14f6..cea381d027 100644 --- a/lib/ansible/module_utils/gcp_utils.py +++ b/lib/ansible/module_utils/gcp_utils.py @@ -129,8 +129,8 @@ class GcpSession(object): credentials, project_id = google.auth.default() return credentials elif cred_type == 'serviceaccount': - return service_account.Credentials.from_service_account_file( - self.module.params['service_account_file']) + path = os.path.realpath(os.path.expanduser(self.module.params['service_account_file'])) + return service_account.Credentials.from_service_account_file(path) elif cred_type == 'machineaccount': return google.auth.compute_engine.Credentials( self.module.params['service_account_email'])