mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-07 21:42:38 +00:00
helm - add support for -set options when running helm install (#546)
helm - add support for -set options when running helm install SUMMARY helm support setting options -set, -set-string, -set-file and -set-json when running helm install ISSUE TYPE Feature Pull Request COMPONENT NAME helm ADDITIONAL INFORMATION Reviewed-by: Alina Buzachis <None> Reviewed-by: Bikouo Aubin <None> Reviewed-by: Mike Graves <mgraves@redhat.com>
This commit is contained in:
@@ -1,9 +1,4 @@
|
||||
# slow - 11min
|
||||
slow
|
||||
time=334
|
||||
time=100
|
||||
helm_info
|
||||
helm_plugin
|
||||
helm_plugin_info
|
||||
helm_repository
|
||||
helm_template
|
||||
helm_pull
|
||||
|
||||
@@ -14,20 +14,13 @@ chart_test_values:
|
||||
revisionHistoryLimit: 0
|
||||
myValue: "changed"
|
||||
|
||||
default_kubeconfig_path: "~/.kube/config"
|
||||
|
||||
test_namespace:
|
||||
- "helm-diff"
|
||||
- "helm-envvars"
|
||||
- "helm-test-crds"
|
||||
- "helm-uninstall"
|
||||
- "helm-not-installed"
|
||||
- "helm-crd"
|
||||
- "helm-url"
|
||||
- "helm-repository"
|
||||
- "helm-read-envvars"
|
||||
- "helm-dep-update"
|
||||
- "helm-local-path-001"
|
||||
- "helm-local-path-002"
|
||||
- "helm-local-path-003"
|
||||
- "helm-dep"
|
||||
- "helm-in-memory-kubeconfig"
|
||||
- "helm-kubeconfig-with-insecure-skip-tls-verify"
|
||||
- "helm-kubeconfig-with-ca-cert"
|
||||
- "helm-from-repository"
|
||||
- "helm-from-url"
|
||||
|
||||
@@ -10,14 +10,12 @@
|
||||
include_tasks: test_helm_not_installed.yml
|
||||
|
||||
- name: "Install {{ helm_version }}"
|
||||
include_tasks: install.yml
|
||||
include_role:
|
||||
name: install_helm
|
||||
|
||||
- name: "Ensure we honor the environment variables"
|
||||
include_tasks: test_read_envvars.yml
|
||||
|
||||
- name: tests_repository
|
||||
include_tasks: tests_repository.yml
|
||||
|
||||
- name: Deploy charts
|
||||
include_tasks: "tests_chart/{{ test_chart_type }}.yml"
|
||||
loop_control:
|
||||
@@ -30,12 +28,6 @@
|
||||
- name: test helm dependency update
|
||||
include_tasks: test_up_dep.yml
|
||||
|
||||
- name: Test helm plugin
|
||||
include_tasks: tests_helm_plugin.yml
|
||||
|
||||
- name: Test helm diff
|
||||
include_tasks: tests_helm_diff.yml
|
||||
|
||||
- name: Test helm uninstall
|
||||
include_tasks: test_helm_uninstall.yml
|
||||
|
||||
@@ -43,12 +35,6 @@
|
||||
- name: Test Skip CRDS feature in helm chart install
|
||||
include_tasks: test_crds.yml
|
||||
|
||||
- name: Test helm modules with custom kube config, validate_certs and/or ca_cert
|
||||
include_tasks: tests_helm_kubeconfig.yml
|
||||
|
||||
- name: Test helm pull
|
||||
include_tasks: tests_helm_pull.yml
|
||||
|
||||
- name: Clean helm install
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
- name: Test CRDs
|
||||
vars:
|
||||
test_chart: "test-crds"
|
||||
helm_namespace: "{{ test_namespace[0] }}"
|
||||
block:
|
||||
- name: Create namespace
|
||||
k8s:
|
||||
kind: Namespace
|
||||
name: "{{ test_namespace[4] }}"
|
||||
name: "{{ helm_namespace }}"
|
||||
|
||||
- name: Copy test chart
|
||||
copy:
|
||||
@@ -17,7 +18,7 @@
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_ref: "/tmp/helm_test_crds/{{ test_chart }}"
|
||||
namespace: "{{ test_namespace[4] }}"
|
||||
namespace: "{{ helm_namespace }}"
|
||||
name: test-crds
|
||||
skip_crds: true
|
||||
register: install
|
||||
@@ -33,7 +34,7 @@
|
||||
apiVersion: ansible.com/v1
|
||||
kind: Foo
|
||||
metadata:
|
||||
namespace: "{{ test_namespace[4] }}"
|
||||
namespace: "{{ helm_namespace }}"
|
||||
name: test-foo
|
||||
foobar: footest
|
||||
ignore_errors: true
|
||||
@@ -48,7 +49,7 @@
|
||||
- name: Uninstall chart
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
namespace: "{{ test_namespace[4] }}"
|
||||
namespace: "{{ helm_namespace }}"
|
||||
name: test-crds
|
||||
state: absent
|
||||
|
||||
@@ -56,7 +57,7 @@
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_ref: "/tmp/helm_test_crds/{{ test_chart }}"
|
||||
namespace: "{{ test_namespace[4] }}"
|
||||
namespace: "{{ helm_namespace }}"
|
||||
name: test-crds
|
||||
|
||||
- name: Create custom resource
|
||||
@@ -65,7 +66,7 @@
|
||||
apiVersion: ansible.com/v1
|
||||
kind: Foo
|
||||
metadata:
|
||||
namespace: "{{ test_namespace[4] }}"
|
||||
namespace: "{{ helm_namespace }}"
|
||||
name: test-foo
|
||||
foobar: footest
|
||||
register: result
|
||||
@@ -85,7 +86,7 @@
|
||||
- name: Remove namespace
|
||||
k8s:
|
||||
kind: Namespace
|
||||
name: "{{ test_namespace[4] }}"
|
||||
name: "{{ helm_namespace }}"
|
||||
state: absent
|
||||
ignore_errors: true
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
binary_path: "{{ helm_binary}}_fake"
|
||||
name: test
|
||||
chart_ref: "{{ chart_test }}"
|
||||
namespace: "{{ test_namespace[3] }}"
|
||||
namespace: "helm-test"
|
||||
ignore_errors: yes
|
||||
register: helm_missing_binary
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
version: "3.7.0"
|
||||
register: test_version
|
||||
|
||||
- block:
|
||||
- set_fact:
|
||||
chart_source: "https://github.com/kubernetes/kube-state-metrics/releases/download/kube-state-metrics-helm-chart-2.13.3/kube-state-metrics-2.13.3.tgz"
|
||||
chart_name: "test-wait-uninstall"
|
||||
helm_namespace: "{{ test_namespace[2] }}"
|
||||
- vars:
|
||||
chart_source: "https://github.com/kubernetes/kube-state-metrics/releases/download/kube-state-metrics-helm-chart-2.13.3/kube-state-metrics-2.13.3.tgz"
|
||||
chart_name: "test-wait-uninstall"
|
||||
helm_namespace: "{{ test_namespace[1] }}"
|
||||
block:
|
||||
|
||||
- name: Install chart
|
||||
helm:
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
binary_path: "{{ helm_binary }}"
|
||||
state: absent
|
||||
name: does-not-exist
|
||||
namespace: "{{ test_namespace[1] }}"
|
||||
namespace: "{{ helm_namespace }}"
|
||||
environment:
|
||||
K8S_AUTH_HOST: somewhere
|
||||
vars:
|
||||
helm_namespace: "{{ test_namespace[2] }}"
|
||||
register: _helm_result
|
||||
failed_when: '"http://somewhere/version" not in _helm_result.stderr'
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# Helm module
|
||||
- name: "Test dependency update for helm module"
|
||||
vars:
|
||||
helm_namespace: "{{ test_namespace[3] }}"
|
||||
block:
|
||||
- name: copy chart
|
||||
copy:
|
||||
@@ -9,9 +11,6 @@
|
||||
- test-chart
|
||||
- dep-up
|
||||
|
||||
- set_fact:
|
||||
helm_namespace: "{{ test_namespace[10] }}"
|
||||
|
||||
- name: "Test chart with dependency_update false"
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
@@ -81,8 +80,6 @@
|
||||
kind: Namespace
|
||||
name: "{{ helm_namespace }}"
|
||||
state: absent
|
||||
wait: true
|
||||
wait_timeout: 180
|
||||
|
||||
- name: "Remove charts"
|
||||
file:
|
||||
@@ -153,14 +150,6 @@
|
||||
success_msg: "subchart not exist in the charts directory"
|
||||
fail_msg: "There is no Subchart pulled"
|
||||
always:
|
||||
- name: Remove helm namespace
|
||||
k8s:
|
||||
api_version: v1
|
||||
kind: Namespace
|
||||
name: "{{ helm_namespace }}"
|
||||
state: absent
|
||||
wait: true
|
||||
wait_timeout: 180
|
||||
|
||||
- name: "Remove charts"
|
||||
file:
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
chart_test_version: "{{ chart_test_version_local_path }}"
|
||||
chart_test_version_upgrade: "{{ chart_test_version_upgrade_local_path }}"
|
||||
chart_name: "local-path-001"
|
||||
helm_namespace: "{{ test_namespace[7] }}"
|
||||
helm_namespace: "{{ test_namespace[4] }}"
|
||||
|
||||
- name: Test appVersion idempotence
|
||||
vars:
|
||||
@@ -69,7 +69,7 @@
|
||||
chart_source: "/tmp/helm_test_appversion/test-chart/{{ chart_test }}-{{ chart_test_app_version }}-{{ chart_test_version }}.tgz"
|
||||
chart_source_upgrade: "/tmp/helm_test_appversion/test-chart/{{ chart_test }}-{{ chart_test_upgrade_app_version }}-{{ chart_test_version_upgrade }}.tgz"
|
||||
chart_name: "local-path-002"
|
||||
helm_namespace: "{{ test_namespace[8] }}"
|
||||
helm_namespace: "{{ test_namespace[5] }}"
|
||||
|
||||
- name: Test appVersion handling when null
|
||||
vars:
|
||||
@@ -99,7 +99,7 @@
|
||||
chart_source: "/tmp/helm_test_appversion/test-null/{{ chart_test }}/"
|
||||
chart_source_upgrade: "{{ chart_test }}-{{ chart_test_version_upgrade }}.tgz"
|
||||
chart_name: "local-path-003"
|
||||
helm_namespace: "{{ test_namespace[9] }}"
|
||||
helm_namespace: "{{ test_namespace[6] }}"
|
||||
|
||||
- name: Remove clone repos
|
||||
file:
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
chart_source: "test_helm/{{ chart_test }}"
|
||||
chart_source_version: "{{ chart_test_version }}"
|
||||
chart_source_version_upgrade: "{{ chart_test_version_upgrade }}"
|
||||
helm_namespace: "{{ test_namespace[6] }}"
|
||||
helm_namespace: "{{ test_namespace[7] }}"
|
||||
|
||||
- name: Remove chart repo
|
||||
helm_repository:
|
||||
|
||||
@@ -5,4 +5,4 @@
|
||||
source: url
|
||||
chart_source: "https://github.com/kubernetes/ingress-nginx/releases/download/helm-chart-{{ chart_test_version }}/{{ chart_test }}-{{ chart_test_version }}.tgz"
|
||||
chart_source_upgrade: "https://github.com/kubernetes/ingress-nginx/releases/download/helm-chart-{{ chart_test_version_upgrade }}/{{ chart_test }}-{{ chart_test_version_upgrade }}.tgz"
|
||||
helm_namespace: "{{ test_namespace[5] }}"
|
||||
helm_namespace: "{{ test_namespace[8] }}"
|
||||
|
||||
3
tests/integration/targets/helm_diff/aliases
Normal file
3
tests/integration/targets/helm_diff/aliases
Normal file
@@ -0,0 +1,3 @@
|
||||
time=40
|
||||
helm_plugin
|
||||
helm
|
||||
3
tests/integration/targets/helm_diff/defaults/main.yml
Normal file
3
tests/integration/targets/helm_diff/defaults/main.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
helm_binary: "/tmp/helm/{{ ansible_system | lower }}-amd64/helm"
|
||||
helm_namespace: helm-diff
|
||||
@@ -0,0 +1,6 @@
|
||||
apiVersion: v2
|
||||
name: test-chart
|
||||
description: A chart used in molecule tests
|
||||
type: application
|
||||
version: 0.1.0
|
||||
appVersion: "default"
|
||||
@@ -0,0 +1,6 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: test-chart-configmap
|
||||
data:
|
||||
myValue: {{ default "test" .Values.myValue }}
|
||||
4
tests/integration/targets/helm_diff/meta/main.yml
Normal file
4
tests/integration/targets/helm_diff/meta/main.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
dependencies:
|
||||
- remove_namespace
|
||||
- install_helm
|
||||
@@ -5,8 +5,6 @@
|
||||
redis_chart_version: '17.0.5'
|
||||
|
||||
block:
|
||||
- set_fact:
|
||||
helm_namespace: "{{ test_namespace[0] }}"
|
||||
|
||||
- name: Install helm diff
|
||||
helm_plugin:
|
||||
2
tests/integration/targets/helm_kubeconfig/aliases
Normal file
2
tests/integration/targets/helm_kubeconfig/aliases
Normal file
@@ -0,0 +1,2 @@
|
||||
time=40
|
||||
helm
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
helm_binary: "/tmp/helm/{{ ansible_system | lower }}-amd64/helm"
|
||||
default_kubeconfig_path: "~/.kube/config"
|
||||
test_namespace:
|
||||
- "helm-in-memory-kubeconfig"
|
||||
- "helm-kubeconfig-with-ca-cert"
|
||||
- "helm-kubeconfig-with-insecure-skip-tls-verify"
|
||||
3
tests/integration/targets/helm_kubeconfig/meta/main.yml
Normal file
3
tests/integration/targets/helm_kubeconfig/meta/main.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
dependencies:
|
||||
- remove_namespace
|
||||
@@ -3,7 +3,7 @@
|
||||
custom_config: "{{ lookup('file', default_kubeconfig_path | expanduser) | from_yaml }}"
|
||||
|
||||
- name: Test helm modules using in-memory kubeconfig
|
||||
include_tasks: "../tests_helm_auth.yml"
|
||||
include_tasks: "tests_helm_auth.yml"
|
||||
vars:
|
||||
test_kubeconfig: "{{ custom_config }}"
|
||||
helm_namespace: "{{ test_namespace[11] }}"
|
||||
helm_namespace: "{{ test_namespace[0] }}"
|
||||
@@ -60,13 +60,13 @@
|
||||
- '"Error: Kubernetes cluster unreachable" in _install.msg'
|
||||
|
||||
- name: Test helm modules using in-memory kubeconfig
|
||||
include_tasks: "../tests_helm_auth.yml"
|
||||
include_tasks: "tests_helm_auth.yml"
|
||||
vars:
|
||||
test_kubeconfig: "{{ tfile.path }}"
|
||||
test_ca_cert: "{{ ca_file.path }}"
|
||||
|
||||
vars:
|
||||
helm_namespace: "{{ test_namespace[13] }}"
|
||||
helm_namespace: "{{ test_namespace[1] }}"
|
||||
|
||||
always:
|
||||
- name: Delete temporary file
|
||||
@@ -51,13 +51,13 @@
|
||||
- '"Error: Kubernetes cluster unreachable" in _install.msg'
|
||||
|
||||
- name: Test helm modules using in-memory kubeconfig
|
||||
include_tasks: "../tests_helm_auth.yml"
|
||||
include_tasks: "tests_helm_auth.yml"
|
||||
vars:
|
||||
test_kubeconfig: "{{ tfile.path }}"
|
||||
test_validate_certs: false
|
||||
|
||||
vars:
|
||||
helm_namespace: "{{ test_namespace[12] }}"
|
||||
helm_namespace: "{{ test_namespace[2] }}"
|
||||
|
||||
always:
|
||||
- name: Delete temporary file
|
||||
@@ -1,9 +1,9 @@
|
||||
---
|
||||
- name: Test helm with in-memory kubeconfig
|
||||
include_tasks: "tests_kubeconfig/from_in_memory_kubeconfig.yml"
|
||||
include_tasks: "from_in_memory_kubeconfig.yml"
|
||||
|
||||
- name: Test helm with custom kubeconfig and validate_certs=false
|
||||
include_tasks: "tests_kubeconfig/from_kubeconfig_with_validate_certs.yml"
|
||||
include_tasks: "from_kubeconfig_with_validate_certs.yml"
|
||||
loop_control:
|
||||
loop_var: test_helm_version
|
||||
with_items:
|
||||
@@ -11,12 +11,9 @@
|
||||
- "v3.8.2"
|
||||
|
||||
- name: Test helm with custom kubeconfig and ca_cert
|
||||
include_tasks: "tests_kubeconfig/from_kubeconfig_with_cacert.yml"
|
||||
include_tasks: "from_kubeconfig_with_cacert.yml"
|
||||
loop_control:
|
||||
loop_var: test_helm_version
|
||||
with_items:
|
||||
- "v3.5.1"
|
||||
- "v3.4.2"
|
||||
|
||||
- name: install default helm archive version
|
||||
include_tasks: install.yml
|
||||
@@ -8,9 +8,10 @@
|
||||
- name: Install helm binary
|
||||
block:
|
||||
- name: "Install {{ test_helm_version }}"
|
||||
include_tasks: install.yml
|
||||
include_role:
|
||||
name: install_helm
|
||||
vars:
|
||||
helm_archive_name: "helm-{{ test_helm_version }}-{{ ansible_system | lower }}-amd64.tar.gz"
|
||||
helm_version: "{{ test_helm_version }}"
|
||||
|
||||
when: test_helm_version is defined
|
||||
|
||||
3
tests/integration/targets/helm_plugin/aliases
Normal file
3
tests/integration/targets/helm_plugin/aliases
Normal file
@@ -0,0 +1,3 @@
|
||||
time=30
|
||||
helm_plugin
|
||||
helm_plugin_info
|
||||
2
tests/integration/targets/helm_plugin/defaults/main.yml
Normal file
2
tests/integration/targets/helm_plugin/defaults/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
helm_binary: "/tmp/helm/{{ ansible_system | lower }}-amd64/helm"
|
||||
3
tests/integration/targets/helm_plugin/meta/main.yml
Normal file
3
tests/integration/targets/helm_plugin/meta/main.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
dependencies:
|
||||
- install_helm
|
||||
2
tests/integration/targets/helm_pull/aliases
Normal file
2
tests/integration/targets/helm_pull/aliases
Normal file
@@ -0,0 +1,2 @@
|
||||
time=27
|
||||
helm_pull
|
||||
@@ -36,7 +36,7 @@
|
||||
# Testing helm pull with helm version == 2.3.0
|
||||
- block:
|
||||
- name: Assert that helm pull failed with helm <= 3.0.0
|
||||
kubernetes.core.helm_pull:
|
||||
helm_pull:
|
||||
binary_path: "{{ helm_path }}"
|
||||
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
|
||||
destination: "{{ destination }}"
|
||||
@@ -55,7 +55,7 @@
|
||||
# Testing helm pull with helm version == 3.0.0
|
||||
- block:
|
||||
- name: Download chart using chart_ssl_cert_file
|
||||
kubernetes.core.helm_pull:
|
||||
helm_pull:
|
||||
binary_path: "{{ helm_path }}"
|
||||
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
|
||||
destination: "{{ destination }}"
|
||||
@@ -71,7 +71,7 @@
|
||||
- _result.msg == "Parameter chart_ssl_cert_file requires helm >= 3.1.0, current version is 3.0.0"
|
||||
|
||||
- name: Download chart using chart_ssl_key_file
|
||||
kubernetes.core.helm_pull:
|
||||
helm_pull:
|
||||
binary_path: "{{ helm_path }}"
|
||||
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
|
||||
destination: "{{ destination }}"
|
||||
@@ -87,7 +87,7 @@
|
||||
- _result.msg == "Parameter chart_ssl_key_file requires helm >= 3.1.0, current version is 3.0.0"
|
||||
|
||||
- name: Download chart using chart_ca_cert
|
||||
kubernetes.core.helm_pull:
|
||||
helm_pull:
|
||||
binary_path: "{{ helm_path }}"
|
||||
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
|
||||
destination: "{{ destination }}"
|
||||
@@ -108,7 +108,7 @@
|
||||
# Testing helm pull with helm version == 3.1.0
|
||||
- block:
|
||||
- name: Download chart using chart_ssl_cert_file, chart_ca_cert, chart_ssl_key_file
|
||||
kubernetes.core.helm_pull:
|
||||
helm_pull:
|
||||
binary_path: "{{ helm_path }}"
|
||||
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
|
||||
destination: "{{ destination }}"
|
||||
@@ -127,7 +127,7 @@
|
||||
- '"--key-file ssl_key_file" in _result.command'
|
||||
|
||||
- name: Download chart using skip_tls_certs_check
|
||||
kubernetes.core.helm_pull:
|
||||
helm_pull:
|
||||
binary_path: "{{ helm_path }}"
|
||||
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
|
||||
destination: "{{ destination }}"
|
||||
@@ -150,7 +150,7 @@
|
||||
# Test options chart_version, verify, pass-credentials, provenance, untar_chart
|
||||
# skip_tls_certs_check, repo_url, repo_username, repo_password
|
||||
- name: Testing chart version
|
||||
kubernetes.core.helm_pull:
|
||||
helm_pull:
|
||||
binary_path: "{{ helm_path }}"
|
||||
chart_ref: redis
|
||||
destination: "{{ destination }}"
|
||||
@@ -182,7 +182,7 @@
|
||||
- '"--keyring pubring.gpg" in _result.command'
|
||||
|
||||
- name: Download chart using chart_ref
|
||||
kubernetes.core.helm_pull:
|
||||
helm_pull:
|
||||
binary_path: "{{ helm_path }}"
|
||||
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
|
||||
destination: "{{ destination }}"
|
||||
@@ -201,7 +201,7 @@
|
||||
- _chart.stat.isreg
|
||||
|
||||
- name: Download chart using untar_chart
|
||||
kubernetes.core.helm_pull:
|
||||
helm_pull:
|
||||
binary_path: "{{ helm_path }}"
|
||||
chart_ref: redis
|
||||
destination: "{{ destination }}"
|
||||
5
tests/integration/targets/helm_repository/aliases
Normal file
5
tests/integration/targets/helm_repository/aliases
Normal file
@@ -0,0 +1,5 @@
|
||||
time=20
|
||||
helm_repository
|
||||
helm_info
|
||||
helm
|
||||
helm_template
|
||||
@@ -0,0 +1,3 @@
|
||||
---
|
||||
chart_test_repo: "https://kubernetes.github.io/ingress-nginx"
|
||||
helm_binary: "/tmp/helm/{{ ansible_system | lower }}-amd64/helm"
|
||||
3
tests/integration/targets/helm_repository/meta/main.yml
Normal file
3
tests/integration/targets/helm_repository/meta/main.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
dependencies:
|
||||
- install_helm
|
||||
3
tests/integration/targets/helm_set_values/aliases
Normal file
3
tests/integration/targets/helm_set_values/aliases
Normal file
@@ -0,0 +1,3 @@
|
||||
time=40
|
||||
helm
|
||||
helm_info
|
||||
@@ -0,0 +1,3 @@
|
||||
---
|
||||
helm_binary: "/tmp/helm/{{ ansible_system | lower }}-amd64/helm"
|
||||
helm_namespace: helm-set-values
|
||||
3
tests/integration/targets/helm_set_values/meta/main.yml
Normal file
3
tests/integration/targets/helm_set_values/meta/main.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
dependencies:
|
||||
- remove_namespace
|
||||
109
tests/integration/targets/helm_set_values/tasks/main.yml
Normal file
109
tests/integration/targets/helm_set_values/tasks/main.yml
Normal file
@@ -0,0 +1,109 @@
|
||||
- name: Install helm using set_values parameters
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_ref: mariadb
|
||||
chart_repo_url: https://charts.bitnami.com/bitnami
|
||||
release_name: test-mariadb
|
||||
release_namespace: "{{ helm_namespace }}"
|
||||
create_namespace: true
|
||||
set_values:
|
||||
- value: phase=integration
|
||||
value_type: string
|
||||
- value: versioned=false
|
||||
|
||||
- name: Get value set as string
|
||||
helm_info:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
release_name: test-mariadb
|
||||
release_namespace: "{{ helm_namespace }}"
|
||||
register: user_values
|
||||
|
||||
- name: Assert that release was created with user-defined variables
|
||||
assert:
|
||||
that:
|
||||
- '"phase" in user_values.status["values"]'
|
||||
- '"versioned" in user_values.status["values"]'
|
||||
- user_values.status["values"]["phase"] == "integration"
|
||||
- user_values.status["values"]["versioned"] is false
|
||||
|
||||
# install chart using set_values and release_values
|
||||
- name: Install helm binary (> 3.10.0) requires to use set-json
|
||||
include_role:
|
||||
name: install_helm
|
||||
vars:
|
||||
helm_version: "v3.10.3"
|
||||
|
||||
- name: Install helm using set_values parameters
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_ref: apache
|
||||
chart_repo_url: https://charts.bitnami.com/bitnami
|
||||
release_name: test-apache
|
||||
release_namespace: "{{ helm_namespace }}"
|
||||
create_namespace: true
|
||||
set_values:
|
||||
- value: 'master.image={"registry": "docker.io", "repository": "bitnami/apache", "tag": "2.4.54-debian-11-r74"}'
|
||||
value_type: json
|
||||
release_values:
|
||||
replicaCount: 3
|
||||
|
||||
- name: Get release info
|
||||
helm_info:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
release_name: test-apache
|
||||
release_namespace: "{{ helm_namespace }}"
|
||||
register: values
|
||||
|
||||
- name: Assert that release was created with user-defined variables
|
||||
assert:
|
||||
that:
|
||||
- values.status["values"].replicaCount == 3
|
||||
- values.status["values"].master.image.registry == "docker.io"
|
||||
- values.status["values"].master.image.repository == "bitnami/apache"
|
||||
- values.status["values"].master.image.tag == "2.4.54-debian-11-r74"
|
||||
|
||||
# install chart using set_values and values_files
|
||||
- name: create temporary file to save values in
|
||||
tempfile:
|
||||
suffix: .yml
|
||||
register: ymlfile
|
||||
|
||||
- block:
|
||||
- name: copy content into values file
|
||||
copy:
|
||||
content: |
|
||||
---
|
||||
mode: distributed
|
||||
dest: "{{ ymlfile.path }}"
|
||||
|
||||
- name: Install helm using set_values parameters
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_ref: minio
|
||||
chart_repo_url: https://charts.bitnami.com/bitnami
|
||||
release_name: test-minio
|
||||
release_namespace: "{{ helm_namespace }}"
|
||||
create_namespace: true
|
||||
set_values:
|
||||
- value: 'disableWebUI=true'
|
||||
values_files:
|
||||
- "{{ ymlfile.path }}"
|
||||
|
||||
- name: Get release info
|
||||
helm_info:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
release_name: test-minio
|
||||
release_namespace: "{{ helm_namespace }}"
|
||||
register: values
|
||||
|
||||
- name: Assert that release was created with user-defined variables
|
||||
assert:
|
||||
that:
|
||||
- values.status["values"].mode == "distributed"
|
||||
- values.status["values"].disableWebUI is true
|
||||
|
||||
always:
|
||||
- name: Delete temporary file
|
||||
file:
|
||||
state: absent
|
||||
path: "{{ ymlfile.path }}"
|
||||
1
tests/integration/targets/install_helm/aliases
Normal file
1
tests/integration/targets/install_helm/aliases
Normal file
@@ -0,0 +1 @@
|
||||
disabled
|
||||
4
tests/integration/targets/install_helm/defaults/main.yml
Normal file
4
tests/integration/targets/install_helm/defaults/main.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
helm_version: v3.7.0
|
||||
helm_install_path: /tmp/helm
|
||||
helm_default_archive_name: "helm-{{ helm_version }}-{{ ansible_system | lower }}-amd64.tar.gz"
|
||||
15
tests/integration/targets/install_helm/tasks/main.yml
Normal file
15
tests/integration/targets/install_helm/tasks/main.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: Init Helm folders
|
||||
file:
|
||||
path: "{{ helm_install_path }}"
|
||||
state: directory
|
||||
|
||||
- name: Unarchive Helm binary
|
||||
unarchive:
|
||||
src: "https://get.helm.sh/{{ helm_archive_name | default(helm_default_archive_name) }}"
|
||||
dest: "{{ helm_install_path }}"
|
||||
remote_src: yes
|
||||
retries: 10
|
||||
delay: 5
|
||||
register: result
|
||||
until: result is not failed
|
||||
@@ -17,6 +17,7 @@ tests/integration/targets/helm/files/appversionless-chart-v2/templates/configmap
|
||||
tests/integration/targets/helm/files/appversionless-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm/files/test-chart-v2/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm_diff/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/k8s_scale/files/deployment.yaml yamllint!skip
|
||||
tests/sanity/refresh_ignore_files shebang!skip
|
||||
plugins/doc_fragments/k8s_name_options.py future-import-boilerplate!skip
|
||||
|
||||
@@ -20,6 +20,7 @@ tests/integration/targets/helm/files/appversionless-chart-v2/templates/configmap
|
||||
tests/integration/targets/helm/files/appversionless-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm/files/test-chart-v2/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm_diff/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/k8s_scale/files/deployment.yaml yamllint!skip
|
||||
tests/sanity/refresh_ignore_files shebang!skip
|
||||
plugins/modules/k8s.py validate-modules:return-syntax-error
|
||||
|
||||
@@ -23,6 +23,7 @@ tests/integration/targets/helm/files/appversionless-chart-v2/templates/configmap
|
||||
tests/integration/targets/helm/files/appversionless-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm/files/test-chart-v2/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm_diff/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/k8s_scale/files/deployment.yaml yamllint!skip
|
||||
tests/sanity/refresh_ignore_files shebang!skip
|
||||
plugins/modules/k8s.py validate-modules:return-syntax-error
|
||||
|
||||
@@ -23,6 +23,7 @@ tests/integration/targets/helm/files/appversionless-chart-v2/templates/configmap
|
||||
tests/integration/targets/helm/files/appversionless-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm/files/test-chart-v2/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm_diff/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/k8s_scale/files/deployment.yaml yamllint!skip
|
||||
tests/sanity/refresh_ignore_files shebang!skip
|
||||
plugins/modules/k8s.py validate-modules:return-syntax-error
|
||||
|
||||
@@ -23,6 +23,7 @@ tests/integration/targets/helm/files/appversionless-chart-v2/templates/configmap
|
||||
tests/integration/targets/helm/files/appversionless-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm/files/test-chart-v2/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm_diff/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/k8s_scale/files/deployment.yaml yamllint!skip
|
||||
tests/sanity/refresh_ignore_files shebang!skip
|
||||
plugins/modules/k8s.py validate-modules:return-syntax-error
|
||||
|
||||
@@ -26,6 +26,7 @@ tests/integration/targets/helm/files/appversionless-chart-v2/templates/configmap
|
||||
tests/integration/targets/helm/files/appversionless-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm/files/test-chart-v2/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm_diff/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/k8s_scale/files/deployment.yaml yamllint!skip
|
||||
tests/sanity/refresh_ignore_files shebang!skip
|
||||
plugins/modules/k8s.py validate-modules:return-syntax-error
|
||||
|
||||
@@ -14,6 +14,7 @@ tests/integration/targets/helm/files/appversionless-chart-v2/templates/configmap
|
||||
tests/integration/targets/helm/files/appversionless-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm/files/test-chart-v2/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm_diff/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/k8s_scale/files/deployment.yaml yamllint!skip
|
||||
tests/sanity/refresh_ignore_files shebang!skip
|
||||
plugins/doc_fragments/k8s_name_options.py future-import-boilerplate!skip
|
||||
|
||||
@@ -46,6 +46,7 @@ YAML_LINT_SKIPS = [
|
||||
"tests/integration/targets/helm/files/appversionless-chart/templates/configmap.yaml",
|
||||
"tests/integration/targets/helm/files/test-chart-v2/templates/configmap.yaml",
|
||||
"tests/integration/targets/helm/files/test-chart/templates/configmap.yaml",
|
||||
"tests/integration/targets/helm_diff/files/test-chart/templates/configmap.yaml",
|
||||
"tests/integration/targets/k8s_scale/files/deployment.yaml",
|
||||
]
|
||||
|
||||
|
||||
@@ -415,3 +415,40 @@ def test_module_prepare_helm_environment_with_ca_cert(helm_version, is_env_var_s
|
||||
print(json.dumps(content, indent=2))
|
||||
assert content["clusters"][0]["cluster"]["certificate-authority"] == ca_cert
|
||||
os.remove(kubeconfig_path)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"set_values, expected",
|
||||
[
|
||||
([{"value": "test"}], ["--set test"]),
|
||||
([{"value_type": "raw", "value": "test"}], ["--set test"]),
|
||||
(
|
||||
[{"value_type": "string", "value": "string_value"}],
|
||||
["--set-string 'string_value'"],
|
||||
),
|
||||
([{"value_type": "file", "value": "file_path"}], ["--set-file 'file_path'"]),
|
||||
(
|
||||
[{"value_type": "json", "value": '{"a": 1, "b": "some_value"}'}],
|
||||
['--set-json \'{"a": 1, "b": "some_value"}\''],
|
||||
),
|
||||
(
|
||||
[
|
||||
{"value_type": "string", "value": "string_value"},
|
||||
{"value_type": "file", "value": "file_path"},
|
||||
],
|
||||
["--set-string 'string_value'", "--set-file 'file_path'"],
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_module_get_helm_set_values_args(set_values, expected):
|
||||
|
||||
module = MagicMock()
|
||||
module.params = {}
|
||||
module.fail_json.side_effect = SystemExit(1)
|
||||
|
||||
helm_module = AnsibleHelmModule(module=module)
|
||||
helm_module.get_helm_version = MagicMock()
|
||||
helm_module.get_helm_version.return_value = "3.10.1"
|
||||
|
||||
result = helm_module.get_helm_set_values_args(set_values)
|
||||
assert " ".join(expected) == result
|
||||
|
||||
Reference in New Issue
Block a user