mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-07-25 08:54:51 +00:00
k8s_*: Group argument_spec accroding to usage (#199)
Partially fix #36 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
@@ -15,8 +15,8 @@ class ModuleDocFragment(object):
|
|||||||
options:
|
options:
|
||||||
resource_definition:
|
resource_definition:
|
||||||
description:
|
description:
|
||||||
- "Provide a valid YAML definition (either as a string, list, or dict) for an object when creating or updating. NOTE: I(kind), I(api_version), I(name),
|
- Provide a valid YAML definition (either as a string, list, or dict) for an object when creating or updating.
|
||||||
and I(namespace) will be overwritten by corresponding values found in the provided I(resource_definition)."
|
- "NOTE: I(kind), I(api_version), I(name), and I(namespace) will be overwritten by corresponding values found in the provided I(resource_definition)."
|
||||||
aliases:
|
aliases:
|
||||||
- definition
|
- definition
|
||||||
- inline
|
- inline
|
||||||
|
|||||||
@@ -83,6 +83,9 @@ COMMON_ARG_SPEC = {
|
|||||||
'type': 'bool',
|
'type': 'bool',
|
||||||
'default': False,
|
'default': False,
|
||||||
},
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
RESOURCE_ARG_SPEC = {
|
||||||
'resource_definition': {
|
'resource_definition': {
|
||||||
'type': list_dict_str,
|
'type': list_dict_str,
|
||||||
'aliases': ['definition', 'inline']
|
'aliases': ['definition', 'inline']
|
||||||
@@ -90,6 +93,9 @@ COMMON_ARG_SPEC = {
|
|||||||
'src': {
|
'src': {
|
||||||
'type': 'path',
|
'type': 'path',
|
||||||
},
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
NAME_ARG_SPEC = {
|
||||||
'kind': {},
|
'kind': {},
|
||||||
'name': {},
|
'name': {},
|
||||||
'namespace': {},
|
'namespace': {},
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import sys
|
|||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from ansible.module_utils.basic import missing_required_lib
|
from ansible.module_utils.basic import missing_required_lib
|
||||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import AUTH_ARG_SPEC, COMMON_ARG_SPEC
|
from ansible_collections.community.kubernetes.plugins.module_utils.common import AUTH_ARG_SPEC, COMMON_ARG_SPEC, RESOURCE_ARG_SPEC, NAME_ARG_SPEC
|
||||||
from ansible.module_utils.six import string_types
|
from ansible.module_utils.six import string_types
|
||||||
from ansible.module_utils._text import to_native
|
from ansible.module_utils._text import to_native
|
||||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import KubernetesAnsibleModule
|
from ansible_collections.community.kubernetes.plugins.module_utils.common import KubernetesAnsibleModule
|
||||||
@@ -78,6 +78,8 @@ class KubernetesRawModule(KubernetesAnsibleModule):
|
|||||||
@property
|
@property
|
||||||
def argspec(self):
|
def argspec(self):
|
||||||
argument_spec = copy.deepcopy(COMMON_ARG_SPEC)
|
argument_spec = copy.deepcopy(COMMON_ARG_SPEC)
|
||||||
|
argument_spec.update(copy.deepcopy(NAME_ARG_SPEC))
|
||||||
|
argument_spec.update(copy.deepcopy(RESOURCE_ARG_SPEC))
|
||||||
argument_spec.update(copy.deepcopy(AUTH_ARG_SPEC))
|
argument_spec.update(copy.deepcopy(AUTH_ARG_SPEC))
|
||||||
argument_spec['merge_type'] = dict(type='list', elements='str', choices=['json', 'merge', 'strategic-merge'])
|
argument_spec['merge_type'] = dict(type='list', elements='str', choices=['json', 'merge', 'strategic-merge'])
|
||||||
argument_spec['wait'] = dict(type='bool', default=False)
|
argument_spec['wait'] = dict(type='bool', default=False)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ __metaclass__ = type
|
|||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import AUTH_ARG_SPEC, COMMON_ARG_SPEC
|
from ansible_collections.community.kubernetes.plugins.module_utils.common import AUTH_ARG_SPEC, RESOURCE_ARG_SPEC, NAME_ARG_SPEC
|
||||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import KubernetesAnsibleModule
|
from ansible_collections.community.kubernetes.plugins.module_utils.common import KubernetesAnsibleModule
|
||||||
from ansible.module_utils.six import string_types
|
from ansible.module_utils.six import string_types
|
||||||
|
|
||||||
@@ -142,11 +142,10 @@ class KubernetesAnsibleScaleModule(KubernetesAnsibleModule):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def argspec(self):
|
def argspec(self):
|
||||||
args = copy.deepcopy(COMMON_ARG_SPEC)
|
args = copy.deepcopy(SCALE_ARG_SPEC)
|
||||||
args.pop('state')
|
args.update(RESOURCE_ARG_SPEC)
|
||||||
args.pop('force')
|
args.update(NAME_ARG_SPEC)
|
||||||
args.update(AUTH_ARG_SPEC)
|
args.update(AUTH_ARG_SPEC)
|
||||||
args.update(SCALE_ARG_SPEC)
|
|
||||||
return args
|
return args
|
||||||
|
|
||||||
def scale(self, resource, existing_object, replicas, wait, wait_time):
|
def scale(self, resource, existing_object, replicas, wait, wait_time):
|
||||||
|
|||||||
@@ -26,40 +26,25 @@ description:
|
|||||||
- Analogous to `kubectl logs` or `oc logs`
|
- Analogous to `kubectl logs` or `oc logs`
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- community.kubernetes.k8s_auth_options
|
- community.kubernetes.k8s_auth_options
|
||||||
|
- community.kubernetes.k8s_name_options
|
||||||
options:
|
options:
|
||||||
api_version:
|
|
||||||
description:
|
|
||||||
- Use to specify the API version. in conjunction with I(kind), I(name), and I(namespace) to identify a
|
|
||||||
specific object.
|
|
||||||
- If using I(label_selector), cannot be overridden
|
|
||||||
default: v1
|
|
||||||
aliases:
|
|
||||||
- api
|
|
||||||
- version
|
|
||||||
type: str
|
|
||||||
kind:
|
kind:
|
||||||
description:
|
description:
|
||||||
- Use to specify an object model. Use in conjunction with I(api_version), I(name), and I(namespace) to identify a
|
- Use to specify an object model.
|
||||||
specific object.
|
- Use in conjunction with I(api_version), I(name), and I(namespace) to identify a specific object.
|
||||||
- If using I(label_selector), cannot be overridden
|
- If using I(label_selector), cannot be overridden.
|
||||||
required: no
|
type: str
|
||||||
default: Pod
|
default: Pod
|
||||||
type: str
|
|
||||||
namespace:
|
|
||||||
description:
|
|
||||||
- Use to specify an object namespace. Use in conjunction with I(api_version), I(kind), and I(name)
|
|
||||||
to identify a specific object.
|
|
||||||
type: str
|
|
||||||
name:
|
name:
|
||||||
description:
|
description:
|
||||||
- Use to specify an object name. Use in conjunction with I(api_version), I(kind) and I(namespace) to identify a
|
- Use to specify an object name.
|
||||||
specific object.
|
- Use in conjunction with I(api_version), I(kind) and I(namespace) to identify a specific object.
|
||||||
- Only one of I(name) or I(label_selector) may be provided
|
- Only one of I(name) or I(label_selector) may be provided.
|
||||||
type: str
|
type: str
|
||||||
label_selectors:
|
label_selectors:
|
||||||
description:
|
description:
|
||||||
- List of label selectors to use to filter results
|
- List of label selectors to use to filter results
|
||||||
- Only one of I(name) or I(label_selector) may be provided
|
- Only one of I(name) or I(label_selector) may be provided.
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
container:
|
container:
|
||||||
@@ -129,7 +114,7 @@ import copy
|
|||||||
from ansible.module_utils.six import PY2
|
from ansible.module_utils.six import PY2
|
||||||
|
|
||||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import KubernetesAnsibleModule
|
from ansible_collections.community.kubernetes.plugins.module_utils.common import KubernetesAnsibleModule
|
||||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import AUTH_ARG_SPEC
|
from ansible_collections.community.kubernetes.plugins.module_utils.common import AUTH_ARG_SPEC, NAME_ARG_SPEC
|
||||||
|
|
||||||
|
|
||||||
class KubernetesLogModule(KubernetesAnsibleModule):
|
class KubernetesLogModule(KubernetesAnsibleModule):
|
||||||
@@ -142,12 +127,10 @@ class KubernetesLogModule(KubernetesAnsibleModule):
|
|||||||
@property
|
@property
|
||||||
def argspec(self):
|
def argspec(self):
|
||||||
args = copy.deepcopy(AUTH_ARG_SPEC)
|
args = copy.deepcopy(AUTH_ARG_SPEC)
|
||||||
|
args.update(NAME_ARG_SPEC)
|
||||||
args.update(
|
args.update(
|
||||||
dict(
|
dict(
|
||||||
kind=dict(default='Pod'),
|
kind=dict(type='str', default='Pod'),
|
||||||
api_version=dict(default='v1', aliases=['api', 'version']),
|
|
||||||
name=dict(),
|
|
||||||
namespace=dict(),
|
|
||||||
container=dict(),
|
container=dict(),
|
||||||
label_selectors=dict(type='list', elements='str', default=[]),
|
label_selectors=dict(type='list', elements='str', default=[]),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -22,43 +22,10 @@ description:
|
|||||||
|
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- community.kubernetes.k8s_auth_options
|
- community.kubernetes.k8s_auth_options
|
||||||
|
- community.kubernetes.k8s_resource_options
|
||||||
|
- community.kubernetes.k8s_state_options
|
||||||
|
|
||||||
options:
|
options:
|
||||||
resource_definition:
|
|
||||||
description:
|
|
||||||
- A partial YAML definition of the Service object being created/updated. Here you can define Kubernetes
|
|
||||||
Service Resource parameters not covered by this module's parameters.
|
|
||||||
- "NOTE: I(resource_definition) has lower priority than module parameters. If you try to define e.g.
|
|
||||||
I(metadata.namespace) here, that value will be ignored and I(metadata) used instead."
|
|
||||||
aliases:
|
|
||||||
- definition
|
|
||||||
- inline
|
|
||||||
type: dict
|
|
||||||
src:
|
|
||||||
description:
|
|
||||||
- "Provide a path to a file containing a valid YAML definition of an object dated. Mutually
|
|
||||||
exclusive with I(resource_definition). NOTE: I(kind), I(api_version), I(resource_name), and I(namespace)
|
|
||||||
will be overwritten by corresponding values found in the configuration read in from the I(src) file."
|
|
||||||
- Reads from the local file system. To read from the Ansible controller's file system, use the file lookup
|
|
||||||
plugin or template lookup plugin, combined with the from_yaml filter, and pass the result to
|
|
||||||
I(resource_definition). See Examples below.
|
|
||||||
type: path
|
|
||||||
state:
|
|
||||||
description:
|
|
||||||
- Determines if an object should be created, patched, or deleted. When set to C(present), an object will be
|
|
||||||
created, if it does not already exist. If set to C(absent), an existing object will be deleted. If set to
|
|
||||||
C(present), an existing object will be patched, if its attributes differ from those specified using
|
|
||||||
module options and I(resource_definition).
|
|
||||||
default: present
|
|
||||||
choices:
|
|
||||||
- present
|
|
||||||
- absent
|
|
||||||
type: str
|
|
||||||
force:
|
|
||||||
description:
|
|
||||||
- If set to C(True), and I(state) is C(present), an existing object will be replaced.
|
|
||||||
default: false
|
|
||||||
type: bool
|
|
||||||
merge_type:
|
merge_type:
|
||||||
description:
|
description:
|
||||||
- Whether to override the default patch merge approach with a specific type. By default, the strategic
|
- Whether to override the default patch merge approach with a specific type. By default, the strategic
|
||||||
@@ -181,7 +148,7 @@ import traceback
|
|||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import AUTH_ARG_SPEC
|
from ansible_collections.community.kubernetes.plugins.module_utils.common import AUTH_ARG_SPEC, COMMON_ARG_SPEC, RESOURCE_ARG_SPEC
|
||||||
from ansible_collections.community.kubernetes.plugins.module_utils.raw import KubernetesRawModule
|
from ansible_collections.community.kubernetes.plugins.module_utils.raw import KubernetesRawModule
|
||||||
|
|
||||||
|
|
||||||
@@ -190,25 +157,10 @@ SERVICE_ARG_SPEC = {
|
|||||||
'type': 'bool',
|
'type': 'bool',
|
||||||
'default': False,
|
'default': False,
|
||||||
},
|
},
|
||||||
'state': {
|
|
||||||
'default': 'present',
|
|
||||||
'choices': ['present', 'absent'],
|
|
||||||
},
|
|
||||||
'force': {
|
|
||||||
'type': 'bool',
|
|
||||||
'default': False,
|
|
||||||
},
|
|
||||||
'resource_definition': {
|
|
||||||
'type': 'dict',
|
|
||||||
'aliases': ['definition', 'inline']
|
|
||||||
},
|
|
||||||
'name': {'required': True},
|
'name': {'required': True},
|
||||||
'namespace': {'required': True},
|
'namespace': {'required': True},
|
||||||
'merge_type': {'type': 'list', 'elements': 'str', 'choices': ['json', 'merge', 'strategic-merge']},
|
'merge_type': {'type': 'list', 'elements': 'str', 'choices': ['json', 'merge', 'strategic-merge']},
|
||||||
'selector': {'type': 'dict'},
|
'selector': {'type': 'dict'},
|
||||||
'src': {
|
|
||||||
'type': 'path',
|
|
||||||
},
|
|
||||||
'type': {
|
'type': {
|
||||||
'type': 'str',
|
'type': 'str',
|
||||||
'choices': [
|
'choices': [
|
||||||
@@ -240,6 +192,8 @@ class KubernetesService(KubernetesRawModule):
|
|||||||
def argspec(self):
|
def argspec(self):
|
||||||
""" argspec property builder """
|
""" argspec property builder """
|
||||||
argument_spec = copy.deepcopy(AUTH_ARG_SPEC)
|
argument_spec = copy.deepcopy(AUTH_ARG_SPEC)
|
||||||
|
argument_spec.update(COMMON_ARG_SPEC)
|
||||||
|
argument_spec.update(RESOURCE_ARG_SPEC)
|
||||||
argument_spec.update(SERVICE_ARG_SPEC)
|
argument_spec.update(SERVICE_ARG_SPEC)
|
||||||
return argument_spec
|
return argument_spec
|
||||||
|
|
||||||
|
|||||||
@@ -3,3 +3,4 @@ plugins/modules/k8s.py validate-modules:return-syntax-error
|
|||||||
plugins/modules/k8s_scale.py validate-modules:parameter-type-not-in-doc
|
plugins/modules/k8s_scale.py validate-modules:parameter-type-not-in-doc
|
||||||
plugins/modules/k8s_scale.py validate-modules:return-syntax-error
|
plugins/modules/k8s_scale.py validate-modules:return-syntax-error
|
||||||
plugins/modules/k8s_service.py validate-modules:return-syntax-error
|
plugins/modules/k8s_service.py validate-modules:return-syntax-error
|
||||||
|
plugins/modules/k8s_service.py validate-modules:parameter-type-not-in-doc
|
||||||
|
|||||||
@@ -3,3 +3,4 @@ plugins/modules/k8s.py validate-modules:return-syntax-error
|
|||||||
plugins/modules/k8s_scale.py validate-modules:parameter-type-not-in-doc
|
plugins/modules/k8s_scale.py validate-modules:parameter-type-not-in-doc
|
||||||
plugins/modules/k8s_scale.py validate-modules:return-syntax-error
|
plugins/modules/k8s_scale.py validate-modules:return-syntax-error
|
||||||
plugins/modules/k8s_service.py validate-modules:return-syntax-error
|
plugins/modules/k8s_service.py validate-modules:return-syntax-error
|
||||||
|
plugins/modules/k8s_service.py validate-modules:parameter-type-not-in-doc
|
||||||
|
|||||||
Reference in New Issue
Block a user