mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-03-27 05:43:02 +00:00
Add helm dependency update SUMMARY Execute the helm dependency update under the hood when found dependencies block in Chart.yaml file. Support the execution of: Standalone dependency update by executing: helm dependency update CHART Inline dependency update when specifying the helm chart_repo_url by adding --dependency-update to the helm install command. ISSUE TYPE Feature Pull Request #191 COMPONENT NAME helm, helm_template ADDITIONAL INFORMATION There is a doc generated for history_max option for the helm module. I think that is not generated in the previous PR #164. There is others changes affect the docs/ folder when I run the collection_prep_add_docs -p . command. These changes are added in the last commit 64eab40. I let you decide rather we keep the commit or remove it. The --dependency-update insertion option is tested used a local helm chart repository create via docker. So here are the tasks that test this feature. Maybe if we create a GitHub repository for the helm chart, we can add this test code in the CI pipeline. # Test The update dependency with chart_repo_url - name: "Test chart without dependencies block and chart_repo_url defined" block: - name: "Test chart without dependencies block and chart_repo_url defined" helm: binary_path: "{{ helm_binary }}" name: test chart_ref: "ingress-nginx" chart_repo_url: https://kubernetes.github.io/ingress-nginx chart_version: "{{ chart_source_version | default(omit) }}" namespace: "{{ helm_namespace }}" create_namespace: yes register: release - assert: that: - "'--dependency-update' not in release.command" - "'upgrade' in release.command" success_msg: "Command does not contains '--dependency-update' options" fail_msg: "Command contains '--dependency-update' options" - name: "Test chart with dependencies block and chart_repo_url defined and replace True" block: - name: "Test chart with dependencies block and chart_repo_url defined and replace True" helm: binary_path: "{{ helm_binary }}" name: test1 chart_ref: "dep_up" chart_repo_url: http://repo:8080/charts chart_version: "{{ chart_source_version | default(omit) }}" namespace: "{{ helm_namespace }}" create_namespace: yes replace: true register: release - debug: var=release - assert: that: - "'--dependency-update' in release.command" - "'install' in release.command" success_msg: "Command contains '--dependency-update' options with helm install command" fail_msg: "Command not contains '--dependency-update' with helm install command" - name: "Test chart with dependencies block and chart_repo_url defined and replace False fails" block: - name: "Test chart with dependencies block and chart_repo_url defined and replace False fails" helm: binary_path: "{{ helm_binary }}" name: test2 chart_ref: "dep_up" chart_repo_url: http://repo:8080/charts chart_version: "{{ chart_source_version | default(omit) }}" namespace: "{{ helm_namespace }}" create_namespace: yes replace: false register: release ignore_errors: true - assert: that: - release.failed - release.msg == "'--dependency-update' hasn't been supported yet with 'helm upgrade'. Please use 'helm install' instead by adding 'replace' option" success_msg: "Command build fail when adding '--dependency-update' with the helm upgrade command" Reviewed-by: Mike Graves <mgraves@redhat.com> Reviewed-by: Wissem BEN CHAABANE <benchaaben.wissem@gmail.com> Reviewed-by: Bikouo Aubin <None>
311 lines
12 KiB
ReStructuredText
311 lines
12 KiB
ReStructuredText
.. _kubernetes.core.helm_template_module:
|
|
|
|
|
|
*****************************
|
|
kubernetes.core.helm_template
|
|
*****************************
|
|
|
|
**Render chart templates**
|
|
|
|
|
|
|
|
.. contents::
|
|
:local:
|
|
:depth: 1
|
|
|
|
|
|
Synopsis
|
|
--------
|
|
- Render chart templates to an output directory or as text of concatenated yaml documents.
|
|
|
|
|
|
|
|
|
|
Parameters
|
|
----------
|
|
|
|
.. raw:: html
|
|
|
|
<table border=0 cellpadding=0 class="documentation-table">
|
|
<tr>
|
|
<th colspan="1">Parameter</th>
|
|
<th>Choices/<font color="blue">Defaults</font></th>
|
|
<th width="100%">Comments</th>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
<b>binary_path</b>
|
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">path</span>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
</td>
|
|
<td>
|
|
<div>The path of a helm binary to use.</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
<b>chart_ref</b>
|
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">path</span>
|
|
/ <span style="color: red">required</span>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
</td>
|
|
<td>
|
|
<div>Chart reference with repo prefix, for example, <code>nginx-stable/nginx-ingress</code>.</div>
|
|
<div>Path to a packaged chart.</div>
|
|
<div>Path to an unpacked chart directory.</div>
|
|
<div>Absolute URL.</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
<b>chart_repo_url</b>
|
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">string</span>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
</td>
|
|
<td>
|
|
<div>Chart repository URL where the requested chart is located.</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
<b>chart_version</b>
|
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">string</span>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
</td>
|
|
<td>
|
|
<div>Chart version to use. If this is not specified, the latest version is installed.</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
<b>dependency_update</b>
|
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">boolean</span>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
|
<li><div style="color: blue"><b>no</b> ←</div></li>
|
|
<li>yes</li>
|
|
</ul>
|
|
</td>
|
|
<td>
|
|
<div>Run helm dependency update before the operation.</div>
|
|
<div>The <em>dependency_update</em> option require the add of <code>dependencies</code> block in <code>Chart.yaml/requirements.yaml</code> file.</div>
|
|
<div>For more information please visit <a href='https://helm.sh/docs/helm/helm_dependency/'>https://helm.sh/docs/helm/helm_dependency/</a></div>
|
|
<div style="font-size: small; color: darkgreen"><br/>aliases: dep_up</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
<b>include_crds</b>
|
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">boolean</span>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
|
<li><div style="color: blue"><b>no</b> ←</div></li>
|
|
<li>yes</li>
|
|
</ul>
|
|
</td>
|
|
<td>
|
|
<div>Include custom resource descriptions in rendered templates.</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
<b>output_dir</b>
|
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">path</span>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
</td>
|
|
<td>
|
|
<div>Output directory where templates will be written.</div>
|
|
<div>If the directory already exists, it will be overwritten.</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
<b>release_values</b>
|
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">dictionary</span>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
<b>Default:</b><br/><div style="color: blue">{}</div>
|
|
</td>
|
|
<td>
|
|
<div>Values to pass to chart.</div>
|
|
<div style="font-size: small; color: darkgreen"><br/>aliases: values</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
<b>update_repo_cache</b>
|
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">boolean</span>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
|
<li><div style="color: blue"><b>no</b> ←</div></li>
|
|
<li>yes</li>
|
|
</ul>
|
|
</td>
|
|
<td>
|
|
<div>Run <code>helm repo update</code> before the operation. Can be run as part of the template generation or as a separate step.</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
<b>values_files</b>
|
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">list</span>
|
|
/ <span style="color: purple">elements=string</span>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
<b>Default:</b><br/><div style="color: blue">[]</div>
|
|
</td>
|
|
<td>
|
|
<div>Value files to pass to chart.</div>
|
|
<div>Paths will be read from the target host's filesystem, not the host running ansible.</div>
|
|
<div><em>values_files</em> option is evaluated before <em>values</em> option if both are used.</div>
|
|
<div>Paths are evaluated in the order the paths are specified.</div>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<br/>
|
|
|
|
|
|
|
|
|
|
Examples
|
|
--------
|
|
|
|
.. code-block:: yaml
|
|
|
|
- name: Render templates to specified directory
|
|
kubernetes.core.helm_template:
|
|
chart_ref: stable/prometheus
|
|
output_dir: mycharts
|
|
|
|
- name: Render templates
|
|
kubernetes.core.helm_template:
|
|
chart_ref: stable/prometheus
|
|
register: result
|
|
|
|
- name: Write templates to file
|
|
copy:
|
|
dest: myfile.yaml
|
|
content: "{{ result.stdout }}"
|
|
|
|
|
|
|
|
Return Values
|
|
-------------
|
|
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
|
|
|
|
.. raw:: html
|
|
|
|
<table border=0 cellpadding=0 class="documentation-table">
|
|
<tr>
|
|
<th colspan="1">Key</th>
|
|
<th>Returned</th>
|
|
<th width="100%">Description</th>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="return-"></div>
|
|
<b>command</b>
|
|
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">string</span>
|
|
</div>
|
|
</td>
|
|
<td>always</td>
|
|
<td>
|
|
<div>Full <code>helm</code> command run by this module, in case you want to re-run the command outside the module or debug a problem.</div>
|
|
<br/>
|
|
<div style="font-size: smaller"><b>Sample:</b></div>
|
|
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">helm template --output-dir mychart nginx-stable/nginx-ingress</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="return-"></div>
|
|
<b>stderr</b>
|
|
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">string</span>
|
|
</div>
|
|
</td>
|
|
<td>always</td>
|
|
<td>
|
|
<div>Full <code>helm</code> command stderr, in case you want to display it or examine the event log.</div>
|
|
<br/>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1">
|
|
<div class="ansibleOptionAnchor" id="return-"></div>
|
|
<b>stdout</b>
|
|
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
|
<div style="font-size: small">
|
|
<span style="color: purple">string</span>
|
|
</div>
|
|
</td>
|
|
<td>always</td>
|
|
<td>
|
|
<div>Full <code>helm</code> command stdout. If no <em>output_dir</em> has been provided this will contain the rendered templates as concatenated yaml documents.</div>
|
|
<br/>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<br/><br/>
|
|
|
|
|
|
Status
|
|
------
|
|
|
|
|
|
Authors
|
|
~~~~~~~
|
|
|
|
- Mike Graves (@gravesm)
|