add reuse_values and reset_values support to helm module (#575)

helm - add reuse_values and reset_values support

SUMMARY

closes #394

ISSUE TYPE


Feature Pull Request

COMPONENT NAME

helm
ADDITIONAL INFORMATION

Reviewed-by: Mike Graves <mgraves@redhat.com>
This commit is contained in:
Bikouo Aubin
2023-02-16 08:47:33 +01:00
committed by GitHub
parent 22764492d2
commit 031cc7c40d
5 changed files with 122 additions and 2 deletions

View File

@@ -24,3 +24,4 @@ test_namespace:
- "helm-local-path-003"
- "helm-from-repository"
- "helm-from-url"
- "helm-reuse-values"

View File

@@ -25,6 +25,9 @@
- from_repository
- from_url
- name: test helm upgrade with reuse_values
include_tasks: test_helm_reuse_values.yml
- name: test helm dependency update
include_tasks: test_up_dep.yml

View File

@@ -0,0 +1,75 @@
---
- name: Test helm reuse_values
vars:
helm_namespace: "{{ test_namespace[9] }}"
chart_release_values:
replica:
replicaCount: 3
master:
count: 1
kind: Deployment
chart_reuse_values:
replica:
replicaCount: 1
master:
count: 3
block:
- name: Initial chart installation
helm:
binary_path: "{{ helm_binary }}"
chart_ref: redis
chart_repo_url: https://charts.bitnami.com/bitnami
release_name: test-redis
release_namespace: "{{ helm_namespace }}"
create_namespace: true
release_values: "{{ chart_release_values }}"
register: install
- name: Get value set as string
helm_info:
binary_path: "{{ helm_binary }}"
release_name: test-redis
release_namespace: "{{ helm_namespace }}"
register: release_value
- name: Validate that chart values are as expected
assert:
that:
- install is changed
- '"--reuse-values=True" not in install.command'
- release_value["status"]["values"] == chart_release_values
- name: Upgrade chart using reuse_values=true
helm:
binary_path: "{{ helm_binary }}"
chart_ref: redis
chart_repo_url: https://charts.bitnami.com/bitnami
release_name: test-redis
release_namespace: "{{ helm_namespace }}"
reuse_values: true
reset_values: false
release_values: "{{ chart_reuse_values }}"
register: upgrade
- name: Get value set as string
helm_info:
binary_path: "{{ helm_binary }}"
release_name: test-redis
release_namespace: "{{ helm_namespace }}"
register: release_value
- name: Validate that chart values are as expected
assert:
that:
- upgrade is changed
- '"--reuse-values=True" in upgrade.command'
- '"--reset-values" not in upgrade.command'
- release_value["status"]["values"] == chart_release_values | combine(chart_reuse_values, recursive=true)
always:
- name: Remove helm namespace
k8s:
api_version: v1
kind: Namespace
name: "{{ helm_namespace }}"
state: absent