diff --git a/plugins/modules/gcp_container_cluster.py b/plugins/modules/gcp_container_cluster.py index 808659b..8957dc1 100644 --- a/plugins/modules/gcp_container_cluster.py +++ b/plugins/modules/gcp_container_cluster.py @@ -49,7 +49,7 @@ options: default: present name: 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 only. Must start with a letter. Must end with a number or a letter. required: false @@ -254,12 +254,7 @@ options: required: false location: description: - - The list of Google Compute Engine locations in which the cluster's nodes should - be located. - required: false - zone: - description: - - The zone where the cluster is deployed. + - The location where the cluster is deployed. required: true extends_documentation_fragment: gcp ''' @@ -275,7 +270,7 @@ EXAMPLES = ''' node_config: machine_type: n1-standard-4 disk_size_gb: 500 - zone: us-central1-a + location: us-central1-a project: "test_project" auth_kind: "serviceaccount" service_account_file: "/tmp/auth.pem" @@ -285,7 +280,7 @@ EXAMPLES = ''' RETURN = ''' name: 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 only. Must start with a letter. Must end with a number or a letter. returned: success @@ -508,12 +503,6 @@ subnetwork: - The name of the Google Compute Engine subnetwork to which the cluster is connected. returned: success 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: description: - 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. returned: success type: str -zone: +location: description: - - The zone where the cluster is deployed. + - The location where the cluster is deployed. returned: success type: str ''' @@ -637,8 +626,7 @@ def main(): ), ), subnetwork=dict(type='str'), - location=dict(type='list', elements='str'), - zone=dict(required=True, type='str'), + location=dict(required=True, type='str'), ) ) @@ -701,7 +689,6 @@ def resource_to_request(module): u'clusterIpv4Cidr': module.params.get('cluster_ipv4_cidr'), u'addonsConfig': ClusterAddonsconfig(module.params.get('addons_config', {}), module).to_request(), u'subnetwork': module.params.get('subnetwork'), - u'location': module.params.get('location'), } request = encode_request(request, module) return_vals = {} diff --git a/plugins/modules/gcp_container_cluster_facts.py b/plugins/modules/gcp_container_cluster_facts.py index 1f6e020..5f5f1d7 100644 --- a/plugins/modules/gcp_container_cluster_facts.py +++ b/plugins/modules/gcp_container_cluster_facts.py @@ -40,17 +40,19 @@ requirements: - requests >= 2.18.4 - google-auth >= 1.3.0 options: - zone: + location: description: - - The zone where the cluster is deployed. + - The location where the cluster is deployed. required: true + aliases: + - zone extends_documentation_fragment: gcp ''' EXAMPLES = ''' - name: a cluster facts gcp_container_cluster_facts: - zone: us-central1-a + location: us-central1-a project: test_project auth_kind: serviceaccount service_account_file: "/tmp/auth.pem" @@ -65,7 +67,7 @@ items: name: description: - 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. returned: success type: str @@ -288,12 +290,6 @@ items: - The name of the Google Compute Engine subnetwork to which the cluster is connected. returned: success 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: description: - 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. returned: success type: str - zone: + location: description: - - The zone where the cluster is deployed. + - The location where the cluster is deployed. returned: success type: str ''' @@ -366,7 +362,7 @@ import json 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']: module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform'] @@ -381,7 +377,7 @@ def main(): 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): diff --git a/tests/integration/gcp_container_cluster/tasks/main.yml b/tests/integration/gcp_container_cluster/tasks/main.yml index 21ab822..1785c26 100644 --- a/tests/integration/gcp_container_cluster/tasks/main.yml +++ b/tests/integration/gcp_container_cluster/tasks/main.yml @@ -23,7 +23,7 @@ node_config: machine_type: n1-standard-4 disk_size_gb: 500 - zone: us-central1-a + location: us-central1-a project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" @@ -39,7 +39,7 @@ node_config: machine_type: n1-standard-4 disk_size_gb: 500 - zone: us-central1-a + location: us-central1-a project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" @@ -51,7 +51,7 @@ - result.changed == true - name: verify that cluster was created gcp_container_cluster_facts: - zone: us-central1-a + location: us-central1-a project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" @@ -73,7 +73,7 @@ node_config: machine_type: n1-standard-4 disk_size_gb: 500 - zone: us-central1-a + location: us-central1-a project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" @@ -94,7 +94,7 @@ node_config: machine_type: n1-standard-4 disk_size_gb: 500 - zone: us-central1-a + location: us-central1-a project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" @@ -106,7 +106,7 @@ - result.changed == true - name: verify that cluster was deleted gcp_container_cluster_facts: - zone: us-central1-a + location: us-central1-a project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" @@ -128,7 +128,7 @@ node_config: machine_type: n1-standard-4 disk_size_gb: 500 - zone: us-central1-a + location: us-central1-a project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}"