mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-23 10:51:24 -07:00
GCP Inventory Plugin (#36884)
* Inventory * Adding multi project support * Adding multi project support * Fixing PR comments and cleaning code * Adding cache support * Changed filter notation * Inventory changes * Better readability for zones, networks, subnetworks * Added project to inventory output * Using IP instead of hostname * Keyed_groups support * Use all zones when none provided. * PR changes * Doc changes * Accepts *gcp_compute.yaml file names * Added support for changing host naming precedent * PR changes round 2 * Cache changes * Changed verify_file function * Misc style changes * Cache fixes * Fix docs for `hostnames` option.
This commit is contained in:
parent
cba64f5869
commit
dc31809d2a
2 changed files with 355 additions and 4 deletions
|
@ -70,9 +70,10 @@ class GcpSession(object):
|
|||
self.product = product
|
||||
self._validate()
|
||||
|
||||
def get(self, url, body=None):
|
||||
def get(self, url, body=None, **kwargs):
|
||||
kwargs.update({'json': body, 'headers': self._headers()})
|
||||
try:
|
||||
return self.session().get(url, json=body, headers=self._headers())
|
||||
return self.session().get(url, **kwargs)
|
||||
except getattr(requests.exceptions, 'RequestException') as inst:
|
||||
self.module.fail_json(msg=inst.message)
|
||||
|
||||
|
@ -105,12 +106,12 @@ class GcpSession(object):
|
|||
if not HAS_GOOGLE_LIBRARIES:
|
||||
self.module.fail_json(msg="Please install the google-auth library")
|
||||
|
||||
if self.module.params['service_account_email'] is not None and self.module.params['auth_kind'] != 'machineaccount':
|
||||
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"
|
||||
)
|
||||
|
||||
if self.module.params['service_account_file'] is not None and self.module.params['auth_kind'] != 'serviceaccount':
|
||||
if self.module.params.get('service_account_file') is not None and self.module.params['auth_kind'] != 'serviceaccount':
|
||||
self.module.fail_json(
|
||||
msg="Service Acccount File only works with Service Account-based authentication"
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue