mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-04-09 04:10:27 -07:00
fix: remove version_added in gcp_compute
The version_added field is documented for a very small set of fields, specifically in gcp_compute today. Removing these values as they are specifying the ansible-core version which is confusing for those who are installing via ansible-galaxy, and the value is not set for any other module. fixes #550.
This commit is contained in:
parent
791e11d45d
commit
252f215f2c
1 changed files with 46 additions and 49 deletions
|
@ -60,23 +60,19 @@ DOCUMENTATION = """
|
||||||
choices: ['application', 'serviceaccount', 'machineaccount']
|
choices: ['application', 'serviceaccount', 'machineaccount']
|
||||||
env:
|
env:
|
||||||
- name: GCP_AUTH_KIND
|
- name: GCP_AUTH_KIND
|
||||||
version_added: "2.8.2"
|
|
||||||
scopes:
|
scopes:
|
||||||
description: list of authentication scopes
|
description: list of authentication scopes
|
||||||
type: list
|
type: list
|
||||||
default: ['https://www.googleapis.com/auth/compute']
|
default: ['https://www.googleapis.com/auth/compute']
|
||||||
env:
|
env:
|
||||||
- name: GCP_SCOPES
|
- name: GCP_SCOPES
|
||||||
version_added: "2.8.2"
|
|
||||||
service_account_file:
|
service_account_file:
|
||||||
description:
|
description:
|
||||||
- The path of a Service Account JSON file if serviceaccount is selected as type.
|
- The path of a Service Account JSON file if serviceaccount is selected as type.
|
||||||
type: path
|
type: path
|
||||||
env:
|
env:
|
||||||
- name: GCP_SERVICE_ACCOUNT_FILE
|
- name: GCP_SERVICE_ACCOUNT_FILE
|
||||||
version_added: "2.8.2"
|
|
||||||
- name: GCE_CREDENTIALS_FILE_PATH
|
- name: GCE_CREDENTIALS_FILE_PATH
|
||||||
version_added: "2.8"
|
|
||||||
service_account_contents:
|
service_account_contents:
|
||||||
description:
|
description:
|
||||||
- A string representing the contents of a Service Account JSON file. This should not be passed in as a dictionary,
|
- A string representing the contents of a Service Account JSON file. This should not be passed in as a dictionary,
|
||||||
|
@ -84,14 +80,12 @@ DOCUMENTATION = """
|
||||||
type: string
|
type: string
|
||||||
env:
|
env:
|
||||||
- name: GCP_SERVICE_ACCOUNT_CONTENTS
|
- name: GCP_SERVICE_ACCOUNT_CONTENTS
|
||||||
version_added: "2.8.2"
|
|
||||||
service_account_email:
|
service_account_email:
|
||||||
description:
|
description:
|
||||||
- An optional service account email address if machineaccount is selected
|
- An optional service account email address if machineaccount is selected
|
||||||
and the user does not wish to use the default email.
|
and the user does not wish to use the default email.
|
||||||
env:
|
env:
|
||||||
- name: GCP_SERVICE_ACCOUNT_EMAIL
|
- name: GCP_SERVICE_ACCOUNT_EMAIL
|
||||||
version_added: "2.8.2"
|
|
||||||
vars_prefix:
|
vars_prefix:
|
||||||
description: prefix to apply to host variables, does not include facts nor params
|
description: prefix to apply to host variables, does not include facts nor params
|
||||||
default: ''
|
default: ''
|
||||||
|
@ -105,7 +99,6 @@ DOCUMENTATION = """
|
||||||
which group names end up being used as.
|
which group names end up being used as.
|
||||||
type: bool
|
type: bool
|
||||||
default: False
|
default: False
|
||||||
version_added: '2.8'
|
|
||||||
retrieve_image_info:
|
retrieve_image_info:
|
||||||
description:
|
description:
|
||||||
- Populate the C(image) host fact for the instances returned with the GCP image name
|
- Populate the C(image) host fact for the instances returned with the GCP image name
|
||||||
|
@ -114,7 +107,6 @@ DOCUMENTATION = """
|
||||||
- Unless this option is enabled, the C(image) host variable will be C(null)
|
- Unless this option is enabled, the C(image) host variable will be C(null)
|
||||||
type: bool
|
type: bool
|
||||||
default: False
|
default: False
|
||||||
version_added: '2.8'
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
@ -170,7 +162,9 @@ class GcpMockModule(object):
|
||||||
|
|
||||||
|
|
||||||
class GcpInstance(object):
|
class GcpInstance(object):
|
||||||
def __init__(self, json, hostname_ordering, project_disks, should_format=True, name_suffix=""):
|
def __init__(
|
||||||
|
self, json, hostname_ordering, project_disks, should_format=True, name_suffix=""
|
||||||
|
):
|
||||||
self.hostname_ordering = hostname_ordering
|
self.hostname_ordering = hostname_ordering
|
||||||
self.project_disks = project_disks
|
self.project_disks = project_disks
|
||||||
self.name_suffix = name_suffix
|
self.name_suffix = name_suffix
|
||||||
|
@ -238,13 +232,13 @@ class GcpInstance(object):
|
||||||
for order in self.hostname_ordering:
|
for order in self.hostname_ordering:
|
||||||
name = None
|
name = None
|
||||||
if order.startswith("labels."):
|
if order.startswith("labels."):
|
||||||
name = self.json[u"labels"].get(order[7:])
|
name = self.json["labels"].get(order[7:])
|
||||||
elif order == "public_ip":
|
elif order == "public_ip":
|
||||||
name = self._get_publicip()
|
name = self._get_publicip()
|
||||||
elif order == "private_ip":
|
elif order == "private_ip":
|
||||||
name = self._get_privateip()
|
name = self._get_privateip()
|
||||||
elif order == "name":
|
elif order == "name":
|
||||||
name = self.json[u"name"] + self.name_suffix
|
name = self.json["name"] + self.name_suffix
|
||||||
else:
|
else:
|
||||||
raise AnsibleParserError("%s is not a valid hostname precedent" % order)
|
raise AnsibleParserError("%s is not a valid hostname precedent" % order)
|
||||||
|
|
||||||
|
@ -262,7 +256,7 @@ class GcpInstance(object):
|
||||||
if "accessConfigs" in interface:
|
if "accessConfigs" in interface:
|
||||||
for accessConfig in interface["accessConfigs"]:
|
for accessConfig in interface["accessConfigs"]:
|
||||||
if "natIP" in accessConfig:
|
if "natIP" in accessConfig:
|
||||||
return accessConfig[u"natIP"]
|
return accessConfig["natIP"]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _get_image(self):
|
def _get_image(self):
|
||||||
|
@ -283,9 +277,9 @@ class GcpInstance(object):
|
||||||
:return the privateIP of this instance or None
|
:return the privateIP of this instance or None
|
||||||
"""
|
"""
|
||||||
# Fallback: Get private IP
|
# Fallback: Get private IP
|
||||||
for interface in self.json[u"networkInterfaces"]:
|
for interface in self.json["networkInterfaces"]:
|
||||||
if "networkIP" in interface:
|
if "networkIP" in interface:
|
||||||
return interface[u"networkIP"]
|
return interface["networkIP"]
|
||||||
|
|
||||||
|
|
||||||
class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
||||||
|
@ -349,7 +343,10 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
||||||
self.fake_module,
|
self.fake_module,
|
||||||
self.auth_session.get(
|
self.auth_session.get(
|
||||||
link,
|
link,
|
||||||
params={"filter": query, "pageToken": resp.get("nextPageToken")},
|
params={
|
||||||
|
"filter": query,
|
||||||
|
"pageToken": resp.get("nextPageToken"),
|
||||||
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
lists.append(resp.get("items"))
|
lists.append(resp.get("items"))
|
||||||
|
@ -516,20 +513,20 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
||||||
|
|
||||||
def fetch_projects(self, params, link, query):
|
def fetch_projects(self, params, link, query):
|
||||||
module = GcpMockModule(params)
|
module = GcpMockModule(params)
|
||||||
auth = GcpSession(module, 'cloudresourcemanager')
|
auth = GcpSession(module, "cloudresourcemanager")
|
||||||
response = auth.get(link, params={'filter': query})
|
response = auth.get(link, params={"filter": query})
|
||||||
return self._return_if_object(module, response)
|
return self._return_if_object(module, response)
|
||||||
|
|
||||||
def projects_for_folder(self, config_data, folder):
|
def projects_for_folder(self, config_data, folder):
|
||||||
link = 'https://cloudresourcemanager.googleapis.com/v1/projects'
|
link = "https://cloudresourcemanager.googleapis.com/v1/projects"
|
||||||
query = 'parent.id = {0}'.format(folder)
|
query = "parent.id = {0}".format(folder)
|
||||||
projects = []
|
projects = []
|
||||||
config_data['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
|
config_data["scopes"] = ["https://www.googleapis.com/auth/cloud-platform"]
|
||||||
projects_response = self.fetch_projects(config_data, link, query)
|
projects_response = self.fetch_projects(config_data, link, query)
|
||||||
|
|
||||||
if 'projects' in projects_response:
|
if "projects" in projects_response:
|
||||||
for item in projects_response.get('projects'):
|
for item in projects_response.get("projects"):
|
||||||
projects.append(item['projectId'])
|
projects.append(item["projectId"])
|
||||||
return projects
|
return projects
|
||||||
|
|
||||||
def parse(self, inventory, loader, path, cache=True):
|
def parse(self, inventory, loader, path, cache=True):
|
||||||
|
|
Loading…
Add table
Reference in a new issue