mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-08 14:02:38 +00:00
helm: 'changed' flag takes 'values' in consideration (#332)
Return `changed` `False` is the `values_files` match the `values` of the existing deployment. Closes: #274
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
bugfixes:
|
||||||
|
- helm - ``release_values`` makes ansible always show changed state (https://github.com/ansible-collections/community.kubernetes/issues/274)
|
||||||
@@ -295,6 +295,22 @@
|
|||||||
- install.status.chart == "{{ chart_test }}-{{ chart_test_version }}"
|
- install.status.chart == "{{ chart_test }}-{{ chart_test_version }}"
|
||||||
- "install.status['values'].revisionHistoryLimit == 0"
|
- "install.status['values'].revisionHistoryLimit == 0"
|
||||||
|
|
||||||
|
- name: "Install {{ chart_test }} from {{ source }} with values_files (again)"
|
||||||
|
helm:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
|
name: test
|
||||||
|
chart_ref: "{{ chart_source }}"
|
||||||
|
chart_version: "{{ chart_source_version | default(omit) }}"
|
||||||
|
namespace: "{{ helm_namespace }}"
|
||||||
|
values_files:
|
||||||
|
- "{{ role_path }}/files/values.yaml"
|
||||||
|
register: install
|
||||||
|
|
||||||
|
- name: "Assert the result is consistent"
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- not (install is changed)
|
||||||
|
|
||||||
- name: Remove helm namespace
|
- name: Remove helm namespace
|
||||||
k8s:
|
k8s:
|
||||||
api_version: v1
|
api_version: v1
|
||||||
|
|||||||
@@ -387,6 +387,18 @@ def delete(command, release_name, purge, disable_hook):
|
|||||||
return delete_command
|
return delete_command
|
||||||
|
|
||||||
|
|
||||||
|
def load_values_files(values_files):
|
||||||
|
values = {}
|
||||||
|
for values_file in values_files or []:
|
||||||
|
with open(values_file, 'r') as fd:
|
||||||
|
content = yaml.safe_load(fd)
|
||||||
|
if not isinstance(content, dict):
|
||||||
|
continue
|
||||||
|
for k, v in content.items():
|
||||||
|
values[k] = v
|
||||||
|
return values
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global module
|
global module
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
@@ -502,7 +514,12 @@ def main():
|
|||||||
# when deployed without an 'appVersion' chart value the 'helm list' command will return the entry `app_version: ""`
|
# when deployed without an 'appVersion' chart value the 'helm list' command will return the entry `app_version: ""`
|
||||||
appversion_is_same = (chart_app_version == released_app_version) or (chart_app_version is None and released_app_version == "")
|
appversion_is_same = (chart_app_version == released_app_version) or (chart_app_version is None and released_app_version == "")
|
||||||
|
|
||||||
if force or release_values != release_status['values'] \
|
if values_files:
|
||||||
|
values_match = release_status['values'] == load_values_files(values_files)
|
||||||
|
else:
|
||||||
|
values_match = release_status['values'] == release_values
|
||||||
|
|
||||||
|
if force or not values_match \
|
||||||
or (chart_info['name'] + '-' + chart_info['version']) != release_status["chart"] \
|
or (chart_info['name'] + '-' + chart_info['version']) != release_status["chart"] \
|
||||||
or not appversion_is_same:
|
or not appversion_is_same:
|
||||||
helm_cmd = deploy(helm_cmd, release_name, release_values, chart_ref, wait, wait_timeout,
|
helm_cmd = deploy(helm_cmd, release_name, release_values, chart_ref, wait, wait_timeout,
|
||||||
|
|||||||
Reference in New Issue
Block a user