diff --git a/changelogs/fragments/20250916-skip-schema-validation.yaml b/changelogs/fragments/20250916-skip-schema-validation.yaml
new file mode 100644
index 00000000..3706b764
--- /dev/null
+++ b/changelogs/fragments/20250916-skip-schema-validation.yaml
@@ -0,0 +1,2 @@
+minor_changes:
+ - Added support of skip-schema-validation in `helm` module (https://github.com/ansible-collections/kubernetes.core/pull/995)
diff --git a/docs/kubernetes.core.helm_module.rst b/docs/kubernetes.core.helm_module.rst
index 87147138..3896a82a 100644
--- a/docs/kubernetes.core.helm_module.rst
+++ b/docs/kubernetes.core.helm_module.rst
@@ -622,6 +622,27 @@ Parameters
Skip custom resource definitions when installing or upgrading.
+
|
diff --git a/plugins/modules/helm.py b/plugins/modules/helm.py
index 84d38759..681b24db 100644
--- a/plugins/modules/helm.py
+++ b/plugins/modules/helm.py
@@ -251,6 +251,13 @@ options:
type: bool
default: False
version_added: 6.1.0
+ skip_schema_validation:
+ description:
+ - Disables JSON schema validation for Chart and values.
+ - This feature requires helm >= 3.16.0
+ type: bool
+ default: False
+ version_added: 6.2.0
extends_documentation_fragment:
- kubernetes.core.helm_common_options
"""
@@ -568,6 +575,7 @@ def deploy(
insecure_skip_tls_verify=False,
plain_http=False,
take_ownership=False,
+ skip_schema_validation=False,
):
"""
Install/upgrade/rollback release chart
@@ -658,6 +666,17 @@ def deploy(
if set_value_args:
deploy_command += " " + set_value_args
+ if skip_schema_validation:
+ helm_version = module.get_helm_version()
+ if LooseVersion(helm_version) < LooseVersion("3.16.0"):
+ module.fail_json(
+ msg="skip_schema_validation requires helm >= 3.16.0, current version is {0}".format(
+ helm_version
+ )
+ )
+ else:
+ deploy_command += " --skip-schema-validation"
+
deploy_command += " " + release_name + f" '{chart_name}'"
return deploy_command
@@ -731,6 +750,7 @@ def helmdiff_check(
reset_then_reuse_values=False,
insecure_skip_tls_verify=False,
plain_http=False,
+ skip_schema_validation=False,
):
"""
Use helm diff to determine if a release would change by upgrading a chart.
@@ -786,6 +806,17 @@ def helmdiff_check(
if insecure_skip_tls_verify:
cmd += " --insecure-skip-tls-verify"
+ if skip_schema_validation:
+ helm_version = module.get_helm_version()
+ if LooseVersion(helm_version) < LooseVersion("3.16.0"):
+ module.fail_json(
+ msg="skip_schema_validation requires helm >= 3.16.0, current version is {0}".format(
+ helm_version
+ )
+ )
+ else:
+ cmd += " --skip-schema-validation"
+
if plain_http:
helm_version = module.get_helm_version()
if LooseVersion(helm_version) < LooseVersion("3.13.0"):
@@ -862,6 +893,7 @@ def argument_spec():
),
plain_http=dict(type="bool", default=False),
take_ownership=dict(type="bool", default=False),
+ skip_schema_validation=dict(type="bool", default=False),
)
)
return arg_spec
@@ -918,6 +950,7 @@ def main():
insecure_skip_tls_verify = module.params.get("insecure_skip_tls_verify")
plain_http = module.params.get("plain_http")
take_ownership = module.params.get("take_ownership")
+ skip_schema_validation = module.params.get("skip_schema_validation")
if update_repo_cache:
run_repo_update(module)
@@ -945,6 +978,15 @@ def main():
)
)
+ if skip_schema_validation:
+ helm_version = module.get_helm_version()
+ if LooseVersion(helm_version) < LooseVersion("3.16.0"):
+ module.fail_json(
+ msg="skip_schema_validation requires helm >= 3.16.0, current version is {0}".format(
+ helm_version
+ )
+ )
+
opt_result = {}
if release_state == "absent" and release_status is not None:
# skip release statuses 'uninstalled' and 'uninstalling'
@@ -1037,6 +1079,7 @@ def main():
reset_then_reuse_values=reset_then_reuse_values,
insecure_skip_tls_verify=insecure_skip_tls_verify,
plain_http=plain_http,
+ skip_schema_validation=skip_schema_validation,
)
changed = True
@@ -1065,6 +1108,7 @@ def main():
reset_then_reuse_values=reset_then_reuse_values,
insecure_skip_tls_verify=insecure_skip_tls_verify,
plain_http=plain_http,
+ skip_schema_validation=skip_schema_validation,
)
if would_change and module._diff:
opt_result["diff"] = {"prepared": prepared}
@@ -1104,6 +1148,7 @@ def main():
insecure_skip_tls_verify=insecure_skip_tls_verify,
plain_http=plain_http,
take_ownership=take_ownership,
+ skip_schema_validation=skip_schema_validation,
)
changed = True
diff --git a/tests/integration/targets/helm/defaults/main.yml b/tests/integration/targets/helm/defaults/main.yml
index 9ef99a16..3aa59c0e 100644
--- a/tests/integration/targets/helm/defaults/main.yml
+++ b/tests/integration/targets/helm/defaults/main.yml
@@ -30,3 +30,4 @@ test_namespace:
- "helm-reset-then-reuse-values"
- "helm-insecure"
- "helm-test-take-ownership"
+ - "helm-skip-schema-validation"
diff --git a/tests/integration/targets/helm/tasks/run_test.yml b/tests/integration/targets/helm/tasks/run_test.yml
index 0ae279a3..d500f7e5 100644
--- a/tests/integration/targets/helm/tasks/run_test.yml
+++ b/tests/integration/targets/helm/tasks/run_test.yml
@@ -50,6 +50,9 @@
- name: Test take ownership flag feature
include_tasks: test_helm_take_ownership.yml
+- name: Test helm skip_schema_validation
+ include_tasks: test_skip_schema_validation.yml
+
- name: Clean helm install
file:
path: "{{ item }}"
diff --git a/tests/integration/targets/helm/tasks/test_skip_schema_validation.yml b/tests/integration/targets/helm/tasks/test_skip_schema_validation.yml
new file mode 100644
index 00000000..f3afe574
--- /dev/null
+++ b/tests/integration/targets/helm/tasks/test_skip_schema_validation.yml
@@ -0,0 +1,48 @@
+---
+- name: Test helm skip_schema_validation
+ vars:
+ helm_namespace: "{{ test_namespace[14] }}"
+ chart_release_values:
+ replica:
+ replicaCount: 3
+ master:
+ count: 1
+ kind: Deployment
+ block:
+ - name: Chart installation
+ helm:
+ binary_path: "{{ helm_binary }}"
+ chart_ref: oci://registry-1.docker.io/bitnamicharts/redis
+ release_name: test-redis
+ release_namespace: "{{ helm_namespace }}"
+ create_namespace: true
+ release_values: "{{ chart_release_values }}"
+ skip_schema_validation: true
+ register: install
+ ignore_errors: true
+
+ - name: Debug install result
+ debug:
+ var: install
+
+ - name: Validate skip_schema_validation with helm >= 3.16.0 works
+ assert:
+ that:
+ - install is changed
+ - "'--skip-schema-validation' in install.command"
+ when: "helm_version is ansible.builtin.version('v3.16.0', '>=')"
+
+ - name: Validate skip_schema_validation with helm < 3.16.0 fails
+ assert:
+ that:
+ - install is failed
+ - "'skip_schema_validation requires helm >= 3.16.0' in install.msg"
+ when: "helm_version is ansible.builtin.version('v3.16.0', '<')"
+
+ always:
+ - name: Remove helm namespace
+ k8s:
+ api_version: v1
+ kind: Namespace
+ name: "{{ helm_namespace }}"
+ state: absent
|