Changing NodePool from Zone to Location (#182)

<!-- This change is generated by MagicModules. -->
/cc @rambleraptor
This commit is contained in:
The Magician 2019-01-31 09:54:33 -08:00 committed by Alex Stephen
parent ba60e76aee
commit 1ec588abb1
5 changed files with 59 additions and 46 deletions

View file

@ -256,6 +256,9 @@ options:
description:
- The location where the cluster is deployed.
required: true
aliases:
- zone
version_added: 2.8
extends_documentation_fragment: gcp
'''
@ -626,7 +629,7 @@ def main():
),
),
subnetwork=dict(type='str'),
location=dict(required=True, type='str'),
location=dict(required=True, type='str', aliases=['zone']),
)
)

View file

@ -45,7 +45,9 @@ options:
- The location where the cluster is deployed.
required: true
aliases:
- region
- zone
version_added: 2.8
extends_documentation_fragment: gcp
'''
@ -362,7 +364,7 @@ import json
def main():
module = GcpModule(argument_spec=dict(location=dict(required=True, type='str', aliases=['zone'])))
module = GcpModule(argument_spec=dict(location=dict(required=True, type='str', aliases=['region', 'zone'])))
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']

View file

@ -207,23 +207,27 @@ options:
Alternatively, you can add `register: name-of-resource` to a gcp_container_cluster
task and then set this cluster field to "{{ name-of-resource }}"'
required: true
zone:
location:
description:
- The zone where the node pool is deployed.
- The location where the node pool is deployed.
required: true
aliases:
- region
- zone
version_added: 2.8
extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: create a cluster
gcp_container_cluster:
name: cluster-nodepool
initial_node_count: 4
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: "cluster-nodepool"
initial_node_count: 4
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: cluster
- name: create a node pool
@ -231,7 +235,7 @@ EXAMPLES = '''
name: my-pool
initial_node_count: 4
cluster: "{{ cluster }}"
zone: us-central1-a
location: us-central1-a
project: "test_project"
auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem"
@ -415,9 +419,9 @@ cluster:
- The cluster this node pool belongs to.
returned: success
type: str
zone:
location:
description:
- The zone where the node pool is deployed.
- The location where the node pool is deployed.
returned: success
type: str
'''
@ -468,7 +472,7 @@ def main():
),
),
cluster=dict(required=True),
zone=dict(required=True, type='str'),
location=dict(required=True, type='str', aliases=['region', 'zone']),
)
)
@ -551,8 +555,8 @@ def self_link(module):
def collection(module):
res = {'project': module.params['project'], 'zone': module.params['zone'], 'cluster': replace_resource_dict(module.params['cluster'], 'name')}
return "https://container.googleapis.com/v1/projects/{project}/zones/{zone}/clusters/{cluster}/nodePools".format(**res)
res = {'project': module.params['project'], 'location': module.params['location'], 'cluster': replace_resource_dict(module.params['cluster'], 'name')}
return "https://container.googleapis.com/v1/projects/{project}/zones/{location}/clusters/{cluster}/nodePools".format(**res)
def return_if_object(module, response, allow_not_found=False):

View file

@ -40,10 +40,14 @@ requirements:
- requests >= 2.18.4
- google-auth >= 1.3.0
options:
zone:
location:
description:
- The zone where the node pool is deployed.
- The location where the node pool is deployed.
required: true
aliases:
- region
- zone
version_added: 2.8
cluster:
description:
- The cluster this node pool belongs to.
@ -59,7 +63,7 @@ EXAMPLES = '''
- name: a node pool facts
gcp_container_node_pool_facts:
cluster: "{{ cluster }}"
zone: us-central1-a
location: us-central1-a
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
@ -248,9 +252,9 @@ items:
- The cluster this node pool belongs to.
returned: success
type: str
zone:
location:
description:
- The zone where the node pool is deployed.
- The location where the node pool is deployed.
returned: success
type: str
'''
@ -267,7 +271,7 @@ import json
def main():
module = GcpModule(argument_spec=dict(zone=dict(required=True, type='str'), cluster=dict(required=True)))
module = GcpModule(argument_spec=dict(location=dict(required=True, type='str', aliases=['region', 'zone']), cluster=dict(required=True)))
if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
@ -282,8 +286,8 @@ def main():
def collection(module):
res = {'project': module.params['project'], 'zone': module.params['zone'], 'cluster': replace_resource_dict(module.params['cluster'], 'name')}
return "https://container.googleapis.com/v1/projects/{project}/zones/{zone}/clusters/{cluster}/nodePools".format(**res)
res = {'project': module.params['project'], 'location': module.params['location'], 'cluster': replace_resource_dict(module.params['cluster'], 'name')}
return "https://container.googleapis.com/v1/projects/{project}/zones/{location}/clusters/{cluster}/nodePools".format(**res)
def fetch_list(module, link):

View file

@ -15,20 +15,20 @@
# Pre-test setup
- name: create a cluster
gcp_container_cluster:
name: cluster-nodepool
initial_node_count: 4
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: "cluster-nodepool"
initial_node_count: 4
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: cluster
- name: delete a node pool
gcp_container_node_pool:
name: my-pool
initial_node_count: 4
cluster: "{{ cluster }}"
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 @@
name: my-pool
initial_node_count: 4
cluster: "{{ cluster }}"
zone: us-central1-a
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
@ -52,7 +52,7 @@
- name: verify that node_pool was created
gcp_container_node_pool_facts:
cluster: "{{ cluster }}"
zone: us-central1-a
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
@ -69,7 +69,7 @@
name: my-pool
initial_node_count: 4
cluster: "{{ cluster }}"
zone: us-central1-a
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
@ -85,7 +85,7 @@
name: my-pool
initial_node_count: 4
cluster: "{{ cluster }}"
zone: us-central1-a
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
@ -98,7 +98,7 @@
- name: verify that node_pool was deleted
gcp_container_node_pool_facts:
cluster: "{{ cluster }}"
zone: us-central1-a
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
@ -115,7 +115,7 @@
name: my-pool
initial_node_count: 4
cluster: "{{ cluster }}"
zone: us-central1-a
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
@ -130,12 +130,12 @@
# If errors happen, don't crash the playbook!
- name: delete a cluster
gcp_container_cluster:
name: cluster-nodepool
initial_node_count: 4
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: absent
name: "cluster-nodepool"
initial_node_count: 4
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: absent
register: cluster
ignore_errors: true