|
|
@ -107,15 +107,13 @@ options:
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
labels:
|
|
|
|
labels:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- 'The map of Kubernetes labels (key/value pairs) to be
|
|
|
|
- 'The map of Kubernetes labels (key/value pairs) to be applied to each node.
|
|
|
|
applied to each node. These will added in addition to any
|
|
|
|
These will added in addition to any default label(s) that Kubernetes may apply to
|
|
|
|
default label(s) that Kubernetes may apply to the node. In
|
|
|
|
the node. In case of conflict in label keys, the applied set may differ depending
|
|
|
|
case of conflict in label keys, the applied set may differ
|
|
|
|
on the Kubernetes version -- it''s best to assume the behavior is undefined and
|
|
|
|
depending on the Kubernetes version -- it''s best to assume
|
|
|
|
conflicts should be avoided. For more information, including usage and the valid
|
|
|
|
the behavior is undefined and conflicts should be avoided. For
|
|
|
|
values, see: U(http://kubernetes.io/v1.1/docs/user-guide/labels.html) An object
|
|
|
|
more information, including usage and the valid values, see:
|
|
|
|
containing a list of "key": value pairs.'
|
|
|
|
U(http://kubernetes.io/v1.1/docs/user-guide/labels.html) An
|
|
|
|
|
|
|
|
object containing a list of "key": value pairs.'
|
|
|
|
|
|
|
|
- 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.'
|
|
|
|
- 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.'
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
local_ssd_count:
|
|
|
|
local_ssd_count:
|
|
|
@ -199,7 +197,7 @@ options:
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
cluster:
|
|
|
|
cluster:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- A reference to Cluster resource.
|
|
|
|
- The cluster this node pool belongs to.
|
|
|
|
required: true
|
|
|
|
required: true
|
|
|
|
zone:
|
|
|
|
zone:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
@ -211,28 +209,24 @@ extends_documentation_fragment: gcp
|
|
|
|
EXAMPLES = '''
|
|
|
|
EXAMPLES = '''
|
|
|
|
- name: create a cluster
|
|
|
|
- name: create a cluster
|
|
|
|
gcp_container_cluster:
|
|
|
|
gcp_container_cluster:
|
|
|
|
name: 'cluster-nodepool'
|
|
|
|
name: "cluster-nodepool"
|
|
|
|
initial_node_count: 4
|
|
|
|
initial_node_count: 4
|
|
|
|
zone: 'us-central1-a'
|
|
|
|
zone: 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 }}"
|
|
|
|
scopes:
|
|
|
|
|
|
|
|
- https://www.googleapis.com/auth/cloud-platform
|
|
|
|
|
|
|
|
state: present
|
|
|
|
state: present
|
|
|
|
register: cluster
|
|
|
|
register: cluster
|
|
|
|
|
|
|
|
|
|
|
|
- name: create a node pool
|
|
|
|
- name: create a node pool
|
|
|
|
gcp_container_node_pool:
|
|
|
|
gcp_container_node_pool:
|
|
|
|
name: testObject
|
|
|
|
name: "test_object"
|
|
|
|
initial_node_count: 4
|
|
|
|
initial_node_count: 4
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
zone: 'us-central1-a'
|
|
|
|
zone: us-central1-a
|
|
|
|
project: testProject
|
|
|
|
project: "test_project"
|
|
|
|
auth_kind: service_account
|
|
|
|
auth_kind: "service_account"
|
|
|
|
service_account_file: /tmp/auth.pem
|
|
|
|
service_account_file: "/tmp/auth.pem"
|
|
|
|
scopes:
|
|
|
|
|
|
|
|
- https://www.googleapis.com/auth/cloud-platform
|
|
|
|
|
|
|
|
state: present
|
|
|
|
state: present
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
@ -302,15 +296,13 @@ RETURN = '''
|
|
|
|
type: str
|
|
|
|
type: str
|
|
|
|
labels:
|
|
|
|
labels:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- 'The map of Kubernetes labels (key/value pairs) to be
|
|
|
|
- 'The map of Kubernetes labels (key/value pairs) to be applied to each node.
|
|
|
|
applied to each node. These will added in addition to any
|
|
|
|
These will added in addition to any default label(s) that Kubernetes may apply to
|
|
|
|
default label(s) that Kubernetes may apply to the node. In
|
|
|
|
the node. In case of conflict in label keys, the applied set may differ depending
|
|
|
|
case of conflict in label keys, the applied set may differ
|
|
|
|
on the Kubernetes version -- it''s best to assume the behavior is undefined and
|
|
|
|
depending on the Kubernetes version -- it''s best to assume
|
|
|
|
conflicts should be avoided. For more information, including usage and the valid
|
|
|
|
the behavior is undefined and conflicts should be avoided. For
|
|
|
|
values, see: U(http://kubernetes.io/v1.1/docs/user-guide/labels.html) An object
|
|
|
|
more information, including usage and the valid values, see:
|
|
|
|
containing a list of "key": value pairs.'
|
|
|
|
U(http://kubernetes.io/v1.1/docs/user-guide/labels.html) An
|
|
|
|
|
|
|
|
object containing a list of "key": value pairs.'
|
|
|
|
|
|
|
|
- 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.'
|
|
|
|
- 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.'
|
|
|
|
returned: success
|
|
|
|
returned: success
|
|
|
|
type: dict
|
|
|
|
type: dict
|
|
|
@ -410,7 +402,7 @@ RETURN = '''
|
|
|
|
type: str
|
|
|
|
type: str
|
|
|
|
cluster:
|
|
|
|
cluster:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- A reference to Cluster resource.
|
|
|
|
- The cluster this node pool belongs to.
|
|
|
|
returned: success
|
|
|
|
returned: success
|
|
|
|
type: dict
|
|
|
|
type: dict
|
|
|
|
zone:
|
|
|
|
zone:
|
|
|
@ -471,6 +463,9 @@ def main():
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not module.params['scopes']:
|
|
|
|
|
|
|
|
module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
|
|
|
|
|
|
|
|
|
|
|
|
state = module.params['state']
|
|
|
|
state = module.params['state']
|
|
|
|
|
|
|
|
|
|
|
|
fetch = fetch_resource(module, self_link(module))
|
|
|
|
fetch = fetch_resource(module, self_link(module))
|
|
|
@ -517,8 +512,8 @@ def resource_to_request(module):
|
|
|
|
u'name': module.params.get('name'),
|
|
|
|
u'name': module.params.get('name'),
|
|
|
|
u'config': NodePoolConfig(module.params.get('config', {}), module).to_request(),
|
|
|
|
u'config': NodePoolConfig(module.params.get('config', {}), module).to_request(),
|
|
|
|
u'initialNodeCount': module.params.get('initial_node_count'),
|
|
|
|
u'initialNodeCount': module.params.get('initial_node_count'),
|
|
|
|
u'autoscaling': NodePoolAutosca(module.params.get('autoscaling', {}), module).to_request(),
|
|
|
|
u'autoscaling': NodePoolAutoscaling(module.params.get('autoscaling', {}), module).to_request(),
|
|
|
|
u'management': NodePoolManagem(module.params.get('management', {}), module).to_request()
|
|
|
|
u'management': NodePoolManagement(module.params.get('management', {}), module).to_request()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
request = encode_request(request, module)
|
|
|
|
request = encode_request(request, module)
|
|
|
|
return_vals = {}
|
|
|
|
return_vals = {}
|
|
|
@ -600,8 +595,8 @@ def response_to_hash(module, response):
|
|
|
|
u'config': NodePoolConfig(response.get(u'config', {}), module).from_response(),
|
|
|
|
u'config': NodePoolConfig(response.get(u'config', {}), module).from_response(),
|
|
|
|
u'initialNodeCount': module.params.get('initial_node_count'),
|
|
|
|
u'initialNodeCount': module.params.get('initial_node_count'),
|
|
|
|
u'version': response.get(u'version'),
|
|
|
|
u'version': response.get(u'version'),
|
|
|
|
u'autoscaling': NodePoolAutosca(response.get(u'autoscaling', {}), module).from_response(),
|
|
|
|
u'autoscaling': NodePoolAutoscaling(response.get(u'autoscaling', {}), module).from_response(),
|
|
|
|
u'management': NodePoolManagem(response.get(u'management', {}), module).from_response()
|
|
|
|
u'management': NodePoolManagement(response.get(u'management', {}), module).from_response()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -617,7 +612,7 @@ def async_op_url(module, extra_data=None):
|
|
|
|
def wait_for_operation(module, response):
|
|
|
|
def wait_for_operation(module, response):
|
|
|
|
op_result = return_if_object(module, response)
|
|
|
|
op_result = return_if_object(module, response)
|
|
|
|
if op_result is None:
|
|
|
|
if op_result is None:
|
|
|
|
return None
|
|
|
|
return {}
|
|
|
|
status = navigate_hash(op_result, ['status'])
|
|
|
|
status = navigate_hash(op_result, ['status'])
|
|
|
|
wait_done = wait_for_completion(status, op_result, module)
|
|
|
|
wait_done = wait_for_completion(status, op_result, module)
|
|
|
|
return fetch_resource(module, navigate_hash(wait_done, ['targetLink']))
|
|
|
|
return fetch_resource(module, navigate_hash(wait_done, ['targetLink']))
|
|
|
@ -695,7 +690,7 @@ class NodePoolConfig(object):
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NodePoolAutosca(object):
|
|
|
|
class NodePoolAutoscaling(object):
|
|
|
|
def __init__(self, request, module):
|
|
|
|
def __init__(self, request, module):
|
|
|
|
self.module = module
|
|
|
|
self.module = module
|
|
|
|
if request:
|
|
|
|
if request:
|
|
|
@ -718,7 +713,7 @@ class NodePoolAutosca(object):
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NodePoolManagem(object):
|
|
|
|
class NodePoolManagement(object):
|
|
|
|
def __init__(self, request, module):
|
|
|
|
def __init__(self, request, module):
|
|
|
|
self.module = module
|
|
|
|
self.module = module
|
|
|
|
if request:
|
|
|
|
if request:
|
|
|
@ -730,18 +725,18 @@ class NodePoolManagem(object):
|
|
|
|
return remove_nones_from_dict({
|
|
|
|
return remove_nones_from_dict({
|
|
|
|
u'autoUpgrade': self.request.get('auto_upgrade'),
|
|
|
|
u'autoUpgrade': self.request.get('auto_upgrade'),
|
|
|
|
u'autoRepair': self.request.get('auto_repair'),
|
|
|
|
u'autoRepair': self.request.get('auto_repair'),
|
|
|
|
u'upgradeOptions': NodePoolUpgraOptio(self.request.get('upgrade_options', {}), self.module).to_request()
|
|
|
|
u'upgradeOptions': NodePoolUpgradeOptions(self.request.get('upgrade_options', {}), self.module).to_request()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
def from_response(self):
|
|
|
|
def from_response(self):
|
|
|
|
return remove_nones_from_dict({
|
|
|
|
return remove_nones_from_dict({
|
|
|
|
u'autoUpgrade': self.request.get(u'autoUpgrade'),
|
|
|
|
u'autoUpgrade': self.request.get(u'autoUpgrade'),
|
|
|
|
u'autoRepair': self.request.get(u'autoRepair'),
|
|
|
|
u'autoRepair': self.request.get(u'autoRepair'),
|
|
|
|
u'upgradeOptions': NodePoolUpgraOptio(self.request.get(u'upgradeOptions', {}), self.module).from_response()
|
|
|
|
u'upgradeOptions': NodePoolUpgradeOptions(self.request.get(u'upgradeOptions', {}), self.module).from_response()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NodePoolUpgraOptio(object):
|
|
|
|
class NodePoolUpgradeOptions(object):
|
|
|
|
def __init__(self, request, module):
|
|
|
|
def __init__(self, request, module):
|
|
|
|
self.module = module
|
|
|
|
self.module = module
|
|
|
|
if request:
|
|
|
|
if request:
|
|
|
|