mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-06 21:12:37 +00:00
SUMMARY
Fix charts ref on integration tests targets
ISSUE TYPE
Bugfix Pull Request
Reviewed-by: Yuriy Novostavskiy
Reviewed-by: Alina Buzachis
(cherry picked from commit 7559b65946)
Co-authored-by: Bikouo Aubin <79859644+abikouo@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
apiVersion: v2
|
||||
name: test-chart-deployment-time
|
||||
description: A chart with a config map containing the deployment time in data
|
||||
type: application
|
||||
version: 0.1.0
|
||||
appVersion: "default"
|
||||
@@ -0,0 +1,7 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ default "ansible-configmap" .Values.myConfigmapName }}
|
||||
data:
|
||||
myValue: {{ default "test" .Values.myValue }}
|
||||
deploymentTime: {{ now }}
|
||||
@@ -2,3 +2,4 @@
|
||||
dependencies:
|
||||
- remove_namespace
|
||||
- install_helm
|
||||
- setup_helm_registry
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
- name: Test helm diff functionality
|
||||
vars:
|
||||
test_chart_ref: "/tmp/test-chart"
|
||||
redis_chart_version: '17.0.5'
|
||||
|
||||
block:
|
||||
|
||||
@@ -24,7 +23,7 @@
|
||||
name: test-chart
|
||||
namespace: "{{ helm_namespace }}"
|
||||
chart_ref: "{{ test_chart_ref }}"
|
||||
create_namespace: yes
|
||||
create_namespace: true
|
||||
register: install
|
||||
|
||||
- assert:
|
||||
@@ -49,8 +48,8 @@
|
||||
name: test-chart
|
||||
namespace: "{{ helm_namespace }}"
|
||||
chart_ref: "{{ test_chart_ref }}"
|
||||
check_mode: yes
|
||||
diff: yes
|
||||
check_mode: true
|
||||
diff: true
|
||||
register: diff_result
|
||||
|
||||
- name: Check if helm diff check is correct
|
||||
@@ -79,7 +78,7 @@
|
||||
namespace: "{{ helm_namespace }}"
|
||||
chart_ref: "{{ test_chart_ref }}"
|
||||
check_mode: yes
|
||||
diff: yes
|
||||
diff: true
|
||||
register: diff_result
|
||||
|
||||
- name: Check if no diff in check mode when no change
|
||||
@@ -101,7 +100,7 @@
|
||||
|
||||
- name: Modify values
|
||||
blockinfile:
|
||||
create: yes
|
||||
create: true
|
||||
path: "{{ test_chart_ref }}/values.yml"
|
||||
block: |
|
||||
---
|
||||
@@ -206,52 +205,76 @@
|
||||
- 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
|
||||
ignore_errors: true
|
||||
|
||||
- name: Define chart variables
|
||||
set_fact:
|
||||
test_chart_values:
|
||||
myValue: 'Some ConfigMap data value'
|
||||
myConfigmapName: 'ansible-config-from-url'
|
||||
test_chart_version: 0.1.0
|
||||
test_chart_ref_url: "oci://localhost:6035/testing/test-chart-deployment-time"
|
||||
|
||||
- name: Deploy chart to remote registry
|
||||
block:
|
||||
- name: Create local directory to copy chart in
|
||||
ansible.builtin.tempfile:
|
||||
suffix: .chart
|
||||
state: directory
|
||||
register: _tmpd
|
||||
|
||||
- name: Copy local registry
|
||||
ansible.builtin.copy:
|
||||
dest: "{{ _tmpd.path }}"
|
||||
src: '{{ role_path }}/files/test-chart-deployment-time'
|
||||
|
||||
- name: Push chart to helm registry
|
||||
ansible.builtin.include_role:
|
||||
name: push_to_helm_registry
|
||||
vars:
|
||||
chart_local_path: '{{ _tmpd.path }}/test-chart-deployment-time'
|
||||
chart_repo_path: 'testing'
|
||||
always:
|
||||
- name: Delete temporary directory
|
||||
ansible.builtin.file:
|
||||
state: absent
|
||||
path: '{{ _tmpd.path }}'
|
||||
|
||||
- name: Log into Helm registry
|
||||
ansible.builtin.command: "{{ helm_binary }} registry login -u testuser -p 'pass123!' localhost:6035"
|
||||
|
||||
- name: Install chart from remote URL
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_ref: "{{ test_chart_ref_url }}"
|
||||
chart_version: 0.1.0
|
||||
namespace: "{{ helm_namespace }}"
|
||||
name: another-chart
|
||||
release_values: "{{ test_chart_values }}"
|
||||
|
||||
- name: Upgrade chart
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_ref: "{{ test_chart_ref_url }}"
|
||||
chart_version: 0.1.0
|
||||
namespace: "{{ helm_namespace }}"
|
||||
name: another-chart
|
||||
release_values: "{{ test_chart_values }}"
|
||||
check_mode: true
|
||||
register: _upgrade
|
||||
|
||||
- name: Assert that module raised a warning
|
||||
assert:
|
||||
that:
|
||||
- not _upgrade.changed
|
||||
- _upgrade.warnings is defined
|
||||
- _upgrade.warnings | length == 1
|
||||
- _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: Install helm diff (version=3.4.1)
|
||||
helm_plugin:
|
||||
@@ -260,37 +283,36 @@
|
||||
plugin_path: https://github.com/databus23/helm-diff
|
||||
plugin_version: 3.4.1
|
||||
|
||||
- name: Upgrade Redis chart once again
|
||||
- name: Upgrade chart once again
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_repo_url: https://charts.bitnami.com/bitnami
|
||||
chart_ref: redis
|
||||
chart_ref: "{{ test_chart_ref_url }}"
|
||||
chart_version: 0.1.0
|
||||
namespace: "{{ helm_namespace }}"
|
||||
name: redis-chart
|
||||
chart_version: "{{ redis_chart_version }}"
|
||||
release_values: "{{ redis_chart_values }}"
|
||||
check_mode: yes
|
||||
register: redis_upgrade_2
|
||||
name: another-chart
|
||||
release_values: "{{ test_chart_values }}"
|
||||
check_mode: true
|
||||
register: _upgrade_2
|
||||
|
||||
- name: Assert that module raised a warning
|
||||
assert:
|
||||
that:
|
||||
- redis_upgrade_2.changed
|
||||
- redis_upgrade_2.warnings is not defined
|
||||
- _upgrade_2.changed
|
||||
- _upgrade_2.warnings is not defined
|
||||
|
||||
always:
|
||||
- name: Remove chart directory
|
||||
file:
|
||||
path: "{{ test_chart_ref }}"
|
||||
state: absent
|
||||
ignore_errors: yes
|
||||
ignore_errors: true
|
||||
|
||||
- name: Uninstall helm diff
|
||||
helm_plugin:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
state: absent
|
||||
plugin_name: diff
|
||||
ignore_errors: yes
|
||||
ignore_errors: true
|
||||
|
||||
- name: Remove helm namespace
|
||||
k8s:
|
||||
@@ -299,6 +321,6 @@
|
||||
name: "{{ helm_namespace }}"
|
||||
state: absent
|
||||
wait: true
|
||||
ignore_errors: yes
|
||||
ignore_errors: true
|
||||
|
||||
- include_tasks: reuse_values.yml
|
||||
|
||||
Reference in New Issue
Block a user