Inspec regional cluster

Signed-off-by: Modular Magician <magic-modules@google.com>
This commit is contained in:
Sam Levenick 2019-01-30 17:36:52 +00:00 committed by Alex Stephen
parent 3a8363cfa7
commit 8c60e90103
3 changed files with 24 additions and 41 deletions

View file

@ -49,7 +49,7 @@ options:
default: present default: present
name: name:
description: description:
- The name of this cluster. The name must be unique within this project and zone, - The name of this cluster. The name must be unique within this project and location,
and can be up to 40 characters. Must be Lowercase letters, numbers, and hyphens and can be up to 40 characters. Must be Lowercase letters, numbers, and hyphens
only. Must start with a letter. Must end with a number or a letter. only. Must start with a letter. Must end with a number or a letter.
required: false required: false
@ -254,12 +254,7 @@ options:
required: false required: false
location: location:
description: description:
- The list of Google Compute Engine locations in which the cluster's nodes should - The location where the cluster is deployed.
be located.
required: false
zone:
description:
- The zone where the cluster is deployed.
required: true required: true
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
''' '''
@ -275,7 +270,7 @@ EXAMPLES = '''
node_config: node_config:
machine_type: n1-standard-4 machine_type: n1-standard-4
disk_size_gb: 500 disk_size_gb: 500
zone: us-central1-a location: us-central1-a
project: "test_project" project: "test_project"
auth_kind: "serviceaccount" auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
@ -285,7 +280,7 @@ EXAMPLES = '''
RETURN = ''' RETURN = '''
name: name:
description: description:
- The name of this cluster. The name must be unique within this project and zone, - The name of this cluster. The name must be unique within this project and location,
and can be up to 40 characters. Must be Lowercase letters, numbers, and hyphens and can be up to 40 characters. Must be Lowercase letters, numbers, and hyphens
only. Must start with a letter. Must end with a number or a letter. only. Must start with a letter. Must end with a number or a letter.
returned: success returned: success
@ -508,12 +503,6 @@ subnetwork:
- The name of the Google Compute Engine subnetwork to which the cluster is connected. - The name of the Google Compute Engine subnetwork to which the cluster is connected.
returned: success returned: success
type: str type: str
location:
description:
- The list of Google Compute Engine locations in which the cluster's nodes should
be located.
returned: success
type: list
endpoint: endpoint:
description: description:
- The IP address of this cluster's master endpoint. - The IP address of this cluster's master endpoint.
@ -567,9 +556,9 @@ expireTime:
- The time the cluster will be automatically deleted in RFC3339 text format. - The time the cluster will be automatically deleted in RFC3339 text format.
returned: success returned: success
type: str type: str
zone: location:
description: description:
- The zone where the cluster is deployed. - The location where the cluster is deployed.
returned: success returned: success
type: str type: str
''' '''
@ -637,8 +626,7 @@ def main():
), ),
), ),
subnetwork=dict(type='str'), subnetwork=dict(type='str'),
location=dict(type='list', elements='str'), location=dict(required=True, type='str'),
zone=dict(required=True, type='str'),
) )
) )
@ -701,7 +689,6 @@ def resource_to_request(module):
u'clusterIpv4Cidr': module.params.get('cluster_ipv4_cidr'), u'clusterIpv4Cidr': module.params.get('cluster_ipv4_cidr'),
u'addonsConfig': ClusterAddonsconfig(module.params.get('addons_config', {}), module).to_request(), u'addonsConfig': ClusterAddonsconfig(module.params.get('addons_config', {}), module).to_request(),
u'subnetwork': module.params.get('subnetwork'), u'subnetwork': module.params.get('subnetwork'),
u'location': module.params.get('location'),
} }
request = encode_request(request, module) request = encode_request(request, module)
return_vals = {} return_vals = {}

View file

@ -40,17 +40,19 @@ requirements:
- requests >= 2.18.4 - requests >= 2.18.4
- google-auth >= 1.3.0 - google-auth >= 1.3.0
options: options:
zone: location:
description: description:
- The zone where the cluster is deployed. - The location where the cluster is deployed.
required: true required: true
aliases:
- zone
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a cluster facts - name: a cluster facts
gcp_container_cluster_facts: gcp_container_cluster_facts:
zone: us-central1-a location: us-central1-a
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
@ -65,7 +67,7 @@ items:
name: name:
description: description:
- The name of this cluster. The name must be unique within this project and - The name of this cluster. The name must be unique within this project and
zone, and can be up to 40 characters. Must be Lowercase letters, numbers, location, and can be up to 40 characters. Must be Lowercase letters, numbers,
and hyphens only. Must start with a letter. Must end with a number or a letter. and hyphens only. Must start with a letter. Must end with a number or a letter.
returned: success returned: success
type: str type: str
@ -288,12 +290,6 @@ items:
- The name of the Google Compute Engine subnetwork to which the cluster is connected. - The name of the Google Compute Engine subnetwork to which the cluster is connected.
returned: success returned: success
type: str type: str
location:
description:
- The list of Google Compute Engine locations in which the cluster's nodes should
be located.
returned: success
type: list
endpoint: endpoint:
description: description:
- The IP address of this cluster's master endpoint. - The IP address of this cluster's master endpoint.
@ -347,9 +343,9 @@ items:
- The time the cluster will be automatically deleted in RFC3339 text format. - The time the cluster will be automatically deleted in RFC3339 text format.
returned: success returned: success
type: str type: str
zone: location:
description: description:
- The zone where the cluster is deployed. - The location where the cluster is deployed.
returned: success returned: success
type: str type: str
''' '''
@ -366,7 +362,7 @@ import json
def main(): def main():
module = GcpModule(argument_spec=dict(zone=dict(required=True, type='str'))) module = GcpModule(argument_spec=dict(location=dict(required=True, type='str', aliases=['zone'])))
if not module.params['scopes']: if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform'] module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
@ -381,7 +377,7 @@ def main():
def collection(module): def collection(module):
return "https://container.googleapis.com/v1/projects/{project}/zones/{zone}/clusters".format(**module.params) return "https://container.googleapis.com/v1/projects/{project}/locations/{location}/clusters".format(**module.params)
def fetch_list(module, link): def fetch_list(module, link):

View file

@ -23,7 +23,7 @@
node_config: node_config:
machine_type: n1-standard-4 machine_type: n1-standard-4
disk_size_gb: 500 disk_size_gb: 500
zone: us-central1-a location: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -39,7 +39,7 @@
node_config: node_config:
machine_type: n1-standard-4 machine_type: n1-standard-4
disk_size_gb: 500 disk_size_gb: 500
zone: us-central1-a location: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -51,7 +51,7 @@
- result.changed == true - result.changed == true
- name: verify that cluster was created - name: verify that cluster was created
gcp_container_cluster_facts: gcp_container_cluster_facts:
zone: us-central1-a location: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -73,7 +73,7 @@
node_config: node_config:
machine_type: n1-standard-4 machine_type: n1-standard-4
disk_size_gb: 500 disk_size_gb: 500
zone: us-central1-a location: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -94,7 +94,7 @@
node_config: node_config:
machine_type: n1-standard-4 machine_type: n1-standard-4
disk_size_gb: 500 disk_size_gb: 500
zone: us-central1-a location: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -106,7 +106,7 @@
- result.changed == true - result.changed == true
- name: verify that cluster was deleted - name: verify that cluster was deleted
gcp_container_cluster_facts: gcp_container_cluster_facts:
zone: us-central1-a location: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -128,7 +128,7 @@
node_config: node_config:
machine_type: n1-standard-4 machine_type: n1-standard-4
disk_size_gb: 500 disk_size_gb: 500
zone: us-central1-a location: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"