From 77b54a32675cf753cd2b3a79aa3b1502316c49b6 Mon Sep 17 00:00:00 2001 From: Alex Stephen Date: Thu, 7 Jun 2018 21:05:58 +0000 Subject: [PATCH] GCP Inventory Plugin scopes fix --- lib/ansible/module_utils/gcp_utils.py | 3 +++ lib/ansible/plugins/inventory/gcp_compute.py | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/gcp_utils.py b/lib/ansible/module_utils/gcp_utils.py index d61ecac19b5..8bc6d92d52c 100644 --- a/lib/ansible/module_utils/gcp_utils.py +++ b/lib/ansible/module_utils/gcp_utils.py @@ -106,6 +106,9 @@ class GcpSession(object): if not HAS_GOOGLE_LIBRARIES: self.module.fail_json(msg="Please install the google-auth library") + if 'auth_kind' not in self.module.params: + self.module.fail_json(msg="Auth kind parameter is missing") + if self.module.params.get('service_account_email') is not None and self.module.params['auth_kind'] != 'machineaccount': self.module.fail_json( msg="Service Acccount Email only works with Machine Account-based authentication" diff --git a/lib/ansible/plugins/inventory/gcp_compute.py b/lib/ansible/plugins/inventory/gcp_compute.py index c395ac62fff..7396c5f5c01 100644 --- a/lib/ansible/plugins/inventory/gcp_compute.py +++ b/lib/ansible/plugins/inventory/gcp_compute.py @@ -12,7 +12,6 @@ DOCUMENTATION = ''' - requests >= 2.18.4 - google-auth >= 1.3.0 extends_documentation_fragment: - - gcp - constructed - inventory_cache description: @@ -35,6 +34,16 @@ DOCUMENTATION = ''' hostnames should be assigned. Currently supported hostnames are 'public_ip', 'private_ip', or 'name'. default: ['public_ip', 'private_ip', 'name'] + auth_kind: + description: + - The type of credential used. + service_account_file: + description: + - The path of a Service Account JSON file if serviceaccount is selected as type. + service_account_email: + description: + - An optional service account email address if machineaccount is selected + and the user does not wish to use the default email. ''' EXAMPLES = '''