mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-14 05:22:08 +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"
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
name: "sample_plugin"
|
||||
version: "0.0.1"
|
||||
usage: "Sample Helm Plugin"
|
||||
description: |-
|
||||
This plugin provides sample plugin to Helm.
|
||||
usage:
|
||||
This is new line
|
||||
This is another line
|
||||
ignoreFlags: false
|
||||
useTunnel: false
|
||||
command: "$HELM_PLUGIN_DIR/main.sh"
|
||||
@@ -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] }}"
|
||||
|
||||
@@ -1,196 +0,0 @@
|
||||
---
|
||||
- name: create temporary directory
|
||||
tempfile:
|
||||
state: directory
|
||||
suffix: .helm
|
||||
register: _dir
|
||||
|
||||
- name: Install helm binary
|
||||
block:
|
||||
- name: "Install {{ test_helm_version }}"
|
||||
include_tasks: install.yml
|
||||
vars:
|
||||
helm_archive_name: "helm-{{ test_helm_version }}-{{ ansible_system | lower }}-amd64.tar.gz"
|
||||
|
||||
when: test_helm_version is defined
|
||||
|
||||
- set_fact:
|
||||
saved_kubeconfig_path: "{{ _dir.path }}/config"
|
||||
|
||||
- block:
|
||||
- name: Copy default kubeconfig
|
||||
copy:
|
||||
remote_src: true
|
||||
src: "{{ default_kubeconfig_path }}"
|
||||
dest: "{{ saved_kubeconfig_path }}"
|
||||
|
||||
- name: Delete default kubeconfig
|
||||
file:
|
||||
path: "{{ default_kubeconfig_path }}"
|
||||
state: absent
|
||||
|
||||
# helm_plugin and helm_plugin_info
|
||||
- name: Install subenv plugin
|
||||
helm_plugin:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
kubeconfig: "{{ test_kubeconfig | default(omit) }}"
|
||||
validate_certs: "{{ test_validate_certs | default(omit) }}"
|
||||
ca_cert: "{{ test_ca_cert | default(omit) }}"
|
||||
state: present
|
||||
plugin_path: https://github.com/hydeenoble/helm-subenv
|
||||
register: plugin
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- plugin is changed
|
||||
|
||||
- name: Gather info about all plugin
|
||||
helm_plugin_info:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
kubeconfig: "{{ test_kubeconfig | default(omit) }}"
|
||||
validate_certs: "{{ test_validate_certs | default(omit) }}"
|
||||
ca_cert: "{{ test_ca_cert | default(omit) }}"
|
||||
register: plugin_info
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- '"plugin_list" in plugin_info'
|
||||
- plugin_info.plugin_list != []
|
||||
|
||||
# helm_repository, helm, helm_info
|
||||
- name: Add test_bitnami chart repository
|
||||
helm_repository:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: test_bitnami
|
||||
kubeconfig: "{{ test_kubeconfig | default(omit) }}"
|
||||
validate_certs: "{{ test_validate_certs | default(omit) }}"
|
||||
ca_cert: "{{ test_ca_cert | default(omit) }}"
|
||||
repo_url: https://charts.bitnami.com/bitnami
|
||||
register: repository
|
||||
|
||||
- name: Assert that repository was added
|
||||
assert:
|
||||
that:
|
||||
- repository is changed
|
||||
|
||||
- name: Install chart from repository added before
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: rabbitmq
|
||||
chart_ref: test_bitnami/rabbitmq
|
||||
namespace: "{{ helm_namespace }}"
|
||||
update_repo_cache: true
|
||||
kubeconfig: "{{ test_kubeconfig | default(omit) }}"
|
||||
validate_certs: "{{ test_validate_certs | default(omit) }}"
|
||||
ca_cert: "{{ test_ca_cert | default(omit) }}"
|
||||
create_namespace: true
|
||||
register: deploy
|
||||
|
||||
- name: Assert chart was successfully deployed
|
||||
assert:
|
||||
that:
|
||||
- deploy is changed
|
||||
|
||||
- name: Get chart content
|
||||
helm_info:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
kubeconfig: "{{ test_kubeconfig | default(omit) }}"
|
||||
validate_certs: "{{ test_validate_certs | default(omit) }}"
|
||||
ca_cert: "{{ test_ca_cert | default(omit) }}"
|
||||
name: "rabbitmq"
|
||||
namespace: "{{ helm_namespace }}"
|
||||
register: chart_info
|
||||
|
||||
- name: Assert chart was successfully deployed
|
||||
assert:
|
||||
that:
|
||||
- '"status" in chart_info'
|
||||
- chart_info.status.status is defined
|
||||
- chart_info.status.status == "deployed"
|
||||
|
||||
- name: Remove chart
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: rabbitmq
|
||||
namespace: "{{ helm_namespace }}"
|
||||
kubeconfig: "{{ test_kubeconfig | default(omit) }}"
|
||||
validate_certs: "{{ test_validate_certs | default(omit) }}"
|
||||
ca_cert: "{{ test_ca_cert | default(omit) }}"
|
||||
state: absent
|
||||
register: remove_chart
|
||||
|
||||
- name: Assert chart was successfully removed
|
||||
assert:
|
||||
that:
|
||||
- remove_chart is changed
|
||||
|
||||
- name: Get chart content
|
||||
helm_info:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
kubeconfig: "{{ test_kubeconfig | default(omit) }}"
|
||||
validate_certs: "{{ test_validate_certs | default(omit) }}"
|
||||
ca_cert: "{{ test_ca_cert | default(omit) }}"
|
||||
name: "rabbitmq"
|
||||
namespace: "{{ helm_namespace }}"
|
||||
register: chart_info
|
||||
|
||||
- name: Assert chart was successfully deployed
|
||||
assert:
|
||||
that:
|
||||
- '"status" not in chart_info'
|
||||
|
||||
- name: Remove chart repository
|
||||
helm_repository:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: test_bitnami
|
||||
kubeconfig: "{{ test_kubeconfig | default(omit) }}"
|
||||
validate_certs: "{{ test_validate_certs | default(omit) }}"
|
||||
ca_cert: "{{ test_ca_cert | default(omit) }}"
|
||||
state: absent
|
||||
register: remove
|
||||
|
||||
- name: Assert that repository was removed
|
||||
assert:
|
||||
that:
|
||||
- remove is changed
|
||||
|
||||
always:
|
||||
- name: Return kubeconfig
|
||||
copy:
|
||||
remote_src: true
|
||||
src: "{{ saved_kubeconfig_path }}"
|
||||
dest: "{{ default_kubeconfig_path }}"
|
||||
ignore_errors: true
|
||||
|
||||
- name: Delete temporary directory
|
||||
file:
|
||||
path: "{{ _dir.path }}"
|
||||
state: absent
|
||||
ignore_errors: true
|
||||
|
||||
- name: Delete temporary directory for helm install
|
||||
file:
|
||||
path: "{{ _helm_install.path }}"
|
||||
state: absent
|
||||
ignore_errors: true
|
||||
when: _helm_install is defined
|
||||
|
||||
- name: Remove subenv plugin
|
||||
helm_plugin:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
plugin_name: subenv
|
||||
state: absent
|
||||
ignore_errors: true
|
||||
|
||||
- name: Delete namespace
|
||||
k8s:
|
||||
kind: Namespace
|
||||
name: "{{ helm_namespace }}"
|
||||
ignore_errors: true
|
||||
|
||||
- name: Delete helm repository
|
||||
helm_repository:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: test_bitnami
|
||||
state: absent
|
||||
ignore_errors: true
|
||||
@@ -1,261 +0,0 @@
|
||||
---
|
||||
- name: Test helm diff functionality
|
||||
vars:
|
||||
test_chart_ref: "/tmp/test-chart"
|
||||
redis_chart_version: '17.0.5'
|
||||
|
||||
block:
|
||||
- set_fact:
|
||||
helm_namespace: "{{ test_namespace[0] }}"
|
||||
|
||||
- name: Install helm diff
|
||||
helm_plugin:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
state: present
|
||||
plugin_path: https://github.com/databus23/helm-diff
|
||||
plugin_version: 3.4.0
|
||||
|
||||
- name: Copy test chart
|
||||
copy:
|
||||
src: "test-chart/"
|
||||
dest: "{{ test_chart_ref }}"
|
||||
|
||||
- name: Install local chart
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: test-chart
|
||||
namespace: "{{ helm_namespace }}"
|
||||
chart_ref: "{{ test_chart_ref }}"
|
||||
create_namespace: yes
|
||||
register: install
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- install is changed
|
||||
|
||||
- name: Modify local chart
|
||||
blockinfile:
|
||||
create: yes
|
||||
path: "{{ test_chart_ref }}/templates/anothermap.yaml"
|
||||
block: !unsafe |
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: test-chart-another-configmap
|
||||
data:
|
||||
foo: {{ .Values.foo | default "bar" }}
|
||||
|
||||
- name: Test helm diff in check mode
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: test-chart
|
||||
namespace: "{{ helm_namespace }}"
|
||||
chart_ref: "{{ test_chart_ref }}"
|
||||
check_mode: yes
|
||||
diff: yes
|
||||
register: diff_result
|
||||
|
||||
- name: Check if helm diff check is correct
|
||||
vars:
|
||||
foo_bar_value: "+ foo: bar"
|
||||
assert:
|
||||
that:
|
||||
- foo_bar_value in diff_result.diff.prepared
|
||||
|
||||
- name: Upgrade local chart with modifications
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: test-chart
|
||||
namespace: "{{ helm_namespace }}"
|
||||
chart_ref: "{{ test_chart_ref }}"
|
||||
register: install
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- install is changed
|
||||
|
||||
- name: No diff in check mode when no change
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: test-chart
|
||||
namespace: "{{ helm_namespace }}"
|
||||
chart_ref: "{{ test_chart_ref }}"
|
||||
check_mode: yes
|
||||
diff: yes
|
||||
register: diff_result
|
||||
|
||||
- name: Check if no diff in check mode when no change
|
||||
assert:
|
||||
that:
|
||||
- '"diff" not in diff_result'
|
||||
|
||||
- name: Upgrade modified local chart idempotency check
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: test-chart
|
||||
namespace: "{{ helm_namespace }}"
|
||||
chart_ref: "{{ test_chart_ref }}"
|
||||
register: install
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- install is not changed
|
||||
|
||||
- name: Modify values
|
||||
blockinfile:
|
||||
create: yes
|
||||
path: "{{ test_chart_ref }}/values.yml"
|
||||
block: |
|
||||
---
|
||||
foo: baz
|
||||
|
||||
- name: Upgrade with values file
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: test-chart
|
||||
namespace: "{{ helm_namespace }}"
|
||||
chart_ref: "{{ test_chart_ref }}"
|
||||
values_files:
|
||||
- "{{ test_chart_ref }}/values.yml"
|
||||
register: install
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- install is changed
|
||||
|
||||
- name: Upgrade with values file idempotency check
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: test-chart
|
||||
namespace: "{{ helm_namespace }}"
|
||||
chart_ref: "{{ test_chart_ref }}"
|
||||
values_files:
|
||||
- "{{ test_chart_ref }}/values.yml"
|
||||
register: install
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- install is not changed
|
||||
|
||||
- name: Upgrade with values
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: test-chart
|
||||
namespace: "{{ helm_namespace }}"
|
||||
chart_ref: "{{ test_chart_ref }}"
|
||||
values:
|
||||
foo: gaz
|
||||
register: install
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- install is changed
|
||||
|
||||
- name: Upgrade with values idempotency check
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: test-chart
|
||||
namespace: "{{ helm_namespace }}"
|
||||
chart_ref: "{{ test_chart_ref }}"
|
||||
values:
|
||||
foo: gaz
|
||||
register: install
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- install is not changed
|
||||
|
||||
# Test helm diff with chart_repo_url
|
||||
- name: Define Redis chart values
|
||||
set_fact:
|
||||
redis_chart_values:
|
||||
commonLabels:
|
||||
phase: testing
|
||||
company: RedHat
|
||||
image:
|
||||
tag: 6.2.6-debian-10-r135
|
||||
architecture: standalone
|
||||
|
||||
- name: Install Redis chart
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_repo_url: https://charts.bitnami.com/bitnami
|
||||
chart_ref: redis
|
||||
namespace: "{{ helm_namespace }}"
|
||||
name: redis-chart
|
||||
chart_version: "{{ redis_chart_version }}"
|
||||
release_values: "{{ redis_chart_values }}"
|
||||
|
||||
- name: Upgrade Redis chart
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_repo_url: https://charts.bitnami.com/bitnami
|
||||
chart_ref: redis
|
||||
namespace: "{{ helm_namespace }}"
|
||||
name: redis-chart
|
||||
chart_version: "{{ redis_chart_version }}"
|
||||
release_values: "{{ redis_chart_values }}"
|
||||
check_mode: yes
|
||||
register: redis_upgrade
|
||||
|
||||
- name: Assert that module raised a warning
|
||||
assert:
|
||||
that:
|
||||
- not redis_upgrade.changed
|
||||
- redis_upgrade.warnings is defined
|
||||
- redis_upgrade.warnings | length == 1
|
||||
- redis_upgrade.warnings[0] == "The default idempotency check can fail to report changes in certain cases. Install helm diff >= 3.4.1 for better results."
|
||||
|
||||
- name: Uninstall helm diff
|
||||
helm_plugin:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
state: absent
|
||||
plugin_name: diff
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Install helm diff (version=3.4.1)
|
||||
helm_plugin:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
state: present
|
||||
plugin_path: https://github.com/databus23/helm-diff
|
||||
plugin_version: 3.4.1
|
||||
|
||||
- name: Upgrade Redis chart once again
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_repo_url: https://charts.bitnami.com/bitnami
|
||||
chart_ref: redis
|
||||
namespace: "{{ helm_namespace }}"
|
||||
name: redis-chart
|
||||
chart_version: "{{ redis_chart_version }}"
|
||||
release_values: "{{ redis_chart_values }}"
|
||||
check_mode: yes
|
||||
register: redis_upgrade_2
|
||||
|
||||
- name: Assert that module raised a warning
|
||||
assert:
|
||||
that:
|
||||
- redis_upgrade_2.changed
|
||||
- redis_upgrade_2.warnings is not defined
|
||||
|
||||
always:
|
||||
- name: Remove chart directory
|
||||
file:
|
||||
path: "{{ test_chart_ref }}"
|
||||
state: absent
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Uninstall helm diff
|
||||
helm_plugin:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
state: absent
|
||||
plugin_name: diff
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Remove helm namespace
|
||||
k8s:
|
||||
api_version: v1
|
||||
kind: Namespace
|
||||
name: "{{ helm_namespace }}"
|
||||
state: absent
|
||||
ignore_errors: yes
|
||||
@@ -1,22 +0,0 @@
|
||||
---
|
||||
- name: Test helm with in-memory kubeconfig
|
||||
include_tasks: "tests_kubeconfig/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"
|
||||
loop_control:
|
||||
loop_var: test_helm_version
|
||||
with_items:
|
||||
- "v3.10.3"
|
||||
- "v3.8.2"
|
||||
|
||||
- name: Test helm with custom kubeconfig and ca_cert
|
||||
include_tasks: "tests_kubeconfig/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
|
||||
@@ -1,165 +0,0 @@
|
||||
---
|
||||
- name: Install env plugin in check mode
|
||||
helm_plugin:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
state: present
|
||||
plugin_path: https://github.com/adamreese/helm-env
|
||||
register: check_install_env
|
||||
check_mode: true
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- check_install_env.changed
|
||||
|
||||
- name: Install env plugin
|
||||
helm_plugin:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
state: present
|
||||
plugin_path: https://github.com/adamreese/helm-env
|
||||
register: install_env
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- install_env.changed
|
||||
|
||||
- name: Gather info about all plugin
|
||||
helm_plugin_info:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
register: plugin_info
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- plugin_info.plugin_list is defined
|
||||
|
||||
- name: Install env plugin again
|
||||
helm_plugin:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
state: present
|
||||
plugin_path: https://github.com/adamreese/helm-env
|
||||
register: install_env
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- not install_env.changed
|
||||
|
||||
- name: Uninstall env plugin in check mode
|
||||
helm_plugin:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
state: absent
|
||||
plugin_name: env
|
||||
register: check_uninstall_env
|
||||
check_mode: true
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- check_uninstall_env.changed
|
||||
|
||||
- name: Uninstall env plugin
|
||||
helm_plugin:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
state: absent
|
||||
plugin_name: env
|
||||
register: uninstall_env
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- uninstall_env.changed
|
||||
|
||||
- name: Uninstall env plugin again
|
||||
helm_plugin:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
state: absent
|
||||
plugin_name: env
|
||||
register: uninstall_env
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- not uninstall_env.changed
|
||||
|
||||
# https://github.com/ansible-collections/community.kubernetes/issues/399
|
||||
- block:
|
||||
- name: Copy required plugin files
|
||||
copy:
|
||||
src: "files/sample_plugin"
|
||||
dest: "/tmp/helm_plugin_test/"
|
||||
|
||||
- name: Install sample_plugin from the directory
|
||||
helm_plugin:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
state: present
|
||||
plugin_path: "/tmp/helm_plugin_test/sample_plugin"
|
||||
register: sample_plugin_output
|
||||
|
||||
- name: Assert that sample_plugin is installed or not
|
||||
assert:
|
||||
that:
|
||||
- sample_plugin_output.changed
|
||||
|
||||
- name: Gather Helm plugin info
|
||||
helm_plugin_info:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
register: r
|
||||
|
||||
- name: Set sample_plugin version
|
||||
set_fact:
|
||||
plugin_version: "{{ ( r.plugin_list | selectattr('name', 'equalto', plugin_name) | list )[0].version }}"
|
||||
vars:
|
||||
plugin_name: "sample_plugin"
|
||||
|
||||
- name: Assert if sample_plugin with multiline comment is installed
|
||||
assert:
|
||||
that:
|
||||
- plugin_version == "0.0.1"
|
||||
always:
|
||||
- name: Uninstall sample_plugin
|
||||
helm_plugin:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
state: absent
|
||||
plugin_name: sample_plugin
|
||||
ignore_errors: yes
|
||||
|
||||
- block:
|
||||
- name: uninstall helm plugin secrets
|
||||
helm_plugin:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
plugin_name: secrets
|
||||
state: absent
|
||||
|
||||
- name: install helm-secrets on a specific version
|
||||
helm_plugin:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
plugin_path: https://github.com/jkroepke/helm-secrets
|
||||
plugin_version: 3.4.1
|
||||
state: present
|
||||
|
||||
- name: list helm plugin
|
||||
helm_plugin_info:
|
||||
plugin_name: secrets
|
||||
binary_path: "{{ helm_binary }}"
|
||||
register: plugin_list
|
||||
|
||||
- name: assert that secrets has been installed with specified version
|
||||
assert:
|
||||
that:
|
||||
- plugin_list.plugin_list[0].version == "3.4.1"
|
||||
|
||||
- name: Update helm plugin version to latest
|
||||
helm_plugin:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
plugin_name: secrets
|
||||
state: latest
|
||||
register: _update
|
||||
|
||||
- name: assert update was performed
|
||||
assert:
|
||||
that:
|
||||
- _update.changed
|
||||
- '"Updated plugin: secrets" in _update.stdout'
|
||||
|
||||
always:
|
||||
- name: Uninstall sample_plugin
|
||||
helm_plugin:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
state: absent
|
||||
plugin_name: secrets
|
||||
ignore_errors: yes
|
||||
@@ -1,232 +0,0 @@
|
||||
---
|
||||
- name: Define helm versions to test
|
||||
set_fact:
|
||||
helm_versions:
|
||||
- 3.8.0
|
||||
- 3.1.0
|
||||
- 3.0.0
|
||||
- 2.3.0
|
||||
|
||||
- block:
|
||||
- name: Create temp directory for helm tests
|
||||
tempfile:
|
||||
state: directory
|
||||
register: tmpdir
|
||||
|
||||
- name: Set temp directory fact
|
||||
set_fact:
|
||||
temp_dir: "{{ tmpdir.path }}"
|
||||
|
||||
- set_fact:
|
||||
destination: "{{ temp_dir }}"
|
||||
|
||||
- name: Create Helm directories
|
||||
file:
|
||||
state: directory
|
||||
path: "{{ temp_dir }}/{{ item }}"
|
||||
with_items: "{{ helm_versions }}"
|
||||
|
||||
- name: Unarchive Helm binary
|
||||
unarchive:
|
||||
src: "https://get.helm.sh/helm-v{{ item }}-linux-amd64.tar.gz"
|
||||
dest: "{{ temp_dir }}/{{ item }}"
|
||||
remote_src: yes
|
||||
with_items: "{{ helm_versions }}"
|
||||
|
||||
# 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:
|
||||
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 }}"
|
||||
ignore_errors: true
|
||||
register: _result
|
||||
|
||||
- name: assert that module failed with proper message
|
||||
assert:
|
||||
that:
|
||||
- _result is failed
|
||||
- _result.msg == "This module requires helm >= 3.0.0, current version is 2.3.0"
|
||||
|
||||
vars:
|
||||
helm_path: "{{ temp_dir }}/2.3.0/linux-amd64/helm"
|
||||
|
||||
# Testing helm pull with helm version == 3.0.0
|
||||
- block:
|
||||
- name: Download chart using chart_ssl_cert_file
|
||||
kubernetes.core.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 }}"
|
||||
chart_ssl_cert_file: ssl_cert_file
|
||||
ignore_errors: true
|
||||
check_mode: true
|
||||
register: _result
|
||||
|
||||
- name: assert that module failed with proper message
|
||||
assert:
|
||||
that:
|
||||
- _result is failed
|
||||
- _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:
|
||||
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 }}"
|
||||
chart_ssl_key_file: ssl_key_file
|
||||
ignore_errors: true
|
||||
check_mode: true
|
||||
register: _result
|
||||
|
||||
- name: assert that module failed with proper message
|
||||
assert:
|
||||
that:
|
||||
- _result is failed
|
||||
- _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:
|
||||
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 }}"
|
||||
chart_ca_cert: ca_cert_file
|
||||
ignore_errors: true
|
||||
check_mode: true
|
||||
register: _result
|
||||
|
||||
- name: assert that module failed with proper message
|
||||
assert:
|
||||
that:
|
||||
- _result is failed
|
||||
- _result.msg == "Parameter chart_ca_cert requires helm >= 3.1.0, current version is 3.0.0"
|
||||
|
||||
vars:
|
||||
helm_path: "{{ temp_dir }}/3.0.0/linux-amd64/helm"
|
||||
|
||||
# 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:
|
||||
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 }}"
|
||||
chart_ssl_cert_file: ssl_cert_file
|
||||
chart_ssl_key_file: ssl_key_file
|
||||
chart_ca_cert: ca_cert_file
|
||||
check_mode: true
|
||||
register: _result
|
||||
|
||||
- name: assert that module failed with proper message
|
||||
assert:
|
||||
that:
|
||||
- _result is changed
|
||||
- '"--ca-file ca_cert_file" in _result.command'
|
||||
- '"--cert-file ssl_cert_file" in _result.command'
|
||||
- '"--key-file ssl_key_file" in _result.command'
|
||||
|
||||
- name: Download chart using skip_tls_certs_check
|
||||
kubernetes.core.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 }}"
|
||||
skip_tls_certs_check: true
|
||||
ignore_errors: true
|
||||
check_mode: true
|
||||
register: _result
|
||||
|
||||
- name: assert that module failed with proper message
|
||||
assert:
|
||||
that:
|
||||
- _result is failed
|
||||
- _result.msg == "Parameter skip_tls_certs_check requires helm >= 3.3.0, current version is 3.1.0"
|
||||
|
||||
vars:
|
||||
helm_path: "{{ temp_dir }}/3.1.0/linux-amd64/helm"
|
||||
|
||||
# Testing helm pull with helm version == 3.8.0
|
||||
- block:
|
||||
# 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:
|
||||
binary_path: "{{ helm_path }}"
|
||||
chart_ref: redis
|
||||
destination: "{{ destination }}"
|
||||
chart_version: "0.2.1"
|
||||
verify_chart: true
|
||||
pass_credentials: true
|
||||
provenance: true
|
||||
untar_chart: true
|
||||
skip_tls_certs_check: true
|
||||
repo_url: "https://charts.bitnami.com/bitnami"
|
||||
repo_username: ansible
|
||||
repo_password: testing123
|
||||
verify_chart_keyring: pubring.gpg
|
||||
check_mode: true
|
||||
register: _result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- _result is changed
|
||||
- '"--version 0.2.1" in _result.command'
|
||||
- '"--verify" in _result.command'
|
||||
- '"--pass-credentials" in _result.command'
|
||||
- '"--prov" in _result.command'
|
||||
- '"--untar" in _result.command'
|
||||
- '"--insecure-skip-tls-verify" in _result.command'
|
||||
- '"--repo https://charts.bitnami.com/bitnami" in _result.command'
|
||||
- '"--username ansible" in _result.command'
|
||||
- '"--password ***" in _result.command'
|
||||
- '"--keyring pubring.gpg" in _result.command'
|
||||
|
||||
- name: Download chart using chart_ref
|
||||
kubernetes.core.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 }}"
|
||||
register: _result
|
||||
|
||||
- name: Check chart on local filesystem
|
||||
stat:
|
||||
path: "{{ destination }}/grafana-5.6.0.tgz"
|
||||
register: _chart
|
||||
|
||||
- name: Validate that chart was downloaded
|
||||
assert:
|
||||
that:
|
||||
- _result is changed
|
||||
- _chart.stat.exists
|
||||
- _chart.stat.isreg
|
||||
|
||||
- name: Download chart using untar_chart
|
||||
kubernetes.core.helm_pull:
|
||||
binary_path: "{{ helm_path }}"
|
||||
chart_ref: redis
|
||||
destination: "{{ destination }}"
|
||||
repo_url: "https://charts.bitnami.com/bitnami"
|
||||
untar_chart: true
|
||||
register: _result
|
||||
|
||||
- name: Check chart on local filesystem
|
||||
stat:
|
||||
path: "{{ destination }}/redis"
|
||||
register: _chart
|
||||
|
||||
- name: Validate that chart was downloaded
|
||||
assert:
|
||||
that:
|
||||
- _result is changed
|
||||
- _chart.stat.exists
|
||||
- _chart.stat.isdir
|
||||
|
||||
vars:
|
||||
helm_path: "{{ temp_dir }}/3.8.0/linux-amd64/helm"
|
||||
|
||||
|
||||
always:
|
||||
- name: Delete temp directory
|
||||
file:
|
||||
state: absent
|
||||
path: "{{ temp_dir }}"
|
||||
@@ -1,9 +0,0 @@
|
||||
---
|
||||
- set_fact:
|
||||
custom_config: "{{ lookup('file', default_kubeconfig_path | expanduser) | from_yaml }}"
|
||||
|
||||
- name: Test helm modules using in-memory kubeconfig
|
||||
include_tasks: "../tests_helm_auth.yml"
|
||||
vars:
|
||||
test_kubeconfig: "{{ custom_config }}"
|
||||
helm_namespace: "{{ test_namespace[11] }}"
|
||||
@@ -1,76 +0,0 @@
|
||||
---
|
||||
- set_fact:
|
||||
content: "{{ lookup('file', default_kubeconfig_path) | from_yaml }}"
|
||||
custom_content: {}
|
||||
clusters: []
|
||||
|
||||
- set_fact:
|
||||
custom_content: "{{ custom_content | combine({item.key: item.value}) }}"
|
||||
when: "{{ item.key not in ['clusters'] }}"
|
||||
with_dict: "{{ content }}"
|
||||
|
||||
- set_fact:
|
||||
clusters: "{{ clusters + [item | combine({'cluster': {'certificate-authority-data': omit}}, recursive=true)] }}"
|
||||
with_items: "{{ content.clusters }}"
|
||||
|
||||
- set_fact:
|
||||
custom_content: "{{ custom_content | combine({'clusters': clusters}) }}"
|
||||
|
||||
- name: create temporary file for ca_cert
|
||||
tempfile:
|
||||
suffix: .cacert
|
||||
register: ca_file
|
||||
|
||||
- name: copy content into certificate file
|
||||
copy:
|
||||
content: "{{ content.clusters.0.cluster['certificate-authority-data'] | b64decode }}"
|
||||
dest: "{{ ca_file.path }}"
|
||||
|
||||
- name: create temporary file to save config in
|
||||
tempfile:
|
||||
suffix: .config
|
||||
register: tfile
|
||||
|
||||
- name: create custom config
|
||||
copy:
|
||||
content: "{{ custom_content | to_yaml }}"
|
||||
dest: "{{ tfile.path }}"
|
||||
|
||||
- block:
|
||||
- name: Install Redis chart without ca_cert (should fail)
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_repo_url: https://charts.bitnami.com/bitnami
|
||||
chart_ref: redis
|
||||
namespace: "{{ helm_namespace }}"
|
||||
create_namespace: true
|
||||
name: redis-chart
|
||||
chart_version: '17.0.5'
|
||||
release_values:
|
||||
architecture: standalone
|
||||
release_state: present
|
||||
kubeconfig: "{{ tfile.path }}"
|
||||
ignore_errors: true
|
||||
register: _install
|
||||
|
||||
- name: assert task failed
|
||||
assert:
|
||||
that:
|
||||
- _install is failed
|
||||
- '"Error: Kubernetes cluster unreachable" in _install.msg'
|
||||
|
||||
- name: Test helm modules using in-memory kubeconfig
|
||||
include_tasks: "../tests_helm_auth.yml"
|
||||
vars:
|
||||
test_kubeconfig: "{{ tfile.path }}"
|
||||
test_ca_cert: "{{ ca_file.path }}"
|
||||
|
||||
vars:
|
||||
helm_namespace: "{{ test_namespace[13] }}"
|
||||
|
||||
always:
|
||||
- name: Delete temporary file
|
||||
file:
|
||||
state: absent
|
||||
path: "{{ tfile.path }}"
|
||||
ignore_errors: true
|
||||
@@ -1,67 +0,0 @@
|
||||
---
|
||||
- set_fact:
|
||||
content: "{{ lookup('file', default_kubeconfig_path) | from_yaml }}"
|
||||
custom_content: {}
|
||||
clusters: []
|
||||
|
||||
- set_fact:
|
||||
custom_content: "{{ custom_content | combine({item.key: item.value}) }}"
|
||||
when: "{{ item.key not in ['clusters'] }}"
|
||||
with_dict: "{{ content }}"
|
||||
|
||||
- set_fact:
|
||||
clusters: "{{ clusters + [item | combine({'cluster': {'certificate-authority-data': omit}}, recursive=true)] }}"
|
||||
with_items: "{{ content.clusters }}"
|
||||
|
||||
- set_fact:
|
||||
custom_content: "{{ custom_content | combine({'clusters': clusters}) }}"
|
||||
|
||||
- name: create temporary file to save config in
|
||||
tempfile:
|
||||
suffix: .config
|
||||
register: tfile
|
||||
|
||||
- name: create custom config
|
||||
copy:
|
||||
content: "{{ custom_content | to_yaml }}"
|
||||
dest: "{{ tfile.path }}"
|
||||
|
||||
- block:
|
||||
- name: Install Redis chart without validate_certs=false (should fail)
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_repo_url: https://charts.bitnami.com/bitnami
|
||||
chart_ref: redis
|
||||
namespace: "{{ helm_namespace }}"
|
||||
create_namespace: true
|
||||
name: redis-chart
|
||||
chart_version: '17.0.5'
|
||||
release_values:
|
||||
architecture: standalone
|
||||
release_state: present
|
||||
kubeconfig: "{{ tfile.path }}"
|
||||
validate_certs: true
|
||||
ignore_errors: true
|
||||
register: _install
|
||||
|
||||
- name: assert task failed
|
||||
assert:
|
||||
that:
|
||||
- _install is failed
|
||||
- '"Error: Kubernetes cluster unreachable" in _install.msg'
|
||||
|
||||
- name: Test helm modules using in-memory kubeconfig
|
||||
include_tasks: "../tests_helm_auth.yml"
|
||||
vars:
|
||||
test_kubeconfig: "{{ tfile.path }}"
|
||||
test_validate_certs: false
|
||||
|
||||
vars:
|
||||
helm_namespace: "{{ test_namespace[12] }}"
|
||||
|
||||
always:
|
||||
- name: Delete temporary file
|
||||
file:
|
||||
state: absent
|
||||
path: "{{ tfile.path }}"
|
||||
ignore_errors: true
|
||||
@@ -1,80 +0,0 @@
|
||||
---
|
||||
- name: "Ensure test_helm_repo doesn't exist"
|
||||
helm_repository:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: test_helm_repo
|
||||
state: absent
|
||||
|
||||
- name: Add test_helm_repo chart repository
|
||||
helm_repository:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: test_helm_repo
|
||||
repo_url: "{{ chart_test_repo }}"
|
||||
register: repository
|
||||
|
||||
- name: Assert that test_helm_repo repository is added
|
||||
assert:
|
||||
that:
|
||||
- repository is changed
|
||||
|
||||
- name: Check idempotency
|
||||
helm_repository:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: test_helm_repo
|
||||
repo_url: "{{ chart_test_repo }}"
|
||||
register: repository
|
||||
|
||||
- name: Assert idempotency
|
||||
assert:
|
||||
that:
|
||||
- repository is not changed
|
||||
|
||||
- name: Failed to add repository with the same name
|
||||
helm_repository:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: test_helm_repo
|
||||
repo_url: "https://other-charts.url"
|
||||
register: repository_errors
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Assert that adding repository with the same name failed
|
||||
assert:
|
||||
that:
|
||||
- repository_errors is failed
|
||||
|
||||
- name: Succesfully add repository with the same name when forcing
|
||||
helm_repository:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: test_helm_repo
|
||||
repo_url: "{{ chart_test_repo }}"
|
||||
force: true
|
||||
register: repository
|
||||
|
||||
- name: Assert that test_helm_repo repository is changed
|
||||
assert:
|
||||
that:
|
||||
- repository is changed
|
||||
|
||||
- name: Remove test_helm_repo chart repository
|
||||
helm_repository:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: test_helm_repo
|
||||
state: absent
|
||||
register: repository
|
||||
|
||||
- name: Assert that test_helm_repo repository is removed
|
||||
assert:
|
||||
that:
|
||||
- repository is changed
|
||||
|
||||
- name: Check idempotency after remove
|
||||
helm_repository:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: test_helm_repo
|
||||
state: absent
|
||||
register: repository
|
||||
|
||||
- name: Assert idempotency
|
||||
assert:
|
||||
that:
|
||||
- repository is not changed
|
||||
Reference in New Issue
Block a user