mirror of
https://github.com/openshift/community.okd.git
synced 2026-05-06 13:12:37 +00:00
update collection with latest feature from kubernetes.core (#181)
* Rebase code with kubernetes.core stable-2.4
This commit is contained in:
@@ -260,13 +260,9 @@ result:
|
||||
'''
|
||||
# ENDREMOVE (downstream)
|
||||
|
||||
try:
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import AnsibleModule
|
||||
except ImportError:
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
|
||||
NAME_ARG_SPEC, RESOURCE_ARG_SPEC, AUTH_ARG_SPEC, WAIT_ARG_SPEC, DELETE_OPTS_ARG_SPEC)
|
||||
NAME_ARG_SPEC, RESOURCE_ARG_SPEC, AUTH_ARG_SPEC, WAIT_ARG_SPEC, DELETE_OPTS_ARG_SPEC
|
||||
)
|
||||
|
||||
|
||||
def validate_spec():
|
||||
@@ -303,15 +299,9 @@ def main():
|
||||
('template', 'src'),
|
||||
]
|
||||
|
||||
module = AnsibleModule(argument_spec=argspec(), supports_check_mode=True, mutually_exclusive=mutually_exclusive)
|
||||
|
||||
from ansible_collections.community.okd.plugins.module_utils.k8s import OKDRawModule
|
||||
okdraw_module = OKDRawModule(module)
|
||||
|
||||
# remove_aliases from kubernetes.core's common requires the argspec attribute. Ideally, it should
|
||||
# read that throught the module class, but we cannot change that.
|
||||
okdraw_module.argspec = argspec()
|
||||
okdraw_module.execute_module()
|
||||
module = OKDRawModule(argument_spec=argspec(), supports_check_mode=True, mutually_exclusive=mutually_exclusive)
|
||||
module.run_module()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -194,7 +194,6 @@ builds:
|
||||
import copy
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import AUTH_ARG_SPEC
|
||||
|
||||
|
||||
@@ -213,17 +212,12 @@ def argument_spec():
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(argument_spec=argument_spec(), supports_check_mode=True)
|
||||
|
||||
from ansible_collections.community.okd.plugins.module_utils.openshift_groups import (
|
||||
OpenshiftGroupsSync
|
||||
)
|
||||
|
||||
try:
|
||||
openshift_groups = OpenshiftGroupsSync(module)
|
||||
openshift_groups.execute_module()
|
||||
except Exception as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
module = OpenshiftGroupsSync(argument_spec=argument_spec(), supports_check_mode=True)
|
||||
module.run_module()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -233,33 +233,20 @@ result:
|
||||
"""
|
||||
# ENDREMOVE (downstream)
|
||||
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
from ansible_collections.community.okd.plugins.module_utils.openshift_common import AnsibleOpenshiftModule
|
||||
|
||||
try:
|
||||
from kubernetes.dynamic.exceptions import DynamicApiError
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
HAS_KUBERNETES_COLLECTION = True
|
||||
k8s_collection_import_exception = None
|
||||
K8S_COLLECTION_ERROR = None
|
||||
except ImportError as e:
|
||||
HAS_KUBERNETES_COLLECTION = False
|
||||
k8s_collection_import_exception = e
|
||||
K8S_COLLECTION_ERROR = traceback.format_exc()
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
|
||||
AUTH_ARG_SPEC,
|
||||
WAIT_ARG_SPEC,
|
||||
)
|
||||
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.common import (
|
||||
K8sAnsibleMixin,
|
||||
get_api_client,
|
||||
)
|
||||
|
||||
|
||||
transforms = {
|
||||
"Build": "build.openshift.io/v1",
|
||||
"BuildConfig": "build.openshift.io/v1",
|
||||
@@ -268,24 +255,9 @@ transforms = {
|
||||
}
|
||||
|
||||
|
||||
class OpenShiftMigrateTemplateInstances(K8sAnsibleMixin):
|
||||
def __init__(self, module):
|
||||
self.module = module
|
||||
self.fail_json = self.module.fail_json
|
||||
self.exit_json = self.module.exit_json
|
||||
|
||||
if not HAS_KUBERNETES_COLLECTION:
|
||||
self.module.fail_json(
|
||||
msg="The kubernetes.core collection must be installed",
|
||||
exception=K8S_COLLECTION_ERROR,
|
||||
error=to_native(k8s_collection_import_exception),
|
||||
)
|
||||
|
||||
super(OpenShiftMigrateTemplateInstances, self).__init__(self.module)
|
||||
|
||||
self.params = self.module.params
|
||||
self.check_mode = self.module.check_mode
|
||||
self.client = get_api_client(self.module)
|
||||
class OpenShiftMigrateTemplateInstances(AnsibleOpenshiftModule):
|
||||
def __init__(self, **kwargs):
|
||||
super(OpenShiftMigrateTemplateInstances, self).__init__(**kwargs)
|
||||
|
||||
def patch_template_instance(self, resource, templateinstance):
|
||||
result = None
|
||||
@@ -293,7 +265,7 @@ class OpenShiftMigrateTemplateInstances(K8sAnsibleMixin):
|
||||
try:
|
||||
result = resource.status.patch(templateinstance)
|
||||
except Exception as exc:
|
||||
self.module.fail_json(
|
||||
self.fail_json(
|
||||
msg="Failed to migrate TemplateInstance {0} due to: {1}".format(
|
||||
templateinstance["metadata"]["name"], to_native(exc)
|
||||
)
|
||||
@@ -351,7 +323,7 @@ class OpenShiftMigrateTemplateInstances(K8sAnsibleMixin):
|
||||
reason=exc.reason,
|
||||
)
|
||||
except Exception as exc:
|
||||
self.module.fail_json(
|
||||
self.fail_json(
|
||||
msg="Failed to retrieve TemplateInstances in namespace '{0}': {1}".format(
|
||||
namespace, to_native(exc)
|
||||
),
|
||||
@@ -367,7 +339,7 @@ class OpenShiftMigrateTemplateInstances(K8sAnsibleMixin):
|
||||
|
||||
if ti_to_be_migrated:
|
||||
if self.check_mode:
|
||||
self.module.exit_json(
|
||||
self.exit_json(
|
||||
**{"changed": True, "result": ti_to_be_migrated}
|
||||
)
|
||||
else:
|
||||
@@ -377,7 +349,7 @@ class OpenShiftMigrateTemplateInstances(K8sAnsibleMixin):
|
||||
)
|
||||
results["changed"] = True
|
||||
|
||||
self.module.exit_json(**results)
|
||||
self.exit_json(**results)
|
||||
|
||||
|
||||
def argspec():
|
||||
@@ -391,10 +363,8 @@ def argspec():
|
||||
|
||||
def main():
|
||||
argument_spec = argspec()
|
||||
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
|
||||
openshift_process = OpenShiftMigrateTemplateInstances(module)
|
||||
openshift_process.argspec = argument_spec
|
||||
openshift_process.execute_module()
|
||||
module = OpenShiftMigrateTemplateInstances(argument_spec=argument_spec, supports_check_mode=True)
|
||||
module.run_module()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -101,7 +101,6 @@ group:
|
||||
|
||||
import copy
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import AUTH_ARG_SPEC
|
||||
|
||||
|
||||
@@ -119,16 +118,14 @@ def argument_spec():
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(argument_spec=argument_spec(),
|
||||
mutually_exclusive=[("name", "label_selectors")],
|
||||
supports_check_mode=True)
|
||||
|
||||
from ansible_collections.community.okd.plugins.module_utils.openshift_adm_prune_auth import (
|
||||
OpenShiftAdmPruneAuth)
|
||||
|
||||
adm_prune_auth = OpenShiftAdmPruneAuth(module)
|
||||
adm_prune_auth.argspec = argument_spec
|
||||
adm_prune_auth.execute_module()
|
||||
module = OpenShiftAdmPruneAuth(argument_spec=argument_spec(),
|
||||
mutually_exclusive=[("name", "label_selectors")],
|
||||
supports_check_mode=True)
|
||||
module.run_module()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -97,9 +97,7 @@ builds:
|
||||
|
||||
import copy
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import AUTH_ARG_SPEC
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
|
||||
def argument_spec():
|
||||
@@ -115,21 +113,11 @@ def argument_spec():
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(argument_spec=argument_spec(), supports_check_mode=True)
|
||||
|
||||
try:
|
||||
from ansible_collections.community.okd.plugins.module_utils.openshift_builds import (
|
||||
OpenShiftBuilds)
|
||||
from ansible_collections.community.okd.plugins.module_utils.openshift_builds import OpenShiftPruneBuilds
|
||||
|
||||
build = OpenShiftBuilds(module)
|
||||
build.argspec = argument_spec
|
||||
build.prune()
|
||||
except Exception as e:
|
||||
module.fail_json(
|
||||
msg="An error occurred while running openshift_adm_prune_builds",
|
||||
error=to_native(e),
|
||||
exception=e,
|
||||
)
|
||||
module = OpenShiftPruneBuilds(argument_spec=argument_spec(), supports_check_mode=True)
|
||||
module.run_module()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -69,7 +69,6 @@ replication_controllers:
|
||||
|
||||
import copy
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
try:
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import AUTH_ARG_SPEC
|
||||
except ImportError as e:
|
||||
@@ -89,13 +88,12 @@ def argument_spec():
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(argument_spec=argument_spec(), supports_check_mode=True)
|
||||
|
||||
from ansible_collections.community.okd.plugins.module_utils.openshift_adm_prune_deployments import (
|
||||
OpenShiftAdmPruneDeployment)
|
||||
|
||||
adm_prune_deployments = OpenShiftAdmPruneDeployment(module)
|
||||
adm_prune_deployments.execute()
|
||||
module = OpenShiftAdmPruneDeployment(argument_spec=argument_spec(), supports_check_mode=True)
|
||||
module.run_module()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -280,7 +280,6 @@ deleted_images:
|
||||
|
||||
import copy
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import AUTH_ARG_SPEC
|
||||
|
||||
|
||||
@@ -303,14 +302,13 @@ def argument_spec():
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(argument_spec=argument_spec(), supports_check_mode=True)
|
||||
|
||||
from ansible_collections.community.okd.plugins.module_utils.openshift_adm_prune_images import (
|
||||
OpenShiftAdmPruneImages)
|
||||
OpenShiftAdmPruneImages
|
||||
)
|
||||
|
||||
adm_prune_images = OpenShiftAdmPruneImages(module)
|
||||
adm_prune_images.argspec = argument_spec()
|
||||
adm_prune_images.execute_module()
|
||||
module = OpenShiftAdmPruneImages(argument_spec=argument_spec(), supports_check_mode=True)
|
||||
module.run_module()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -205,9 +205,7 @@ builds:
|
||||
|
||||
import copy
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import AUTH_ARG_SPEC
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
|
||||
def argument_spec():
|
||||
@@ -242,7 +240,10 @@ def main():
|
||||
mutually_exclusive = [
|
||||
('build_name', 'build_config_name'),
|
||||
]
|
||||
module = AnsibleModule(
|
||||
from ansible_collections.community.okd.plugins.module_utils.openshift_builds import (
|
||||
OpenShiftBuilds
|
||||
)
|
||||
module = OpenShiftBuilds(
|
||||
argument_spec=argument_spec(),
|
||||
mutually_exclusive=mutually_exclusive,
|
||||
required_one_of=[
|
||||
@@ -252,20 +253,7 @@ def main():
|
||||
]
|
||||
],
|
||||
)
|
||||
|
||||
try:
|
||||
from ansible_collections.community.okd.plugins.module_utils.openshift_builds import (
|
||||
OpenShiftBuilds)
|
||||
|
||||
build = OpenShiftBuilds(module)
|
||||
build.argspec = argument_spec
|
||||
build.execute_module()
|
||||
except Exception as e:
|
||||
module.fail_json(
|
||||
msg="An error occurred while running openshift_start_build module.",
|
||||
error=to_native(e),
|
||||
exception=e,
|
||||
)
|
||||
module.run_module()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -158,7 +158,6 @@ result:
|
||||
|
||||
import copy
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import AUTH_ARG_SPEC
|
||||
|
||||
|
||||
@@ -179,17 +178,16 @@ def argument_spec():
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
|
||||
from ansible_collections.community.okd.plugins.module_utils.openshift_import_image import (
|
||||
OpenShiftImportImage
|
||||
)
|
||||
|
||||
module = OpenShiftImportImage(
|
||||
argument_spec=argument_spec(),
|
||||
supports_check_mode=True
|
||||
)
|
||||
|
||||
from ansible_collections.community.okd.plugins.module_utils.openshift_import_image import (
|
||||
OpenShiftImportImage)
|
||||
|
||||
import_image = OpenShiftImportImage(module)
|
||||
import_image.argspec = argument_spec()
|
||||
import_image.execute_module()
|
||||
module.run_module()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -203,11 +203,6 @@ resources:
|
||||
'''
|
||||
# ENDREMOVE (downstream)
|
||||
|
||||
try:
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import AnsibleModule
|
||||
except ImportError:
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
|
||||
AUTH_ARG_SPEC, RESOURCE_ARG_SPEC, WAIT_ARG_SPEC
|
||||
)
|
||||
@@ -229,17 +224,12 @@ def argspec():
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = argspec()
|
||||
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
|
||||
|
||||
from ansible_collections.community.okd.plugins.module_utils.openshift_process import (
|
||||
OpenShiftProcess)
|
||||
|
||||
openshift_process = OpenShiftProcess(module)
|
||||
# remove_aliases from kubernetes.core's common requires the argspec attribute. Ideally, it should
|
||||
# read that throught the module class, but we cannot change that.
|
||||
openshift_process.argspec = argument_spec
|
||||
openshift_process.execute_module()
|
||||
module = OpenShiftProcess(argument_spec=argspec(), supports_check_mode=True)
|
||||
module.run_module()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -84,7 +84,6 @@ check:
|
||||
|
||||
import copy
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import AUTH_ARG_SPEC
|
||||
|
||||
|
||||
@@ -99,17 +98,16 @@ def argument_spec():
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
|
||||
from ansible_collections.community.okd.plugins.module_utils.openshift_registry import (
|
||||
OpenShiftRegistry
|
||||
)
|
||||
|
||||
module = OpenShiftRegistry(
|
||||
argument_spec=argument_spec(),
|
||||
supports_check_mode=True
|
||||
)
|
||||
|
||||
from ansible_collections.community.okd.plugins.module_utils.openshift_registry import (
|
||||
OpenShiftRegistry)
|
||||
|
||||
registry = OpenShiftRegistry(module)
|
||||
registry.argspec = argument_spec()
|
||||
registry.info()
|
||||
module.run_module()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -307,27 +307,19 @@ duration:
|
||||
# ENDREMOVE (downstream)
|
||||
|
||||
import copy
|
||||
import traceback
|
||||
|
||||
try:
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import AnsibleModule
|
||||
except ImportError:
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
from ansible_collections.community.okd.plugins.module_utils.openshift_common import AnsibleOpenshiftModule
|
||||
|
||||
try:
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.common import K8sAnsibleMixin, get_api_client
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.runner import perform_action
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.waiter import Waiter
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
|
||||
AUTH_ARG_SPEC, WAIT_ARG_SPEC, COMMON_ARG_SPEC
|
||||
)
|
||||
HAS_KUBERNETES_COLLECTION = True
|
||||
k8s_collection_import_exception = None
|
||||
K8S_COLLECTION_ERROR = None
|
||||
except ImportError as e:
|
||||
HAS_KUBERNETES_COLLECTION = False
|
||||
k8s_collection_import_exception = e
|
||||
K8S_COLLECTION_ERROR = traceback.format_exc()
|
||||
K8sAnsibleMixin = object
|
||||
pass
|
||||
AUTH_ARG_SPEC = WAIT_ARG_SPEC = COMMON_ARG_SPEC = {}
|
||||
|
||||
try:
|
||||
@@ -336,33 +328,18 @@ except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
class OpenShiftRoute(K8sAnsibleMixin):
|
||||
class OpenShiftRoute(AnsibleOpenshiftModule):
|
||||
|
||||
def __init__(self):
|
||||
self.module = AnsibleModule(
|
||||
super(OpenShiftRoute, self).__init__(
|
||||
argument_spec=self.argspec,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
self.fail_json = self.module.fail_json
|
||||
|
||||
if not HAS_KUBERNETES_COLLECTION:
|
||||
self.module.fail_json(
|
||||
msg="The kubernetes.core collection must be installed",
|
||||
exception=K8S_COLLECTION_ERROR,
|
||||
error=to_native(k8s_collection_import_exception)
|
||||
)
|
||||
|
||||
super(OpenShiftRoute, self).__init__(self.module)
|
||||
|
||||
self.params = self.module.params
|
||||
# TODO: should probably make it so that at least some of these aren't required for perform_action to work
|
||||
# Or at least explicitly pass them in
|
||||
self.append_hash = False
|
||||
self.apply = False
|
||||
self.check_mode = self.module.check_mode
|
||||
self.warnings = []
|
||||
self.params['merge_type'] = None
|
||||
self.client = get_api_client(self.module)
|
||||
|
||||
@property
|
||||
def argspec(self):
|
||||
@@ -391,7 +368,6 @@ class OpenShiftRoute(K8sAnsibleMixin):
|
||||
return spec
|
||||
|
||||
def execute_module(self):
|
||||
v1_routes = self.find_resource('Route', 'route.openshift.io/v1', fail=True)
|
||||
|
||||
service_name = self.params.get('service')
|
||||
namespace = self.params['namespace']
|
||||
@@ -457,13 +433,15 @@ class OpenShiftRoute(K8sAnsibleMixin):
|
||||
tls_dest_ca_cert=tls_dest_ca_cert,
|
||||
)
|
||||
|
||||
result = self.perform_action(v1_routes, route)
|
||||
result = perform_action(self.svc, route, self.params)
|
||||
timeout = self.params.get('wait_timeout')
|
||||
sleep = self.params.get('wait_sleep')
|
||||
if custom_wait:
|
||||
success, result['result'], result['duration'] = self._wait_for(v1_routes, route_name, namespace, wait_predicate, sleep, timeout, state)
|
||||
v1_routes = self.find_resource('Route', 'route.openshift.io/v1', fail=True)
|
||||
waiter = Waiter(self.client, v1_routes, wait_predicate)
|
||||
success, result['result'], result['duration'] = waiter.wait(timeout=timeout, sleep=sleep, name=route_name, namespace=namespace)
|
||||
|
||||
self.module.exit_json(**result)
|
||||
self.exit_json(**result)
|
||||
|
||||
def build_route_spec(self, service_name, namespace, port=None, wildcard_policy=None, hostname=None, path=None, termination_type=None,
|
||||
tls_insecure_policy=None, tls_ca_cert=None, tls_cert=None, tls_key=None, tls_dest_ca_cert=None):
|
||||
@@ -472,14 +450,14 @@ class OpenShiftRoute(K8sAnsibleMixin):
|
||||
target_service = v1_services.get(name=service_name, namespace=namespace)
|
||||
except NotFoundError:
|
||||
if not port:
|
||||
self.module.fail_json(msg="You need to provide the 'port' argument when exposing a non-existent service")
|
||||
self.fail_json(msg="You need to provide the 'port' argument when exposing a non-existent service")
|
||||
target_service = None
|
||||
except DynamicApiError as exc:
|
||||
self.module.fail_json(msg='Failed to retrieve service to be exposed: {0}'.format(exc.body),
|
||||
error=exc.status, status=exc.status, reason=exc.reason)
|
||||
self.fail_json(msg='Failed to retrieve service to be exposed: {0}'.format(exc.body),
|
||||
error=exc.status, status=exc.status, reason=exc.reason)
|
||||
except Exception as exc:
|
||||
self.module.fail_json(msg='Failed to retrieve service to be exposed: {0}'.format(to_native(exc)),
|
||||
error='', status='', reason='')
|
||||
self.fail_json(msg='Failed to retrieve service to be exposed: {0}'.format(to_native(exc)),
|
||||
error='', status='', reason='')
|
||||
|
||||
route_spec = {
|
||||
'tls': {},
|
||||
@@ -501,27 +479,27 @@ class OpenShiftRoute(K8sAnsibleMixin):
|
||||
route_spec['tls']['insecureEdgeTerminationPolicy'] = tls_insecure_policy.capitalize()
|
||||
elif termination_type == 'passthrough':
|
||||
if tls_insecure_policy != 'redirect':
|
||||
self.module.fail_json("'redirect' is the only supported insecureEdgeTerminationPolicy for passthrough routes")
|
||||
self.fail_json("'redirect' is the only supported insecureEdgeTerminationPolicy for passthrough routes")
|
||||
route_spec['tls']['insecureEdgeTerminationPolicy'] = tls_insecure_policy.capitalize()
|
||||
elif termination_type == 'reencrypt':
|
||||
self.module.fail_json("'tls.insecure_policy' is not supported with reencrypt routes")
|
||||
self.fail_json("'tls.insecure_policy' is not supported with reencrypt routes")
|
||||
else:
|
||||
route_spec['tls']['insecureEdgeTerminationPolicy'] = None
|
||||
if tls_ca_cert:
|
||||
if termination_type == 'passthrough':
|
||||
self.module.fail_json("'tls.ca_certificate' is not supported with passthrough routes")
|
||||
self.fail_json("'tls.ca_certificate' is not supported with passthrough routes")
|
||||
route_spec['tls']['caCertificate'] = tls_ca_cert
|
||||
if tls_cert:
|
||||
if termination_type == 'passthrough':
|
||||
self.module.fail_json("'tls.certificate' is not supported with passthrough routes")
|
||||
self.fail_json("'tls.certificate' is not supported with passthrough routes")
|
||||
route_spec['tls']['certificate'] = tls_cert
|
||||
if tls_key:
|
||||
if termination_type == 'passthrough':
|
||||
self.module.fail_json("'tls.key' is not supported with passthrough routes")
|
||||
self.fail_json("'tls.key' is not supported with passthrough routes")
|
||||
route_spec['tls']['key'] = tls_key
|
||||
if tls_dest_ca_cert:
|
||||
if termination_type != 'reencrypt':
|
||||
self.module.fail_json("'destination_certificate' is only valid for reencrypt routes")
|
||||
self.fail_json("'destination_certificate' is only valid for reencrypt routes")
|
||||
route_spec['tls']['destinationCACertificate'] = tls_dest_ca_cert
|
||||
else:
|
||||
route_spec['tls'] = None
|
||||
@@ -557,7 +535,7 @@ def wait_predicate(route):
|
||||
|
||||
|
||||
def main():
|
||||
OpenShiftRoute().execute_module()
|
||||
OpenShiftRoute().run_module()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user