Open krisek opened 2 years ago
Hi @krisek
Thanks for taking the time to report this feature. helm
module does not support the diff
mode for now, but this is a feature we may need to address later.
To clarify, a diff is currently returned if you are upgrading an existing release and you have the helm diff plugin installed. We do not generate a diff if you are installing a new release or if you do not have helm diff installed. I think we should be able to easily add the diff for installing new releases as this is supported by helm diff. I would not see us adding diff support without helm diff installed in the near future, though, as this would be a significant amount of effort.
Yes, without helm diff it is definitely a mission impossible. The background is that I'm working on a CI/CD pipeline that has a dry-run feature -- to help the operator to see what would happen if the pipeline were really ran.
@krisek , you can achieve something like this by comparing the current and future release with helm_template and fact_diff.
Pseudo code:
- name: "{{ release_name }} : fetch existing release info"
kubernetes.core.helm_info:
release_name: "{{ release_name }}"
release_namespace: "{{ release_namespace }}"
check_mode: false
changed_when: false
when: ansible_diff_mode
register: existing_info
- name: "{{ release_name }} : render existing release"
kubernetes.core.helm_template:
chart_version: "{{ existing_info['status']['chart'][(chart_name|length + 1):] }}" # cut version from "somechart-1.2.3"
release_values: "{{ existing_info['status']['values'] }}" # use values from last release
validate: true # opened pull request #587 for this one
...
...
register: existing_tpl
- name: "{{ release_name }} : render new release"
kubernetes.core.helm_template:
chart_version: "{{ new_version }}"
release_values "{{ new_release_values }}"
...
...
register: new_tpl
- name: "{{ release_name }} : diff"
ansible.utils.fact_diff:
before: "{{ existing_tpl.stdout|default('')|trim }}"
after: "{{ new_tpl.stdout|trim }}"
...
changed_when: existing_tpl.stdout|default('')|trim != new_tpl.stdout|trim
fact_diff
produces less verbose (only a few lines of changes) and more readable (green/red diff lines) output than running kubernetes.core.helm in diff_mode. If no current release exists, all new manifests will be displayed.
Pull request for --validate
: #587
SUMMARY
The Kubernetes returns with
--check --diff
CLI parameters, the actual diff that would be applied on the cluster. It would be great if the helm module would do the same.ISSUE TYPE
COMPONENT NAME
helm.py
ADDITIONAL INFORMATION
It would be a great enhancement for CI/CD pipelines.