mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
k8s_service: add new kubernetes module for handling Services (#48872)
* k8s: add k8s_kind arg to KubernetesRawModule Single–kind k8s modules (e.g. k8s_service) do not have a module parameter called 'kind' and need to pass a static 'kind' on KubernetesRawModule class creation. Hence this change. * k8s: make 'validate' and 'wait' mod params optional Not all k8s modules utilizing KubernetesRawModule will use these. * k8s_service: new k8s module for handling Services
This commit is contained in:
parent
0e4a7b0889
commit
d8a690952e
2 changed files with 273 additions and 5 deletions
|
@ -73,7 +73,7 @@ class KubernetesRawModule(KubernetesAnsibleModule):
|
|||
argument_spec['append_hash'] = dict(type='bool', default=False)
|
||||
return argument_spec
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
def __init__(self, k8s_kind=None, *args, **kwargs):
|
||||
self.client = None
|
||||
|
||||
mutually_exclusive = [
|
||||
|
@ -84,12 +84,13 @@ class KubernetesRawModule(KubernetesAnsibleModule):
|
|||
mutually_exclusive=mutually_exclusive,
|
||||
supports_check_mode=True,
|
||||
**kwargs)
|
||||
self.kind = self.params.get('kind')
|
||||
self.kind = k8s_kind or self.params.get('kind')
|
||||
self.api_version = self.params.get('api_version')
|
||||
self.name = self.params.get('name')
|
||||
self.namespace = self.params.get('namespace')
|
||||
resource_definition = self.params.get('resource_definition')
|
||||
if self.params['validate']:
|
||||
validate = self.params.get('validate')
|
||||
if validate:
|
||||
if LooseVersion(self.openshift_version) < LooseVersion("0.8.0"):
|
||||
self.fail_json(msg="openshift >= 0.8.0 is required for validate")
|
||||
self.append_hash = self.params.get('append_hash')
|
||||
|
@ -182,8 +183,8 @@ class KubernetesRawModule(KubernetesAnsibleModule):
|
|||
name = definition['metadata'].get('name')
|
||||
namespace = definition['metadata'].get('namespace')
|
||||
existing = None
|
||||
wait = self.params['wait']
|
||||
wait_timeout = self.params['wait_timeout']
|
||||
wait = self.params.get('wait')
|
||||
wait_timeout = self.params.get('wait_timeout')
|
||||
|
||||
self.remove_aliases()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue