Compare commits

..

15 Commits

Author SHA1 Message Date
Mike Graves
0ec30da62f helm - expand kubeconfig path with user's home dir (#654) (#696)
[backport/stable-2.4] helm - expand kubeconfig path with user's home dir (#654)

helm - expand kubeconfig path with user's home dir
SUMMARY
Currently the helm module fails when providing the default kubeconfig path explicitly, while the same path is fine for the k8s module.
ISSUE TYPE
Bugfix Pull Request
COMPONENT NAME
helm
ADDITIONAL INFORMATION

name: Deploy kubelet-csr-approver delegate_to: client run_once: true kubernetes.core.helm: update_repo_cache: true kubeconfig: "~/.kube/config" state: present name: kubelet-csr-approver namespace: kubelet-csr-approver create_namespace: true chart_ref: kubelet-csr-approver/kubelet-csr-approver chart_version: 1.0.5 values: "{{ lookup('template', 'values.yaml.j2') | from_yaml }}" atomic: true

Before change:
TASK [kubernetes/kubelet_csr_approver : Deploy kubelet-csr-approver] *** An exception occurred during task execution. To see the full traceback, use -vvv. The error was: FileNotFoundError: [Errno 2] No such file or directory: '/.kube/config'
fatal: [node-1 -> client(192.168.121.56)]: FAILED! => {"changed": false, "module_stderr": "", "module_stdout": "Traceback (most recent call last):\r\n  File "/home/vagrant/.ansible/tmp/ansible-tmp-1697293347.7135417-118207-9805169252135/AnsiballZ_helm.py", line 107, in \r\n    _ansiballz_main()\r\n  File "/home/vagrant/.ansible/tmp/ansible-tmp-1697293347.7135417-118207-9805169252135/AnsiballZ_helm.py", line 99, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File "/home/vagrant/.ansible/tmp/ansible-tmp-1697293347.7135417-118207-9805169252135/AnsiballZ_helm.py", line 47, in invoke_module\r\n    runpy.run_module(mod_name='ansible_collections.kubernetes.core.plugins.modules.helm', init_globals=dict(_module_fqn='ansible_collections.kubernetes.core.plugins.modules.helm', _modlib_path=modlib_path),\r\n  File "/usr/lib/python3.10/runpy.py", line 224, in run_module\r\n    return _run_module_code(code, init_globals, run_name, mod_spec)\r\n  File "/usr/lib/python3.10/runpy.py", line 96, in _run_module_code\r\n    _run_code(code, mod_globals, init_globals,\r\n  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code\r\n    exec(code, run_globals)\r\n  File "/tmp/ansible_kubernetes.core.helm_payload_o8s36dti/ansible_kubernetes.core.helm_payload.zip/ansible_collections/kubernetes/core/plugins/modules/helm.py", line 924, in \r\n  File "/tmp/ansible_kubernetes.core.helm_payload_o8s36dti/ansible_kubernetes.core.helm_payload.zip/ansible_collections/kubernetes/core/plugins/modules/helm.py", line 737, in main\r\n  File "/tmp/ansible_kubernetes.core.helm_payload_o8s36dti/ansible_kubernetes.core.helm_payload.zip/ansible_collections/kubernetes/core/plugins/modules/helm.py", line 435, in run_repo_update\r\n  File "/tmp/ansible_kubernetes.core.helm_payload_o8s36dti/ansible_kubernetes.core.helm_payload.zip/ansible_collections/kubernetes/core/plugins/module_utils/helm.py", line 169, in run_helm_command\r\n  File "/tmp/ansible_kubernetes.core.helm_payload_o8s36dti/ansible_kubernetes.core.helm_payload.zip/ansible_collections/kubernetes/core/plugins/module_utils/helm.py", line 162, in env_update\r\n  File "/tmp/ansible_kubernetes.core.helm_payload_o8s36dti/ansible_kubernetes.core.helm_payload.zip/ansible_collections/kubernetes/core/plugins/module_utils/helm.py", line 120, in _prepare_helm_environment\r\nFileNotFoundError: [Errno 2] No such file or directory: '/.kube/config'\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
After change:
TASK [kubernetes/kubelet_csr_approver : Deploy kubelet-csr-approver] *** changed: [node-1 -> client(192.168.121.56)]
Reviewed-by: Mike Graves mgraves@redhat.com
Reviewed-by: Bikouo Aubin
(cherry picked from commit 9f7c865)
2024-03-13 13:58:51 +00:00
Bikouo Aubin
7103da38ff Prepare release 2.4.2 (#691)
* Prepare Release 2.4.2

* Update CHANGELOG.rst

* Fixing integration tests
2024-03-04 11:02:22 +01:00
Bikouo Aubin
ed3969fc54 [PR #676/19559892 backport][stable-2.4] fix(Collection's util resource discovery fails when complex subresources present #659) (#688)
* update node image

* fix(Collection's util resource discovery fails when complex subresources present #659)

* fix(add changelog fragment)

* Create discovery.yml

* Update main.yml

* Backport PR659

* fix sanity issues

---------

Co-authored-by: Bastien Bosser <bastien.bosser@eviden.com>
2024-03-01 17:42:08 +01:00
GomathiselviS
7e6c2cdd18 Prepare for release 2.4.1 (#677)
Prepare for release 2.4.1

SUMMARY


This is a release prep PR for kubernetes.core 2.4.1
ISSUE TYPE


Bugfix Pull Request
Docs Pull Request
Feature Pull Request
New Module Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Jill R
Reviewed-by: Bikouo Aubin
Reviewed-by: Mike Graves <mgraves@redhat.com>
Reviewed-by: Alina Buzachis
2024-02-06 16:36:37 +00:00
GomathiselviS
818f06f215 Merge pull request #674 from GomathiselviS/sanity_fix
Fix Sanity failures in stable-2.4
2024-02-01 11:37:33 -05:00
GomathiselviS
e9ae1fee21 Add ignore import 2024-01-30 13:58:10 -05:00
GomathiselviS
c255d11c6e ansible-lint fix 2024-01-30 13:09:52 -05:00
GomathiselviS
b01f78b0b7 add ansible-host-pattern 2024-01-29 12:55:17 -05:00
GomathiselviS
d40f478552 Add docs 2024-01-26 12:15:12 -05:00
GomathiselviS
bb45bb676f Add ignore-2.17 and .ansible-lint 2024-01-25 15:35:25 -05:00
GomathiselviS
ea54179b23 Add ignore-2.17 and .ansible-lint 2024-01-25 15:35:12 -05:00
GomathiselviS
9e41291489 Add ignore statements 2024-01-25 15:25:33 -05:00
GomathiselviS
15da427a34 Add GH workflows 2024-01-25 15:17:09 -05:00
GomathiselviS
0a6d3b604b Fix Sanity failures in stable-2.4 2024-01-25 15:05:01 -05:00
Bikouo Aubin
1527469cb5 Release 2.4.0 (#572) 2023-02-02 07:54:33 +01:00
208 changed files with 903 additions and 3314 deletions

View File

@@ -1,6 +1,7 @@
--- ---
profile: production profile: production
skip_list:
- meta-runtime[unsupported-version]
exclude_paths: exclude_paths:
- tests/integration - tests/integration
- tests/sanity - tests/sanity

1
.github/stale.yml vendored
View File

@@ -12,7 +12,6 @@ daysUntilClose: 30
# Only issues or pull requests with all of these labels are check if stale. # Only issues or pull requests with all of these labels are check if stale.
# Defaults to `[]` (disabled) # Defaults to `[]` (disabled)
onlyLabels: [] onlyLabels: []
# Issues or Pull Requests with these labels will never be considered stale. Set # Issues or Pull Requests with these labels will never be considered stale. Set
# to `[]` to disable # to `[]` to disable
exemptLabels: exemptLabels:

View File

@@ -132,6 +132,8 @@ jobs:
- name: create kubernetes cluster - name: create kubernetes cluster
uses: helm/kind-action@v1.8.0 uses: helm/kind-action@v1.8.0
with:
node_image: "kindest/node:v1.29.2"
- name: Run integration tests - name: Run integration tests
uses: ansible-network/github_actions/.github/actions/ansible_test_integration@main uses: ansible-network/github_actions/.github/actions/ansible_test_integration@main

View File

@@ -10,7 +10,7 @@ on:
- main - main
- stable-* - stable-*
tags: tags:
- '*' - "*"
jobs: jobs:
linters: linters:

View File

@@ -1,3 +1,4 @@
---
name: Unit tests name: Unit tests
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}

View File

@@ -4,44 +4,26 @@ Kubernetes Collection Release Notes
.. contents:: Topics .. contents:: Topics
v2.4.2
v3.0.0
====== ======
Release Summary Release Summary
--------------- ---------------
This major release drops support for ansible-core versions lower than 2.14, Python versions lower than 3.9 and updates python kubernetes library to 24.2.0, helm/kind-action to 1.8.0, kubernetes >= 1.24, along with bug fixes and minor changes. fix resource discovery when complex subresources present
Minor Changes
-------------
- helm - add ``reuse_values`` and ``reset_values`` support to helm module (https://github.com/ansible-collections/kubernetes.core/issues/394).
- k8s - add new option ``delete_all`` to support deletion of all resources when state is set to ``absent``. (https://github.com/ansible-collections/kubernetes.core/issues/504)
- k8s, k8s_info - add a hidden_fields option to allow fields to be hidden in the results of k8s and k8s_info
- k8s_drain - add ability to filter the list of pods to be drained by a pod label selector (https://github.com/ansible-collections/kubernetes.core/issues/474).
Breaking Changes / Porting Guide
--------------------------------
- Remove support for ansible-core < 2.14
- Update python kubernetes library to 24.2.0, helm/kind-action to 1.8.0, kubernetes >= 1.24.
Deprecated Features
-------------------
- k8s - the ``k8s`` inventory plugin has been deprecated and will be removed in release 4.0.0 (https://github.com/ansible-collections/kubernetes.core/issues/31).
Bugfixes Bugfixes
-------- --------
- helm - Put the chart_ref into quotes when running ``helm show chart``, ``helm upgrade`` and ``helm dependency update`` commands (https://github.com/ansible-collections/kubernetes.core/issues/653). - Resolve Collections util resource discovery fails when complex subresources present (https://github.com/ansible-collections/kubernetes.core/pull/676).
- helm - delete temporary file created when deploying chart with option ``release_values`` set (https://github.com/ansible-collections/kubernetes.core/issues/530).
- helm - fix issue occurring when uninstalling chart with statues others than ``deployed`` (https://github.com/ansible-collections/kubernetes.core/issues/319). v2.4.1
- helm - fix post_renderer argument breaking the helm deploy_command (https://github.com/ansible-collections/kubernetes.core/pull/586). ======
- helm - use post_renderer when checking ``changed`` status for a helm release (https://github.com/ansible-collections/kubernetes.core/pull/588).
- k8s_scale - clean handling of ResourceTimeout exception (https://github.com/ansible-collections/kubernetes.core/issues/583). Release Summary
- k8s_scale - fix issue when scaling StatefulSets with ``updateStrategy=OnDelete`` (https://github.com/ansible-collections/kubernetes.core/issues/579). ---------------
The kubernetes.core 2.4.1 release includes several trivial bug fixes related to code sanity.
v2.4.0 v2.4.0
====== ======
@@ -134,7 +116,7 @@ v2.3.1
Bugfixes Bugfixes
-------- --------
- Catch expectation raised when the process is waiting for resources (https://github.com/ansible-collections/kubernetes.core/issues/407). - Catch exception raised when the process is waiting for resources (https://github.com/ansible-collections/kubernetes.core/issues/407).
- Remove `omit` placeholder when defining resource using template parameter (https://github.com/ansible-collections/kubernetes.core/issues/431). - Remove `omit` placeholder when defining resource using template parameter (https://github.com/ansible-collections/kubernetes.core/issues/431).
- k8s - fix the issue when trying to delete resources using label_selectors options (https://github.com/ansible-collections/kubernetes.core/issues/433). - k8s - fix the issue when trying to delete resources using label_selectors options (https://github.com/ansible-collections/kubernetes.core/issues/433).
- k8s_cp - fix issue when using parameter local_path with file on managed node. (https://github.com/ansible-collections/kubernetes.core/issues/421). - k8s_cp - fix issue when using parameter local_path with file on managed node. (https://github.com/ansible-collections/kubernetes.core/issues/421).

View File

@@ -1,5 +1,5 @@
# Also needs to be updated in galaxy.yml # Also needs to be updated in galaxy.yml
VERSION = 3.0.0 VERSION = 2.4.1
TEST_ARGS ?= "" TEST_ARGS ?= ""
PYTHON_VERSION ?= `python -c 'import platform; print(".".join(platform.python_version_tuple()[0:2]))'` PYTHON_VERSION ?= `python -c 'import platform; print(".".join(platform.python_version_tuple()[0:2]))'`

View File

@@ -9,7 +9,7 @@ The collection includes a variety of Ansible content to help automate the manage
<!--start requires_ansible--> <!--start requires_ansible-->
## Ansible version compatibility ## Ansible version compatibility
This collection has been tested against following Ansible versions: **>=2.14.0**. This collection has been tested against following Ansible versions: **>=2.9.17**.
For collections that support Ansible 2.9, please ensure you update your `network_os` to use the For collections that support Ansible 2.9, please ensure you update your `network_os` to use the
fully qualified collection name (for example, `cisco.ios.ios`). fully qualified collection name (for example, `cisco.ios.ios`).
@@ -20,13 +20,13 @@ PEP440 is the schema used to describe the versions of Ansible.
## Python Support ## Python Support
* Collection supports 3.9+ * Collection supports 3.6+
Note: Python2 is deprecated from [1st January 2020](https://www.python.org/doc/sunset-python-2/). Please switch to Python3. Note: Python2 is deprecated from [1st January 2020](https://www.python.org/doc/sunset-python-2/). Please switch to Python3.
## Kubernetes Version Support ## Kubernetes Version Support
This collection supports Kubernetes versions >= 1.24. This collection supports Kubernetes versions >=1.19.
## Included content ## Included content
@@ -93,7 +93,7 @@ You can also include it in a `requirements.yml` file and install it via `ansible
--- ---
collections: collections:
- name: kubernetes.core - name: kubernetes.core
version: 3.0.0 version: 2.4.1
``` ```
### Installing the Kubernetes Python Library ### Installing the Kubernetes Python Library

View File

@@ -762,55 +762,20 @@ releases:
name: helm_pull name: helm_pull
namespace: '' namespace: ''
release_date: '2023-01-24' release_date: '2023-01-24'
3.0.0: 2.4.1:
changes: changes:
breaking_changes: release_summary: The kubernetes.core 2.4.1 release includes several trivial
- Remove support for ansible-core < 2.14 bug fixes related to sanity.
- Update python kubernetes library to 24.2.0, helm/kind-action to 1.8.0, kubernetes
>= 1.24.
bugfixes:
- helm - Put the chart_ref into quotes when running ``helm show chart``, ``helm
upgrade`` and ``helm dependency update`` commands (https://github.com/ansible-collections/kubernetes.core/issues/653).
- helm - delete temporary file created when deploying chart with option ``release_values``
set (https://github.com/ansible-collections/kubernetes.core/issues/530).
- helm - fix issue occurring when uninstalling chart with statues others than
``deployed`` (https://github.com/ansible-collections/kubernetes.core/issues/319).
- helm - fix post_renderer argument breaking the helm deploy_command (https://github.com/ansible-collections/kubernetes.core/pull/586).
- helm - use post_renderer when checking ``changed`` status for a helm release
(https://github.com/ansible-collections/kubernetes.core/pull/588).
- k8s_scale - clean handling of ResourceTimeout exception (https://github.com/ansible-collections/kubernetes.core/issues/583).
- k8s_scale - fix issue when scaling StatefulSets with ``updateStrategy=OnDelete``
(https://github.com/ansible-collections/kubernetes.core/issues/579).
deprecated_features:
- k8s - the ``k8s`` inventory plugin has been deprecated and will be removed
in release 4.0.0 (https://github.com/ansible-collections/kubernetes.core/issues/31).
minor_changes:
- helm - add ``reuse_values`` and ``reset_values`` support to helm module (https://github.com/ansible-collections/kubernetes.core/issues/394).
- k8s - add new option ``delete_all`` to support deletion of all resources when
state is set to ``absent``. (https://github.com/ansible-collections/kubernetes.core/issues/504)
- k8s, k8s_info - add a hidden_fields option to allow fields to be hidden in
the results of k8s and k8s_info
- k8s_drain - add ability to filter the list of pods to be drained by a pod
label selector (https://github.com/ansible-collections/kubernetes.core/issues/474).
release_summary: This major release drops support for ansible-core versions
lower than 2.14, Python versions lower than 3.9 and updates python kubernetes
library to 24.2.0, helm/kind-action to 1.8.0, kubernetes >= 1.24, along with
bug fixes and minor changes.
fragments: fragments:
- 20230206-deprecate-k8s-inventory.yml - fix_sanity_errors.yml
- 20231110-helm-quote-ref.yaml release_date: '2024-02-06'
- 517-k8s-make-name-optional.yaml 2.4.2:
- 575-helm-add-support-for-reuse_values-and-reset_values.yml changes:
- 579-k8s_scale-fix-issue-with-scaling-statefulsets.yml bugfixes:
- 583-k8s_scale-clean-handling-of-ResourceTimeout-exception.yaml - Resolve Collections util resource discovery fails when complex subresources
- 586-helm-fix-post-renderer-arg.yml present (https://github.com/ansible-collections/kubernetes.core/pull/676).
- 588-helm-use-post-renderer-for-helmdiff.yml release_summary: fix resource discovery when complex subresources present
- 589-helm-uninstall-chart-releases-with-statuses-different-than-deployed.yaml fragments:
- 606-k8s_drain-add-pod_selectors-parameter.yaml - 2.4.2.yml
- 612-fix-helm-tests.yaml - 20240222-Collections-util-resource-discovery-fails-when-complex-subresources-present.yml
- 629-add-hidden-fields-option.yaml release_date: '2024-03-01'
- gha-sanity-fixes.yaml
- helm-delete-temporary-file-created-when-using-option-release_values.yaml
- remove_ansible_2_13.yaml
- update_supported_versions.yaml
release_date: '2023-11-17'

View File

@@ -10,21 +10,21 @@ notesdir: fragments
prelude_section_name: release_summary prelude_section_name: release_summary
prelude_section_title: Release Summary prelude_section_title: Release Summary
sections: sections:
- - major_changes - - major_changes
- Major Changes - Major Changes
- - minor_changes - - minor_changes
- Minor Changes - Minor Changes
- - breaking_changes - - breaking_changes
- Breaking Changes / Porting Guide - Breaking Changes / Porting Guide
- - deprecated_features - - deprecated_features
- Deprecated Features - Deprecated Features
- - removed_features - - removed_features
- Removed Features (previously deprecated) - Removed Features (previously deprecated)
- - security_fixes - - security_fixes
- Security Fixes - Security Fixes
- - bugfixes - - bugfixes
- Bugfixes - Bugfixes
- - known_issues - - known_issues
- Known Issues - Known Issues
title: Kubernetes Collection title: Kubernetes Collection
trivial_section_name: trivial trivial_section_name: trivial

View File

@@ -0,0 +1,3 @@
---
bugfixes:
- helm - expand kubeconfig path with user's home directory for consistency with k8s

View File

@@ -105,27 +105,6 @@ Parameters
<div style="font-size: small; color: darkgreen"><br/>aliases: kube_context</div> <div style="font-size: small; color: darkgreen"><br/>aliases: kube_context</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>get_all_values</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li><div style="color: blue"><b>no</b>&nbsp;&larr;</div></li>
<li>yes</li>
</ul>
</td>
<td>
<div>Set to <code>True</code> if you want to get all (computed) values of the release.</div>
<div>When <code>False</code> (default), only user supplied values are returned.</div>
</td>
</tr>
<tr> <tr>
<td colspan="1"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -148,7 +127,7 @@ Parameters
<b>kubeconfig</b> <b>kubeconfig</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small"> <div style="font-size: small">
<span style="color: purple">raw</span> <span style="color: purple">path</span>
</div> </div>
</td> </td>
<td> <td>
@@ -156,7 +135,6 @@ Parameters
<td> <td>
<div>Helm option to specify kubeconfig path to use.</div> <div>Helm option to specify kubeconfig path to use.</div>
<div>If the value is not specified in the task, the value of environment variable <code>K8S_AUTH_KUBECONFIG</code> will be used instead.</div> <div>If the value is not specified in the task, the value of environment variable <code>K8S_AUTH_KUBECONFIG</code> will be used instead.</div>
<div>The configuration can be provided as dictionary. Added in version 2.4.0.</div>
<div style="font-size: small; color: darkgreen"><br/>aliases: kubeconfig_path</div> <div style="font-size: small; color: darkgreen"><br/>aliases: kubeconfig_path</div>
</td> </td>
</tr> </tr>
@@ -194,32 +172,6 @@ Parameters
<div style="font-size: small; color: darkgreen"><br/>aliases: namespace</div> <div style="font-size: small; color: darkgreen"><br/>aliases: namespace</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>release_state</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>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
</td>
<td>
<b>Default:</b><br/><div style="color: blue">[]</div>
</td>
<td>
<div>Show releases as per their states.</div>
<div>Default value is <code>deployed</code> and <code>failed</code>.</div>
<div>If set to <code>all</code>, show all releases without any filter applied.</div>
<div>If set to <code>deployed</code>, show deployed releases.</div>
<div>If set to <code>failed</code>, show failed releases.</div>
<div>If set to <code>pending</code>, show pending releases.</div>
<div>If set to <code>superseded</code>, show superseded releases.</div>
<div>If set to <code>uninstalled</code>, show uninstalled releases, if <code>helm uninstall --keep-history</code> was used.</div>
<div>If set to <code>uninstalling</code>, show releases that are currently being uninstalled.</div>
</td>
</tr>
<tr> <tr>
<td colspan="1"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -252,18 +204,11 @@ Examples
.. code-block:: yaml .. code-block:: yaml
- name: Gather information of Grafana chart inside monitoring namespace - name: Deploy latest version of Grafana chart inside monitoring namespace
kubernetes.core.helm_info: kubernetes.core.helm_info:
name: test name: test
release_namespace: monitoring release_namespace: monitoring
- name: Gather information about test-chart with pending state
kubernetes.core.helm_info:
name: test-chart
release_namespace: testenv
release_state:
- pending
Return Values Return Values
@@ -325,42 +270,6 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
<br/> <br/>
</td> </td>
</tr> </tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>hooks</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
/ <span style="color: purple">elements=dictionary</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
</td>
<td>always</td>
<td>
<div>Hooks of the release</div>
<br/>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>manifest</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
/ <span style="color: purple">elements=dictionary</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
</td>
<td>always</td>
<td>
<div>Manifest of the release</div>
<br/>
</td>
</tr>
<tr> <tr>
<td class="elbow-placeholder">&nbsp;</td> <td class="elbow-placeholder">&nbsp;</td>
<td colspan="1"> <td colspan="1">
@@ -393,23 +302,6 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
<br/> <br/>
</td> </td>
</tr> </tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>notes</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>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
</td>
<td>always</td>
<td>
<div>Notes of the release</div>
<br/>
</td>
</tr>
<tr> <tr>
<td class="elbow-placeholder">&nbsp;</td> <td class="elbow-placeholder">&nbsp;</td>
<td colspan="1"> <td colspan="1">

View File

@@ -36,12 +36,12 @@ Parameters
<table border=0 cellpadding=0 class="documentation-table"> <table border=0 cellpadding=0 class="documentation-table">
<tr> <tr>
<th colspan="2">Parameter</th> <th colspan="1">Parameter</th>
<th>Choices/<font color="blue">Defaults</font></th> <th>Choices/<font color="blue">Defaults</font></th>
<th width="100%">Comments</th> <th width="100%">Comments</th>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>api_key</b> <b>api_key</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -57,7 +57,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>atomic</b> <b>atomic</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -76,7 +76,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>binary_path</b> <b>binary_path</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -91,7 +91,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>ca_cert</b> <b>ca_cert</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -108,7 +108,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>chart_ref</b> <b>chart_ref</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -127,7 +127,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>chart_repo_url</b> <b>chart_repo_url</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -142,7 +142,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>chart_version</b> <b>chart_version</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -157,7 +157,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>context</b> <b>context</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -174,7 +174,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>create_namespace</b> <b>create_namespace</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -194,14 +194,13 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>dependency_update</b> <b>dependency_update</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small"> <div style="font-size: small">
<span style="color: purple">boolean</span> <span style="color: purple">boolean</span>
</div> </div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
</td> </td>
<td> <td>
<ul style="margin: 0; padding: 0"><b>Choices:</b> <ul style="margin: 0; padding: 0"><b>Choices:</b>
@@ -210,7 +209,7 @@ Parameters
</ul> </ul>
</td> </td>
<td> <td>
<div>Run standalone <code>helm dependency update CHART</code> before the operation.</div> <div>Run standelone <code>helm dependency update CHART</code> before the operation.</div>
<div>Run inline <code>--dependency-update</code> with <code>helm install</code> command. This feature is not supported yet with the <code>helm upgrade</code> command.</div> <div>Run inline <code>--dependency-update</code> with <code>helm install</code> command. This feature is not supported yet with the <code>helm upgrade</code> command.</div>
<div>So we should consider to use <em>dependency_update</em> options with <em>replace</em> option enabled when specifying <em>chart_repo_url</em>.</div> <div>So we should consider to use <em>dependency_update</em> options with <em>replace</em> option enabled when specifying <em>chart_repo_url</em>.</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>The <em>dependency_update</em> option require the add of <code>dependencies</code> block in <code>Chart.yaml/requirements.yaml</code> file.</div>
@@ -219,7 +218,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>disable_hook</b> <b>disable_hook</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -238,7 +237,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>force</b> <b>force</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -257,7 +256,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>history_max</b> <b>history_max</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -274,7 +273,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>host</b> <b>host</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -290,12 +289,12 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>kubeconfig</b> <b>kubeconfig</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small"> <div style="font-size: small">
<span style="color: purple">raw</span> <span style="color: purple">path</span>
</div> </div>
</td> </td>
<td> <td>
@@ -303,28 +302,11 @@ Parameters
<td> <td>
<div>Helm option to specify kubeconfig path to use.</div> <div>Helm option to specify kubeconfig path to use.</div>
<div>If the value is not specified in the task, the value of environment variable <code>K8S_AUTH_KUBECONFIG</code> will be used instead.</div> <div>If the value is not specified in the task, the value of environment variable <code>K8S_AUTH_KUBECONFIG</code> will be used instead.</div>
<div>The configuration can be provided as dictionary. Added in version 2.4.0.</div>
<div style="font-size: small; color: darkgreen"><br/>aliases: kubeconfig_path</div> <div style="font-size: small; color: darkgreen"><br/>aliases: kubeconfig_path</div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>post_renderer</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
</td>
<td>
</td>
<td>
<div>Path to an executable to be used for post rendering.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>purge</b> <b>purge</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -343,7 +325,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>release_name</b> <b>release_name</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -360,7 +342,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>release_namespace</b> <b>release_namespace</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -377,7 +359,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>release_state</b> <b>release_state</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -397,7 +379,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>release_values</b> <b>release_values</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -414,7 +396,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>replace</b> <b>replace</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -436,108 +418,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>reset_values</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.5.0</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li>no</li>
<li><div style="color: blue"><b>yes</b>&nbsp;&larr;</div></li>
</ul>
</td>
<td>
<div>When upgrading package, reset the values to the ones built into the chart.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>reuse_values</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.5.0</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li>no</li>
<li>yes</li>
</ul>
</td>
<td>
<div>When upgrading package, specifies wether to reuse the last release&#x27;s values and merge in any overrides from parameters <em>release_values</em>, <em>values_files</em> or <em>set_values</em>.</div>
<div>If <em>reset_values</em> is set to <code>True</code>, this is ignored.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>set_values</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=dictionary</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
</td>
<td>
</td>
<td>
<div>Values to pass to chart configuration</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td colspan="1"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>value</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
/ <span style="color: red">required</span>
</div>
</td>
<td>
</td>
<td>
<div>Value to pass to chart configuration (e.g phase=prod).</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>value_type</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">-</span>
</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li><div style="color: blue"><b>raw</b>&nbsp;&larr;</div></li>
<li>string</li>
<li>json</li>
<li>file</li>
</ul>
</td>
<td>
<div>Use <code>raw</code> set individual value.</div>
<div>Use <code>string</code> to force a string for an individual value.</div>
<div>Use <code>file</code> to set individual values from a file when the value itself is too long for the command line or is dynamically generated.</div>
<div>Use <code>json</code> to set json values (scalars/objects/arrays). This feature requires helm&gt;=3.10.0.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>skip_crds</b> <b>skip_crds</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -557,7 +438,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>timeout</b> <b>timeout</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -575,7 +456,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>update_repo_cache</b> <b>update_repo_cache</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -594,7 +475,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>validate_certs</b> <b>validate_certs</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -615,7 +496,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>values_files</b> <b>values_files</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -636,7 +517,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>wait</b> <b>wait</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -656,7 +537,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>wait_timeout</b> <b>wait_timeout</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -675,12 +556,6 @@ Parameters
<br/> <br/>
Notes
-----
.. note::
- The default idempotency check can fail to report changes when ``release_state`` is set to ``present`` and ``chart_repo_url`` is defined. Install helm diff >= 3.4.1 for better results.
Examples Examples
@@ -737,15 +612,6 @@ Examples
state: absent state: absent
update_repo_cache: true update_repo_cache: true
- name: Deploy Grafana chart using set values on target
kubernetes.core.helm:
name: test
chart_ref: stable/grafana
release_namespace: monitoring
set_values:
- value: phase=prod
value_type: string
# From git # From git
- name: Git clone stable repo on HEAD - name: Git clone stable repo on HEAD
ansible.builtin.git: ansible.builtin.git:
@@ -791,17 +657,6 @@ Examples
logging: logging:
enabled: True enabled: True
# Deploy latest version
- name: Deploy latest version of Grafana chart using reuse_values
kubernetes.core.helm:
name: test
chart_ref: stable/grafana
release_namespace: monitoring
reuse_values: true
values:
replicas: 2
version: 3e8ec0b2dffa40fb97d5342e4af887de95faa8c61a62480dd7f8aa03dffcf533
Return Values Return Values

View File

@@ -126,7 +126,7 @@ Parameters
<b>kubeconfig</b> <b>kubeconfig</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small"> <div style="font-size: small">
<span style="color: purple">raw</span> <span style="color: purple">path</span>
</div> </div>
</td> </td>
<td> <td>
@@ -134,7 +134,6 @@ Parameters
<td> <td>
<div>Helm option to specify kubeconfig path to use.</div> <div>Helm option to specify kubeconfig path to use.</div>
<div>If the value is not specified in the task, the value of environment variable <code>K8S_AUTH_KUBECONFIG</code> will be used instead.</div> <div>If the value is not specified in the task, the value of environment variable <code>K8S_AUTH_KUBECONFIG</code> will be used instead.</div>
<div>The configuration can be provided as dictionary. Added in version 2.4.0.</div>
<div style="font-size: small; color: darkgreen"><br/>aliases: kubeconfig_path</div> <div style="font-size: small; color: darkgreen"><br/>aliases: kubeconfig_path</div>
</td> </td>
</tr> </tr>

View File

@@ -126,7 +126,7 @@ Parameters
<b>kubeconfig</b> <b>kubeconfig</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small"> <div style="font-size: small">
<span style="color: purple">raw</span> <span style="color: purple">path</span>
</div> </div>
</td> </td>
<td> <td>
@@ -134,7 +134,6 @@ Parameters
<td> <td>
<div>Helm option to specify kubeconfig path to use.</div> <div>Helm option to specify kubeconfig path to use.</div>
<div>If the value is not specified in the task, the value of environment variable <code>K8S_AUTH_KUBECONFIG</code> will be used instead.</div> <div>If the value is not specified in the task, the value of environment variable <code>K8S_AUTH_KUBECONFIG</code> will be used instead.</div>
<div>The configuration can be provided as dictionary. Added in version 2.4.0.</div>
<div style="font-size: small; color: darkgreen"><br/>aliases: kubeconfig_path</div> <div style="font-size: small; color: darkgreen"><br/>aliases: kubeconfig_path</div>
</td> </td>
</tr> </tr>
@@ -151,7 +150,7 @@ Parameters
</td> </td>
<td> <td>
<div>Name of Helm plugin.</div> <div>Name of Helm plugin.</div>
<div>Required only if <code>state=absent</code> or <code>state=latest</code>.</div> <div>Required only if <code>state=absent</code>.</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -171,23 +170,6 @@ Parameters
<div>Required only if <code>state=present</code>.</div> <div>Required only if <code>state=present</code>.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>plugin_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>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
</td>
<td>
</td>
<td>
<div>Plugin version to install. If this is not specified, the latest version is installed.</div>
<div>Ignored when <code>state=absent</code> or <code>state=latest</code>.</div>
</td>
</tr>
<tr> <tr>
<td colspan="1"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -201,12 +183,10 @@ Parameters
<ul style="margin: 0; padding: 0"><b>Choices:</b> <ul style="margin: 0; padding: 0"><b>Choices:</b>
<li>absent</li> <li>absent</li>
<li><div style="color: blue"><b>present</b>&nbsp;&larr;</div></li> <li><div style="color: blue"><b>present</b>&nbsp;&larr;</div></li>
<li>latest</li>
</ul> </ul>
</td> </td>
<td> <td>
<div>If <code>state=present</code> the Helm plugin will be installed.</div> <div>If <code>state=present</code> the Helm plugin will be installed.</div>
<div>If <code>state=latest</code> the Helm plugin will be updated. Added in version 2.3.0.</div>
<div>If <code>state=absent</code> the Helm plugin will be removed.</div> <div>If <code>state=absent</code> the Helm plugin will be removed.</div>
</td> </td>
</tr> </tr>
@@ -257,17 +237,6 @@ Examples
plugin_name: env plugin_name: env
state: absent state: absent
- name: Install Helm plugin with a specific version
kubernetes.core.helm_plugin:
plugin_version: 2.0.1
plugin_path: https://domain/path/to/plugin.tar.gz
state: present
- name: Update Helm plugin
kubernetes.core.helm_plugin:
plugin_name: secrets
state: latest
Return Values Return Values

View File

@@ -40,22 +40,6 @@ Parameters
<th>Choices/<font color="blue">Defaults</font></th> <th>Choices/<font color="blue">Defaults</font></th>
<th width="100%">Comments</th> <th width="100%">Comments</th>
</tr> </tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>api_key</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
</td>
<td>
</td>
<td>
<div>Token used to authenticate with the API. Can also be specified via <code>K8S_AUTH_API_KEY</code> environment variable.</div>
</td>
</tr>
<tr> <tr>
<td colspan="1"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -71,117 +55,6 @@ Parameters
<div>The path of a helm binary to use.</div> <div>The path of a helm binary to use.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>ca_cert</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">path</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
</td>
<td>
</td>
<td>
<div>Path to a CA certificate used to authenticate with the API. The full certificate chain must be provided to avoid certificate validation errors. Can also be specified via <code>K8S_AUTH_SSL_CA_CERT</code> environment variable.</div>
<div style="font-size: small; color: darkgreen"><br/>aliases: ssl_ca_cert</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>context</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
</td>
<td>
</td>
<td>
<div>Helm option to specify which kubeconfig context to use.</div>
<div>If the value is not specified in the task, the value of environment variable <code>K8S_AUTH_CONTEXT</code> will be used instead.</div>
<div style="font-size: small; color: darkgreen"><br/>aliases: kube_context</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>force_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>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li><div style="color: blue"><b>no</b>&nbsp;&larr;</div></li>
<li>yes</li>
</ul>
</td>
<td>
<div>Whether or not to replace (overwrite) the repo if it already exists.</div>
<div style="font-size: small; color: darkgreen"><br/>aliases: force</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>host</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
</td>
<td>
</td>
<td>
<div>Provide a URL for accessing the API. Can also be specified via <code>K8S_AUTH_HOST</code> environment variable.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>kubeconfig</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">raw</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
</td>
<td>
</td>
<td>
<div>Helm option to specify kubeconfig path to use.</div>
<div>If the value is not specified in the task, the value of environment variable <code>K8S_AUTH_KUBECONFIG</code> will be used instead.</div>
<div>The configuration can be provided as dictionary.</div>
<div style="font-size: small; color: darkgreen"><br/>aliases: kubeconfig_path</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>pass_credentials</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li><div style="color: blue"><b>no</b>&nbsp;&larr;</div></li>
<li>yes</li>
</ul>
</td>
<td>
<div>Pass credentials to all domains.</div>
</td>
</tr>
<tr> <tr>
<td colspan="1"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -269,27 +142,6 @@ Parameters
<div style="font-size: small; color: darkgreen"><br/>aliases: username</div> <div style="font-size: small; color: darkgreen"><br/>aliases: username</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>validate_certs</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li>no</li>
<li><div style="color: blue"><b>yes</b>&nbsp;&larr;</div></li>
</ul>
</td>
<td>
<div>Whether or not to verify the API server&#x27;s SSL certificates. Can also be specified via <code>K8S_AUTH_VERIFY_SSL</code> environment variable.</div>
<div style="font-size: small; color: darkgreen"><br/>aliases: verify_ssl</div>
</td>
</tr>
</table> </table>
<br/> <br/>

View File

@@ -28,12 +28,12 @@ Parameters
<table border=0 cellpadding=0 class="documentation-table"> <table border=0 cellpadding=0 class="documentation-table">
<tr> <tr>
<th colspan="2">Parameter</th> <th colspan="1">Parameter</th>
<th>Choices/<font color="blue">Defaults</font></th> <th>Choices/<font color="blue">Defaults</font></th>
<th width="100%">Comments</th> <th width="100%">Comments</th>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>binary_path</b> <b>binary_path</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -48,7 +48,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>chart_ref</b> <b>chart_ref</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -67,7 +67,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>chart_repo_url</b> <b>chart_repo_url</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -82,7 +82,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>chart_version</b> <b>chart_version</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -97,14 +97,13 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>dependency_update</b> <b>dependency_update</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small"> <div style="font-size: small">
<span style="color: purple">boolean</span> <span style="color: purple">boolean</span>
</div> </div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
</td> </td>
<td> <td>
<ul style="margin: 0; padding: 0"><b>Choices:</b> <ul style="margin: 0; padding: 0"><b>Choices:</b>
@@ -120,27 +119,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>disable_hook</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li><div style="color: blue"><b>no</b>&nbsp;&larr;</div></li>
<li>yes</li>
</ul>
</td>
<td>
<div>Prevent hooks from running during install.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>include_crds</b> <b>include_crds</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -159,7 +138,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>output_dir</b> <b>output_dir</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -175,40 +154,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>release_name</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
</td>
<td>
</td>
<td>
<div>Release name to use in rendered templates.</div>
<div style="font-size: small; color: darkgreen"><br/>aliases: name</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>release_namespace</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
</td>
<td>
</td>
<td>
<div>namespace scope for this request.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>release_values</b> <b>release_values</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -225,85 +171,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>set_values</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=dictionary</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
</td>
<td>
</td>
<td>
<div>Values to pass to chart configuration.</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td colspan="1"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>value</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
/ <span style="color: red">required</span>
</div>
</td>
<td>
</td>
<td>
<div>Value to pass to chart configuration (e.g phase=prod).</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>value_type</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">-</span>
</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li><div style="color: blue"><b>raw</b>&nbsp;&larr;</div></li>
<li>string</li>
<li>json</li>
<li>file</li>
</ul>
</td>
<td>
<div>Use <code>raw</code> set individual value.</div>
<div>Use <code>string</code> to force a string for an individual value.</div>
<div>Use <code>file</code> to set individual values from a file when the value itself is too long for the command line or is dynamically generated.</div>
<div>Use <code>json</code> to set json values (scalars/objects/arrays). This feature requires helm&gt;=3.10.0.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>show_only</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>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
</td>
<td>
<b>Default:</b><br/><div style="color: blue">[]</div>
</td>
<td>
<div>Only show manifests rendered from the given templates.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>update_repo_cache</b> <b>update_repo_cache</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -322,7 +190,7 @@ Parameters
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
<b>values_files</b> <b>values_files</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a> <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -367,24 +235,6 @@ Examples
dest: myfile.yaml dest: myfile.yaml
content: "{{ result.stdout }}" content: "{{ result.stdout }}"
- name: Render MutatingWebhooksConfiguration for revision tag "canary", rev "1-13-0"
kubernetes.core.helm_template:
chart_ref: istio/istiod
chart_version: "1.13.0"
release_namespace: "istio-system"
show_only:
- "templates/revision-tags.yaml"
release_values:
revision: "1-13-0"
revisionTags:
- "canary"
register: result
- name: Write templates to file
copy:
dest: myfile.yaml
content: "{{ result.stdout }}"
Return Values Return Values

View File

@@ -27,8 +27,8 @@ Requirements
------------ ------------
The below requirements are needed on the host that executes this module. The below requirements are needed on the host that executes this module.
- python >= 3.9 - python >= 3.6
- kubernetes >= 24.2.0 - kubernetes >= 12.0.0
- PyYAML >= 3.11 - PyYAML >= 3.11
@@ -203,29 +203,9 @@ Parameters
</td> </td>
<td> <td>
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div> <div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
<div>Multiple Kubernetes config file can be provided using separator &#x27;;&#x27; for Windows platform or &#x27;:&#x27; for others platforms.</div>
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0. Added in version 2.2.0.</div> <div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0. Added in version 2.2.0.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>no_proxy</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
</td>
<td>
</td>
<td>
<div>The comma separated list of hosts/domains/IP/CIDR that shouldn&#x27;t go through proxy. Can also be specified via K8S_AUTH_NO_PROXY environment variable.</div>
<div>Please note that this module does not pick up typical proxy settings from the environment (e.g. NO_PROXY).</div>
<div>This feature requires kubernetes&gt;=19.15.0. When kubernetes library is less than 19.15.0, it fails even no_proxy set in correct.</div>
<div>example value is &quot;localhost,.local,.example.com,127.0.0.1,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16&quot;</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>

View File

@@ -25,8 +25,8 @@ Requirements
------------ ------------
The below requirements are needed on the host that executes this module. The below requirements are needed on the host that executes this module.
- python >= 3.9 - python >= 3.6
- kubernetes >= 24.2.0 - kubernetes >= 12.0.0
Parameters Parameters
@@ -215,7 +215,6 @@ Parameters
</td> </td>
<td> <td>
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div> <div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
<div>Multiple Kubernetes config file can be provided using separator &#x27;;&#x27; for Windows platform or &#x27;:&#x27; for others platforms.</div>
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0. Added in version 2.2.0.</div> <div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0. Added in version 2.2.0.</div>
</td> </td>
</tr> </tr>
@@ -272,25 +271,6 @@ Parameters
<div>This option is ignored when <em>content</em> is set or when <em>state</em> is set to <code>from_pod</code>.</div> <div>This option is ignored when <em>content</em> is set or when <em>state</em> is set to <code>from_pod</code>.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>no_proxy</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
</td>
<td>
</td>
<td>
<div>The comma separated list of hosts/domains/IP/CIDR that shouldn&#x27;t go through proxy. Can also be specified via K8S_AUTH_NO_PROXY environment variable.</div>
<div>Please note that this module does not pick up typical proxy settings from the environment (e.g. NO_PROXY).</div>
<div>This feature requires kubernetes&gt;=19.15.0. When kubernetes library is less than 19.15.0, it fails even no_proxy set in correct.</div>
<div>example value is &quot;localhost,.local,.example.com,127.0.0.1,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16&quot;</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -558,7 +538,7 @@ Examples
state: from_pod state: from_pod
# copy content into a file in the remote pod # copy content into a file in the remote pod
- name: Copy content into a file in the remote pod - name: Copy /tmp/foo from a remote pod to /tmp/bar locally
kubernetes.core.k8s_cp: kubernetes.core.k8s_cp:
state: to_pod state: to_pod
namespace: some-namespace namespace: some-namespace

View File

@@ -29,8 +29,8 @@ Requirements
------------ ------------
The below requirements are needed on the host that executes this module. The below requirements are needed on the host that executes this module.
- python >= 3.9 - python >= 3.6
- kubernetes >= 24.2.0 - kubernetes >= 12.0.0
Parameters Parameters
@@ -132,7 +132,6 @@ Parameters
</div> </div>
</td> </td>
<td> <td>
<b>Default:</b><br/><div style="color: blue">{}</div>
</td> </td>
<td> <td>
<div>Specify options to delete pods.</div> <div>Specify options to delete pods.</div>
@@ -148,7 +147,6 @@ Parameters
<div style="font-size: small"> <div style="font-size: small">
<span style="color: purple">boolean</span> <span style="color: purple">boolean</span>
</div> </div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
</td> </td>
<td> <td>
<ul style="margin: 0; padding: 0"><b>Choices:</b> <ul style="margin: 0; padding: 0"><b>Choices:</b>
@@ -157,7 +155,7 @@ Parameters
</ul> </ul>
</td> </td>
<td> <td>
<div>Continue even if there are pods using emptyDir (local data that will be deleted when the node is drained).</div> <div>Continue even if there are pods using emptyDir (local data that will be deleted when the node is drained)</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -336,7 +334,6 @@ Parameters
</td> </td>
<td> <td>
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div> <div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
<div>Multiple Kubernetes config file can be provided using separator &#x27;;&#x27; for Windows platform or &#x27;:&#x27; for others platforms.</div>
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0. Added in version 2.2.0.</div> <div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0. Added in version 2.2.0.</div>
</td> </td>
</tr> </tr>
@@ -356,25 +353,6 @@ Parameters
<div>The name of the node.</div> <div>The name of the node.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>no_proxy</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
</td>
<td>
</td>
<td>
<div>The comma separated list of hosts/domains/IP/CIDR that shouldn&#x27;t go through proxy. Can also be specified via K8S_AUTH_NO_PROXY environment variable.</div>
<div>Please note that this module does not pick up typical proxy settings from the environment (e.g. NO_PROXY).</div>
<div>This feature requires kubernetes&gt;=19.15.0. When kubernetes library is less than 19.15.0, it fails even no_proxy set in correct.</div>
<div>example value is &quot;localhost,.local,.example.com,127.0.0.1,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16&quot;</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -414,25 +392,6 @@ Parameters
<div>The fix for this k8s python library is here: https://github.com/kubernetes-client/python-base/pull/169</div> <div>The fix for this k8s python library is here: https://github.com/kubernetes-client/python-base/pull/169</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>pod_selectors</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>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.5.0</div>
</td>
<td>
</td>
<td>
<div>Label selector to filter pods on the node.</div>
<div>This option has effect only when <code>state</code> is set to <em>drain</em>.</div>
<div style="font-size: small; color: darkgreen"><br/>aliases: label_selectors</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -602,7 +561,7 @@ Examples
state: drain state: drain
name: foo name: foo
delete_options: delete_options:
terminate_grace_period: 900 terminate_grace_period: 900
- name: Mark node "foo" as schedulable. - name: Mark node "foo" as schedulable.
kubernetes.core.k8s_drain: kubernetes.core.k8s_drain:
@@ -614,14 +573,6 @@ Examples
state: cordon state: cordon
name: foo name: foo
- name: Drain node "foo" using label selector to filter the list of pods to be drained.
kubernetes.core.k8s_drain:
state: drain
name: foo
pod_selectors:
- 'app!=csi-attacher'
- 'app!=csi-provisioner'
Return Values Return Values

View File

@@ -25,8 +25,8 @@ Requirements
------------ ------------
The below requirements are needed on the host that executes this module. The below requirements are needed on the host that executes this module.
- python >= 3.9 - python >= 3.6
- kubernetes >= 24.2.0 - kubernetes >= 12.0.0
- PyYAML >= 3.11 - PyYAML >= 3.11
@@ -117,7 +117,7 @@ Parameters
<td> <td>
</td> </td>
<td> <td>
<div>The command to execute.</div> <div>The command to execute</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -134,7 +134,6 @@ Parameters
<td> <td>
<div>The name of the container in the pod to connect to.</div> <div>The name of the container in the pod to connect to.</div>
<div>Defaults to only container if there is only one container in the pod.</div> <div>Defaults to only container if there is only one container in the pod.</div>
<div>If not specified, will choose the first container from the given pod as kubectl cmdline does.</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -215,7 +214,6 @@ Parameters
</td> </td>
<td> <td>
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div> <div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
<div>Multiple Kubernetes config file can be provided using separator &#x27;;&#x27; for Windows platform or &#x27;:&#x27; for others platforms.</div>
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0. Added in version 2.2.0.</div> <div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0. Added in version 2.2.0.</div>
</td> </td>
</tr> </tr>
@@ -232,26 +230,7 @@ Parameters
<td> <td>
</td> </td>
<td> <td>
<div>The pod namespace name.</div> <div>The pod namespace name</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>no_proxy</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
</td>
<td>
</td>
<td>
<div>The comma separated list of hosts/domains/IP/CIDR that shouldn&#x27;t go through proxy. Can also be specified via K8S_AUTH_NO_PROXY environment variable.</div>
<div>Please note that this module does not pick up typical proxy settings from the environment (e.g. NO_PROXY).</div>
<div>This feature requires kubernetes&gt;=19.15.0. When kubernetes library is less than 19.15.0, it fails even no_proxy set in correct.</div>
<div>example value is &quot;localhost,.local,.example.com,127.0.0.1,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16&quot;</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -306,7 +285,7 @@ Parameters
<td> <td>
</td> </td>
<td> <td>
<div>The pod name.</div> <div>The pod name</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -323,7 +302,7 @@ Parameters
<td> <td>
<div>The URL of an HTTP proxy to use for the connection.</div> <div>The URL of an HTTP proxy to use for the connection.</div>
<div>Can also be specified via <em>K8S_AUTH_PROXY</em> environment variable.</div> <div>Can also be specified via <em>K8S_AUTH_PROXY</em> environment variable.</div>
<div>Please note that this module does not pick up typical proxy settings from the environment (for example, HTTP_PROXY).</div> <div>Please note that this module does not pick up typical proxy settings from the environment (e.g. HTTP_PROXY).</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -470,13 +449,6 @@ Examples
msg: "cmd failed" msg: "cmd failed"
when: command_status.rc != 0 when: command_status.rc != 0
- name: Specify a container name to execute the command on
kubernetes.core.k8s_exec:
namespace: myproject
pod: busybox-test
container: manager
command: echo "hello"
Return Values Return Values

View File

@@ -28,8 +28,8 @@ Requirements
------------ ------------
The below requirements are needed on the host that executes this module. The below requirements are needed on the host that executes this module.
- python >= 3.9 - python >= 3.6
- kubernetes >= 24.2.0 - kubernetes >= 12.0.0
- PyYAML >= 3.11 - PyYAML >= 3.11
@@ -153,31 +153,11 @@ Parameters
</div> </div>
</td> </td>
<td> <td>
<b>Default:</b><br/><div style="color: blue">[]</div>
</td> </td>
<td> <td>
<div>List of field selectors to use to filter results</div> <div>List of field selectors to use to filter results</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>hidden_fields</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>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.5.0</div>
</td>
<td>
</td>
<td>
<div>Hide fields matching any of the field definitions in the result</div>
<div>An example might be <code>hidden_fields=[metadata.managedFields]</code></div>
<div>Only field definitions that don&#x27;t reference list items are supported (so V(spec.containers[0]) would not work)</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -260,7 +240,6 @@ Parameters
</td> </td>
<td> <td>
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div> <div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
<div>Multiple Kubernetes config file can be provided using separator &#x27;;&#x27; for Windows platform or &#x27;:&#x27; for others platforms.</div>
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0. Added in version 2.2.0.</div> <div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0. Added in version 2.2.0.</div>
</td> </td>
</tr> </tr>
@@ -275,7 +254,6 @@ Parameters
</div> </div>
</td> </td>
<td> <td>
<b>Default:</b><br/><div style="color: blue">[]</div>
</td> </td>
<td> <td>
<div>List of label selectors to use to filter results</div> <div>List of label selectors to use to filter results</div>
@@ -317,25 +295,6 @@ Parameters
<div>If <em>resource definition</em> is provided, the <em>metadata.namespace</em> value from the <em>resource_definition</em> will override this option.</div> <div>If <em>resource definition</em> is provided, the <em>metadata.namespace</em> value from the <em>resource_definition</em> will override this option.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>no_proxy</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
</td>
<td>
</td>
<td>
<div>The comma separated list of hosts/domains/IP/CIDR that shouldn&#x27;t go through proxy. Can also be specified via K8S_AUTH_NO_PROXY environment variable.</div>
<div>Please note that this module does not pick up typical proxy settings from the environment (e.g. NO_PROXY).</div>
<div>This feature requires kubernetes&gt;=19.15.0. When kubernetes library is less than 19.15.0, it fails even no_proxy set in correct.</div>
<div>example value is &quot;localhost,.local,.example.com,127.0.0.1,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16&quot;</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>

View File

@@ -13,15 +13,6 @@ kubernetes.core.k8s
:local: :local:
:depth: 1 :depth: 1
DEPRECATED
----------
:Removed in collection release after
:Why: As discussed in https://github.com/ansible-collections/kubernetes.core/issues/31, we decided to
remove the k8s inventory plugin in release 4.0.0.
:Alternative: Use :ref:`kubernetes.core.k8s_info <kubernetes.core.k8s_info_module>` and :ref:`ansible.builtin.add_host <ansible.builtin.add_host_module>` instead.
Synopsis Synopsis
-------- --------
@@ -36,8 +27,8 @@ Requirements
------------ ------------
The below requirements are needed on the local Ansible controller node that executes this inventory. The below requirements are needed on the local Ansible controller node that executes this inventory.
- python >= 3.9 - python >= 3.6
- kubernetes >= 24.2.0 - kubernetes >= 12.0.0
- PyYAML >= 3.11 - PyYAML >= 3.11
@@ -331,24 +322,24 @@ Examples
# File must be named k8s.yaml or k8s.yml # File must be named k8s.yaml or k8s.yml
- name: Authenticate with token, and return all pods and services for all namespaces # Authenticate with token, and return all pods and services for all namespaces
plugin: kubernetes.core.k8s plugin: kubernetes.core.k8s
connections: connections:
- host: https://192.168.64.4:8443 - host: https://192.168.64.4:8443
api_key: xxxxxxxxxxxxxxxx api_key: xxxxxxxxxxxxxxxx
validate_certs: false validate_certs: false
- name: Use default config (~/.kube/config) file and active context, and return objects for a specific namespace # Use default config (~/.kube/config) file and active context, and return objects for a specific namespace
plugin: kubernetes.core.k8s plugin: kubernetes.core.k8s
connections: connections:
- namespaces: - namespaces:
- testing - testing
- name: Use a custom config file, and a specific context. # Use a custom config file, and a specific context.
plugin: kubernetes.core.k8s plugin: kubernetes.core.k8s
connections: connections:
- kubeconfig: /path/to/config - kubeconfig: /path/to/config
context: 'awx/192-168-64-4:8443/developer' context: 'awx/192-168-64-4:8443/developer'
@@ -357,15 +348,11 @@ Status
------ ------
- This inventory will be removed in version 4.0.0. *[deprecated]*
- For more information see `DEPRECATED`_.
Authors Authors
~~~~~~~ ~~~~~~~
- Chris Houseknecht (@chouseknecht) - Chris Houseknecht <@chouseknecht>
- Fabian von Feilitzsch (@fabianvf) - Fabian von Feilitzsch <@fabianvf>
.. hint:: .. hint::

View File

@@ -27,8 +27,8 @@ Requirements
------------ ------------
The below requirements are needed on the host that executes this module. The below requirements are needed on the host that executes this module.
- python >= 3.9 - python >= 3.6
- kubernetes >= 24.2.0 - kubernetes >= 12.0.0
- PyYAML >= 3.11 - PyYAML >= 3.11
- jsonpatch - jsonpatch
@@ -220,7 +220,6 @@ Parameters
</td> </td>
<td> <td>
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div> <div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
<div>Multiple Kubernetes config file can be provided using separator &#x27;;&#x27; for Windows platform or &#x27;:&#x27; for others platforms.</div>
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0. Added in version 2.2.0.</div> <div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0. Added in version 2.2.0.</div>
</td> </td>
</tr> </tr>
@@ -257,25 +256,6 @@ Parameters
<div>Use in conjunction with <em>api_version</em>, <em>kind</em>, and <em>name</em> to identify a specific object.</div> <div>Use in conjunction with <em>api_version</em>, <em>kind</em>, and <em>name</em> to identify a specific object.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>no_proxy</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
</td>
<td>
</td>
<td>
<div>The comma separated list of hosts/domains/IP/CIDR that shouldn&#x27;t go through proxy. Can also be specified via K8S_AUTH_NO_PROXY environment variable.</div>
<div>Please note that this module does not pick up typical proxy settings from the environment (e.g. NO_PROXY).</div>
<div>This feature requires kubernetes&gt;=19.15.0. When kubernetes library is less than 19.15.0, it fails even no_proxy set in correct.</div>
<div>example value is &quot;localhost,.local,.example.com,127.0.0.1,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16&quot;</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -614,7 +594,7 @@ Examples
path: /metadata/labels/app path: /metadata/labels/app
value: myapp value: myapp
- op: replace - op: replace
path: /spec/containers/0/image patch: /spec/containers/0/image
value: nginx value: nginx

View File

@@ -28,8 +28,8 @@ Requirements
------------ ------------
The below requirements are needed on the host that executes this module. The below requirements are needed on the host that executes this module.
- python >= 3.9 - python >= 3.6
- kubernetes >= 24.2.0 - kubernetes >= 12.0.0
- PyYAML >= 3.11 - PyYAML >= 3.11
@@ -44,27 +44,6 @@ Parameters
<th>Choices/<font color="blue">Defaults</font></th> <th>Choices/<font color="blue">Defaults</font></th>
<th width="100%">Comments</th> <th width="100%">Comments</th>
</tr> </tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>all_containers</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li>no</li>
<li>yes</li>
</ul>
</td>
<td>
<div>If set to <code>true</code>, retrieve all containers&#x27; logs in the pod(s).</div>
<div>mutually exclusive with <code>container</code>.</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -162,8 +141,7 @@ Parameters
<td> <td>
<div>Use to specify the container within a pod to grab the log from.</div> <div>Use to specify the container within a pod to grab the log from.</div>
<div>If there is only one container, this will default to that container.</div> <div>If there is only one container, this will default to that container.</div>
<div>If there is more than one container, this option is required or set <em>all_containers</em> to <code>true</code>.</div> <div>If there is more than one container, this option is required.</div>
<div>mutually exclusive with <code>all_containers</code>.</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -262,7 +240,6 @@ Parameters
</td> </td>
<td> <td>
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div> <div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
<div>Multiple Kubernetes config file can be provided using separator &#x27;;&#x27; for Windows platform or &#x27;:&#x27; for others platforms.</div>
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0. Added in version 2.2.0.</div> <div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0. Added in version 2.2.0.</div>
</td> </td>
</tr> </tr>
@@ -277,7 +254,6 @@ Parameters
</div> </div>
</td> </td>
<td> <td>
<b>Default:</b><br/><div style="color: blue">[]</div>
</td> </td>
<td> <td>
<div>List of label selectors to use to filter results</div> <div>List of label selectors to use to filter results</div>
@@ -319,25 +295,6 @@ Parameters
<div>If <em>resource definition</em> is provided, the <em>metadata.namespace</em> value from the <em>resource_definition</em> will override this option.</div> <div>If <em>resource definition</em> is provided, the <em>metadata.namespace</em> value from the <em>resource_definition</em> will override this option.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>no_proxy</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
</td>
<td>
</td>
<td>
<div>The comma separated list of hosts/domains/IP/CIDR that shouldn&#x27;t go through proxy. Can also be specified via K8S_AUTH_NO_PROXY environment variable.</div>
<div>Please note that this module does not pick up typical proxy settings from the environment (e.g. NO_PROXY).</div>
<div>This feature requires kubernetes&gt;=19.15.0. When kubernetes library is less than 19.15.0, it fails even no_proxy set in correct.</div>
<div>example value is &quot;localhost,.local,.example.com,127.0.0.1,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16&quot;</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -377,26 +334,6 @@ Parameters
<div>The fix for this k8s python library is here: https://github.com/kubernetes-client/python-base/pull/169</div> <div>The fix for this k8s python library is here: https://github.com/kubernetes-client/python-base/pull/169</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>previous</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li><div style="color: blue"><b>no</b>&nbsp;&larr;</div></li>
<li>yes</li>
</ul>
</td>
<td>
<div>If <code>true</code>, print the logs for the previous instance of the container in a pod if it exists.</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -498,22 +435,6 @@ Parameters
<div>A relative time in seconds before the current time from which to show logs.</div> <div>A relative time in seconds before the current time from which to show logs.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>tail_lines</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">integer</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
</td>
<td>
</td>
<td>
<div>A number of lines from the end of the logs to retrieve.</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -598,16 +519,8 @@ Examples
kind: DeploymentConfig kind: DeploymentConfig
namespace: testing namespace: testing
name: example name: example
tail_lines: 100
register: log register: log
# This will get the logs from all containers in Pod
- name: Get the logs from all containers in pod
kubernetes.core.k8s_log:
namespace: testing
name: some-pod
all_containers: true
Return Values Return Values

View File

@@ -26,8 +26,8 @@ Requirements
------------ ------------
The below requirements are needed on the local Ansible controller node that executes this lookup. The below requirements are needed on the local Ansible controller node that executes this lookup.
- python >= 3.9 - python >= 3.6
- kubernetes >= 24.2.0 - kubernetes >= 12.0.0
- PyYAML >= 3.11 - PyYAML >= 3.11
@@ -438,28 +438,106 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
<table border=0 cellpadding=0 class="documentation-table"> <table border=0 cellpadding=0 class="documentation-table">
<tr> <tr>
<th colspan="1">Key</th> <th colspan="2">Key</th>
<th>Returned</th> <th>Returned</th>
<th width="100%">Description</th> <th width="100%">Description</th>
</tr> </tr>
<tr> <tr>
<td colspan="1"> <td colspan="2">
<div class="ansibleOptionAnchor" id="return-"></div> <div class="ansibleOptionAnchor" id="return-"></div>
<b>_list</b> <b>_list</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small"> <div style="font-size: small">
<span style="color: purple">list</span> <span style="color: purple">complex</span>
/ <span style="color: purple">elements=dictionary</span>
</div> </div>
</td> </td>
<td></td> <td></td>
<td> <td>
<div>One ore more object definitions returned from the API.</div> <div>One ore more object definitions returned from the API.</div>
<br/> <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;">[{&#x27;kind&#x27;: &#x27;ConfigMap&#x27;, &#x27;apiVersion&#x27;: &#x27;v1&#x27;, &#x27;metadata&#x27;: {&#x27;creationTimestamp&#x27;: &#x27;2022-03-04T13:59:49Z&#x27;, &#x27;name&#x27;: &#x27;my-config-map&#x27;, &#x27;namespace&#x27;: &#x27;default&#x27;, &#x27;resourceVersion&#x27;: &#x27;418&#x27;, &#x27;uid&#x27;: &#x27;5714b011-d090-4eac-8272-a0ea82ec0abd&#x27;}, &#x27;data&#x27;: {&#x27;key1&#x27;: &#x27;val1&#x27;}}]</div>
</td> </td>
</tr> </tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>api_version</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>success</td>
<td>
<div>The versioned schema of this representation of an object.</div>
<br/>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>kind</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>success</td>
<td>
<div>Represents the REST resource this object represents.</div>
<br/>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>metadata</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">complex</span>
</div>
</td>
<td>success</td>
<td>
<div>Standard object metadata. Includes name, namespace, annotations, labels, etc.</div>
<br/>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>spec</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">complex</span>
</div>
</td>
<td>success</td>
<td>
<div>Specific attributes of the object. Will vary based on the <em>api_version</em> and <em>kind</em>.</div>
<br/>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>status</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">complex</span>
</div>
</td>
<td>success</td>
<td>
<div>Current status details for the object.</div>
<br/>
</td>
</tr>
</table> </table>
<br/><br/> <br/><br/>
@@ -471,8 +549,8 @@ Status
Authors Authors
~~~~~~~ ~~~~~~~
- Chris Houseknecht (@chouseknecht) - Chris Houseknecht <@chouseknecht>
- Fabian von Feilitzsch (@fabianvf) - Fabian von Feilitzsch <@fabianvf>
.. hint:: .. hint::

View File

@@ -29,8 +29,8 @@ Requirements
------------ ------------
The below requirements are needed on the host that executes this module. The below requirements are needed on the host that executes this module.
- python >= 3.9 - python >= 3.6
- kubernetes >= 24.2.0 - kubernetes >= 12.0.0
- PyYAML >= 3.11 - PyYAML >= 3.11
- jsonpatch - jsonpatch
@@ -208,30 +208,6 @@ Parameters
<div>This has no effect on the validation step which is controlled by the <code>validate.fail_on_error</code> parameter.</div> <div>This has no effect on the validation step which is controlled by the <code>validate.fail_on_error</code> parameter.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="3">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>delete_all</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.5.0</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li><div style="color: blue"><b>no</b>&nbsp;&larr;</div></li>
<li>yes</li>
</ul>
</td>
<td>
<div>When this option is set to <em>true</em> and <em>state=absent</em>, module will delete all resources of the specified resource type in the requested namespace.</div>
<div>Ignored when <code>state</code> is not set to <em>absent</em> or when one of (src), <code>name</code> or <code>resource_definition</code> is provided.</div>
<div>Parameter <code>kind</code> is required to use this option.</div>
<div>This parameter can be used with <code>label_selectors</code> to restrict the resources to be deleted.</div>
<div style="font-size: small; color: darkgreen"><br/>aliases: all</div>
</td>
</tr>
<tr> <tr>
<td colspan="3"> <td colspan="3">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -360,45 +336,6 @@ Parameters
<div>If set to <code>yes</code>, and <em>state</em> is <code>present</code>, an existing object will be replaced.</div> <div>If set to <code>yes</code>, and <em>state</em> is <code>present</code>, an existing object will be replaced.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="3">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>generate_name</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
</td>
<td>
</td>
<td>
<div>Use to specify the basis of an object name and random characters will be added automatically on server to generate a unique name.</div>
<div>This option is ignored when <em>state</em> is not set to <code>present</code> or when <em>apply</em> is set to <code>yes</code>.</div>
<div>If <em>resource definition</em> is provided, the <em>metadata.generateName</em> value from the <em>resource_definition</em> will override this option.</div>
<div>If <em>resource definition</em> is provided, and contains <em>metadata.name</em>, this option is ignored.</div>
<div>mutually exclusive with <code>name</code>.</div>
</td>
</tr>
<tr>
<td colspan="3">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>hidden_fields</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>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.5.0</div>
</td>
<td>
</td>
<td>
<div>Hide fields matching this option in the result</div>
<div>An example might be <code>hidden_fields=[metadata.managedFields]</code></div>
<div>Only field definitions that don&#x27;t reference list items are supported (so V(spec.containers[0]) would not work)</div>
</td>
</tr>
<tr> <tr>
<td colspan="3"> <td colspan="3">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -480,7 +417,6 @@ Parameters
</td> </td>
<td> <td>
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div> <div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
<div>Multiple Kubernetes config file can be provided using separator &#x27;;&#x27; for Windows platform or &#x27;:&#x27; for others platforms.</div>
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0. Added in version 2.2.0.</div> <div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0. Added in version 2.2.0.</div>
</td> </td>
</tr> </tr>
@@ -563,25 +499,6 @@ Parameters
<div>If <em>resource definition</em> is provided, the <em>metadata.namespace</em> value from the <em>resource_definition</em> will override this option.</div> <div>If <em>resource definition</em> is provided, the <em>metadata.namespace</em> value from the <em>resource_definition</em> will override this option.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="3">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>no_proxy</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
</td>
<td>
</td>
<td>
<div>The comma separated list of hosts/domains/IP/CIDR that shouldn&#x27;t go through proxy. Can also be specified via K8S_AUTH_NO_PROXY environment variable.</div>
<div>Please note that this module does not pick up typical proxy settings from the environment (e.g. NO_PROXY).</div>
<div>This feature requires kubernetes&gt;=19.15.0. When kubernetes library is less than 19.15.0, it fails even no_proxy set in correct.</div>
<div>example value is &quot;localhost,.local,.example.com,127.0.0.1,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16&quot;</div>
</td>
</tr>
<tr> <tr>
<td colspan="3"> <td colspan="3">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -723,63 +640,6 @@ Parameters
<div style="font-size: small; color: darkgreen"><br/>aliases: definition, inline</div> <div style="font-size: small; color: darkgreen"><br/>aliases: definition, inline</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="3">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>server_side_apply</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">dictionary</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
</td>
<td>
</td>
<td>
<div>When this option is set, apply runs in the server instead of the client.</div>
<div>Ignored if <code>apply</code> is not set or is set to False.</div>
<div>This option requires &quot;kubernetes &gt;= 19.15.0&quot;.</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>field_manager</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
/ <span style="color: red">required</span>
</div>
</td>
<td>
</td>
<td>
<div>Name of the manager used to track field ownership.</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>force_conflicts</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>&nbsp;&larr;</div></li>
<li>yes</li>
</ul>
</td>
<td>
<div>A conflict is a special status error that occurs when an Server Side Apply operation tries to change a field, which another user also claims to manage.</div>
<div>When set to True, server-side apply will force the changes against conflicts.</div>
</td>
</tr>
<tr> <tr>
<td colspan="3"> <td colspan="3">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -794,8 +654,7 @@ Parameters
<td> <td>
<div>Provide a path to a file containing a valid YAML definition of an object or objects to be created or updated. Mutually exclusive with <em>resource_definition</em>. NOTE: <em>kind</em>, <em>api_version</em>, <em>name</em>, and <em>namespace</em> will be overwritten by corresponding values found in the configuration read in from the <em>src</em> file.</div> <div>Provide a path to a file containing a valid YAML definition of an object or objects to be created or updated. Mutually exclusive with <em>resource_definition</em>. NOTE: <em>kind</em>, <em>api_version</em>, <em>name</em>, and <em>namespace</em> will be overwritten by corresponding values found in the configuration read in from the <em>src</em> file.</div>
<div>Reads from the local file system. To read from the Ansible controller&#x27;s file system, including vaulted files, use the file lookup plugin or template lookup plugin, combined with the from_yaml filter, and pass the result to <em>resource_definition</em>. See Examples below.</div> <div>Reads from the local file system. To read from the Ansible controller&#x27;s file system, including vaulted files, use the file lookup plugin or template lookup plugin, combined with the from_yaml filter, and pass the result to <em>resource_definition</em>. See Examples below.</div>
<div>The URL to manifest files that can be used to create the resource. Added in version 2.4.0.</div> <div>Mutually exclusive with <em>template</em> in case of <span class='module'>k8s</span> module.</div>
<div>Mutually exclusive with <em>template</em> in case of <span class='module'>kubernetes.core.k8s</span> module.</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -1157,14 +1016,6 @@ Examples
state: present state: present
definition: "{{ lookup('file', '/testing/deployment.yml') | from_yaml }}" definition: "{{ lookup('file', '/testing/deployment.yml') | from_yaml }}"
- name: >-
(Alternative) Read definition file from the Ansible controller file system.
In this case, the definition file contains multiple YAML documents, separated by ---.
If the definition file has been encrypted with Ansible Vault it will automatically be decrypted.
kubernetes.core.k8s:
state: present
definition: "{{ lookup('file', '/testing/deployment.yml') | from_yaml_all }}"
- name: Read definition template file from the Ansible controller file system - name: Read definition template file from the Ansible controller file system
kubernetes.core.k8s: kubernetes.core.k8s:
state: present state: present
@@ -1182,10 +1033,10 @@ Examples
kubernetes.core.k8s: kubernetes.core.k8s:
state: present state: present
template: template:
- path: '/testing/deployment_one.j2' - path: '/testing/deployment_one.j2'
- path: '/testing/deployment_two.j2' - path: '/testing/deployment_two.j2'
variable_start_string: '[[' variable_start_string: '[['
variable_end_string: ']]' variable_end_string: ']]'
- name: fail on validation errors - name: fail on validation errors
kubernetes.core.k8s: kubernetes.core.k8s:
@@ -1242,41 +1093,6 @@ Examples
labels: labels:
support: patch support: patch
# Create object using generateName
- name: create resource using name generated by the server
kubernetes.core.k8s:
state: present
generate_name: pod-
definition:
apiVersion: v1
kind: Pod
spec:
containers:
- name: py
image: python:3.7-alpine
imagePullPolicy: IfNotPresent
# Server side apply
- name: Create configmap using server side apply
kubernetes.core.k8s:
namespace: testing
definition:
apiVersion: v1
kind: ConfigMap
metadata:
name: my-configmap
apply: yes
server_side_apply:
field_manager: ansible
# Delete all Deployment from specified namespace
- name: Delete all Deployment from specified namespace
kubernetes.core.k8s:
api_version: apps/v1
namespace: testing
kind: Deployment
delete_all: true
Return Values Return Values

View File

@@ -27,8 +27,8 @@ Requirements
------------ ------------
The below requirements are needed on the host that executes this module. The below requirements are needed on the host that executes this module.
- python >= 3.9 - python >= 3.6
- kubernetes >= 24.2.0 - kubernetes >= 12.0.0
- PyYAML >= 3.11 - PyYAML >= 3.11
@@ -152,7 +152,6 @@ Parameters
</div> </div>
</td> </td>
<td> <td>
<b>Default:</b><br/><div style="color: blue">[]</div>
</td> </td>
<td> <td>
<div>List of field selectors to use to filter results.</div> <div>List of field selectors to use to filter results.</div>
@@ -239,7 +238,6 @@ Parameters
</td> </td>
<td> <td>
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div> <div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
<div>Multiple Kubernetes config file can be provided using separator &#x27;;&#x27; for Windows platform or &#x27;:&#x27; for others platforms.</div>
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0. Added in version 2.2.0.</div> <div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0. Added in version 2.2.0.</div>
</td> </td>
</tr> </tr>
@@ -254,7 +252,6 @@ Parameters
</div> </div>
</td> </td>
<td> <td>
<b>Default:</b><br/><div style="color: blue">[]</div>
</td> </td>
<td> <td>
<div>List of label selectors to use to filter results.</div> <div>List of label selectors to use to filter results.</div>
@@ -296,25 +293,6 @@ Parameters
<div>If <em>resource definition</em> is provided, the <em>metadata.namespace</em> value from the <em>resource_definition</em> will override this option.</div> <div>If <em>resource definition</em> is provided, the <em>metadata.namespace</em> value from the <em>resource_definition</em> will override this option.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>no_proxy</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
</td>
<td>
</td>
<td>
<div>The comma separated list of hosts/domains/IP/CIDR that shouldn&#x27;t go through proxy. Can also be specified via K8S_AUTH_NO_PROXY environment variable.</div>
<div>Please note that this module does not pick up typical proxy settings from the environment (e.g. NO_PROXY).</div>
<div>This feature requires kubernetes&gt;=19.15.0. When kubernetes library is less than 19.15.0, it fails even no_proxy set in correct.</div>
<div>example value is &quot;localhost,.local,.example.com,127.0.0.1,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16&quot;</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>

View File

@@ -25,8 +25,8 @@ Requirements
------------ ------------
The below requirements are needed on the host that executes this module. The below requirements are needed on the host that executes this module.
- python >= 3.9 - python >= 3.6
- kubernetes >= 24.2.0 - kubernetes >= 12.0.0
- PyYAML >= 3.11 - PyYAML >= 3.11
@@ -255,7 +255,6 @@ Parameters
</td> </td>
<td> <td>
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div> <div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
<div>Multiple Kubernetes config file can be provided using separator &#x27;;&#x27; for Windows platform or &#x27;:&#x27; for others platforms.</div>
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0. Added in version 2.2.0.</div> <div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0. Added in version 2.2.0.</div>
</td> </td>
</tr> </tr>
@@ -271,7 +270,6 @@ Parameters
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.0.0</div> <div style="font-style: italic; font-size: small; color: darkgreen">added in 2.0.0</div>
</td> </td>
<td> <td>
<b>Default:</b><br/><div style="color: blue">[]</div>
</td> </td>
<td> <td>
<div>List of label selectors to use to filter results.</div> <div>List of label selectors to use to filter results.</div>
@@ -313,25 +311,6 @@ Parameters
<div>If <em>resource definition</em> is provided, the <em>metadata.namespace</em> value from the <em>resource_definition</em> will override this option.</div> <div>If <em>resource definition</em> is provided, the <em>metadata.namespace</em> value from the <em>resource_definition</em> will override this option.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>no_proxy</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
</td>
<td>
</td>
<td>
<div>The comma separated list of hosts/domains/IP/CIDR that shouldn&#x27;t go through proxy. Can also be specified via K8S_AUTH_NO_PROXY environment variable.</div>
<div>Please note that this module does not pick up typical proxy settings from the environment (e.g. NO_PROXY).</div>
<div>This feature requires kubernetes&gt;=19.15.0. When kubernetes library is less than 19.15.0, it fails even no_proxy set in correct.</div>
<div>example value is &quot;localhost,.local,.example.com,127.0.0.1,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16&quot;</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -518,8 +497,7 @@ Parameters
<td> <td>
<div>Provide a path to a file containing a valid YAML definition of an object or objects to be created or updated. Mutually exclusive with <em>resource_definition</em>. NOTE: <em>kind</em>, <em>api_version</em>, <em>name</em>, and <em>namespace</em> will be overwritten by corresponding values found in the configuration read in from the <em>src</em> file.</div> <div>Provide a path to a file containing a valid YAML definition of an object or objects to be created or updated. Mutually exclusive with <em>resource_definition</em>. NOTE: <em>kind</em>, <em>api_version</em>, <em>name</em>, and <em>namespace</em> will be overwritten by corresponding values found in the configuration read in from the <em>src</em> file.</div>
<div>Reads from the local file system. To read from the Ansible controller&#x27;s file system, including vaulted files, use the file lookup plugin or template lookup plugin, combined with the from_yaml filter, and pass the result to <em>resource_definition</em>. See Examples below.</div> <div>Reads from the local file system. To read from the Ansible controller&#x27;s file system, including vaulted files, use the file lookup plugin or template lookup plugin, combined with the from_yaml filter, and pass the result to <em>resource_definition</em>. See Examples below.</div>
<div>The URL to manifest files that can be used to create the resource. Added in version 2.4.0.</div> <div>Mutually exclusive with <em>template</em> in case of <span class='module'>k8s</span> module.</div>
<div>Mutually exclusive with <em>template</em> in case of <span class='module'>kubernetes.core.k8s</span> module.</div>
</td> </td>
</tr> </tr>
<tr> <tr>

View File

@@ -24,8 +24,8 @@ Requirements
------------ ------------
The below requirements are needed on the host that executes this module. The below requirements are needed on the host that executes this module.
- python >= 3.9 - python >= 3.6
- kubernetes >= 24.2.0 - kubernetes >= 12.0.0
Parameters Parameters
@@ -220,7 +220,6 @@ Parameters
</td> </td>
<td> <td>
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div> <div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
<div>Multiple Kubernetes config file can be provided using separator &#x27;;&#x27; for Windows platform or &#x27;:&#x27; for others platforms.</div>
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0. Added in version 2.2.0.</div> <div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0. Added in version 2.2.0.</div>
</td> </td>
</tr> </tr>
@@ -281,25 +280,6 @@ Parameters
<div>Use to specify a Service object namespace.</div> <div>Use to specify a Service object namespace.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>no_proxy</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
</td>
<td>
</td>
<td>
<div>The comma separated list of hosts/domains/IP/CIDR that shouldn&#x27;t go through proxy. Can also be specified via K8S_AUTH_NO_PROXY environment variable.</div>
<div>Please note that this module does not pick up typical proxy settings from the environment (e.g. NO_PROXY).</div>
<div>This feature requires kubernetes&gt;=19.15.0. When kubernetes library is less than 19.15.0, it fails even no_proxy set in correct.</div>
<div>example value is &quot;localhost,.local,.example.com,127.0.0.1,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16&quot;</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -488,8 +468,7 @@ Parameters
<td> <td>
<div>Provide a path to a file containing a valid YAML definition of an object or objects to be created or updated. Mutually exclusive with <em>resource_definition</em>. NOTE: <em>kind</em>, <em>api_version</em>, <em>name</em>, and <em>namespace</em> will be overwritten by corresponding values found in the configuration read in from the <em>src</em> file.</div> <div>Provide a path to a file containing a valid YAML definition of an object or objects to be created or updated. Mutually exclusive with <em>resource_definition</em>. NOTE: <em>kind</em>, <em>api_version</em>, <em>name</em>, and <em>namespace</em> will be overwritten by corresponding values found in the configuration read in from the <em>src</em> file.</div>
<div>Reads from the local file system. To read from the Ansible controller&#x27;s file system, including vaulted files, use the file lookup plugin or template lookup plugin, combined with the from_yaml filter, and pass the result to <em>resource_definition</em>. See Examples below.</div> <div>Reads from the local file system. To read from the Ansible controller&#x27;s file system, including vaulted files, use the file lookup plugin or template lookup plugin, combined with the from_yaml filter, and pass the result to <em>resource_definition</em>. See Examples below.</div>
<div>The URL to manifest files that can be used to create the resource. Added in version 2.4.0.</div> <div>Mutually exclusive with <em>template</em> in case of <span class='module'>k8s</span> module.</div>
<div>Mutually exclusive with <em>template</em> in case of <span class='module'>kubernetes.core.k8s</span> module.</div>
</td> </td>
</tr> </tr>
<tr> <tr>

View File

@@ -26,8 +26,8 @@ Requirements
------------ ------------
The below requirements are needed on the host that executes this module. The below requirements are needed on the host that executes this module.
- python >= 3.9 - python >= 3.6
- kubernetes >= 24.2.0 - kubernetes >= 12.0.0
Parameters Parameters
@@ -182,7 +182,6 @@ Parameters
</td> </td>
<td> <td>
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div> <div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
<div>Multiple Kubernetes config file can be provided using separator &#x27;;&#x27; for Windows platform or &#x27;:&#x27; for others platforms.</div>
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0. Added in version 2.2.0.</div> <div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0. Added in version 2.2.0.</div>
</td> </td>
</tr> </tr>

View File

@@ -208,7 +208,6 @@ Parameters
</td> </td>
<td> <td>
<div>Path to a kubectl config file. Defaults to <em>~/.kube/config</em></div> <div>Path to a kubectl config file. Defaults to <em>~/.kube/config</em></div>
<div>The configuration can be provided as dictionary. Added in version 2.4.0.</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -355,7 +354,7 @@ Status
Authors Authors
~~~~~~~ ~~~~~~~
- xuxinkun (@xuxinkun) - xuxinkun
.. hint:: .. hint::

View File

@@ -133,27 +133,106 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
<table border=0 cellpadding=0 class="documentation-table"> <table border=0 cellpadding=0 class="documentation-table">
<tr> <tr>
<th colspan="1">Key</th> <th colspan="2">Key</th>
<th>Returned</th> <th>Returned</th>
<th width="100%">Description</th> <th width="100%">Description</th>
</tr> </tr>
<tr> <tr>
<td colspan="1"> <td colspan="2">
<div class="ansibleOptionAnchor" id="return-"></div> <div class="ansibleOptionAnchor" id="return-"></div>
<b>_list</b> <b>_list</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">complex</span>
</div>
</td>
<td></td>
<td>
<div>One ore more object definitions returned from the tool execution.</div>
<br/>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>api_version</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small"> <div style="font-size: small">
<span style="color: purple">string</span> <span style="color: purple">string</span>
</div> </div>
</td> </td>
<td></td> <td>success</td>
<td> <td>
<div>YAML string for the object definitions returned from the tool execution.</div> <div>The versioned schema of this representation of an object.</div>
<br/> <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;">{&#x27;kind&#x27;: &#x27;ConfigMap&#x27;, &#x27;apiVersion&#x27;: &#x27;v1&#x27;, &#x27;metadata&#x27;: {&#x27;name&#x27;: &#x27;my-config-map&#x27;, &#x27;namespace&#x27;: &#x27;default&#x27;}, &#x27;data&#x27;: {&#x27;key1&#x27;: &#x27;val1&#x27;}}</div>
</td> </td>
</tr> </tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>kind</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>success</td>
<td>
<div>Represents the REST resource this object represents.</div>
<br/>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>metadata</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">complex</span>
</div>
</td>
<td>success</td>
<td>
<div>Standard object metadata. Includes name, namespace, annotations, labels, etc.</div>
<br/>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>spec</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">complex</span>
</div>
</td>
<td>success</td>
<td>
<div>Specific attributes of the object. Will vary based on the <em>api_version</em> and <em>kind</em>.</div>
<br/>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>status</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">complex</span>
</div>
</td>
<td>success</td>
<td>
<div>Current status details for the object.</div>
<br/>
</td>
</tr>
</table> </table>
<br/><br/> <br/><br/>
@@ -165,7 +244,7 @@ Status
Authors Authors
~~~~~~~ ~~~~~~~
- Aubin Bikouo (@abikouo) - Aubin Bikouo <@abikouo>
.. hint:: .. hint::

View File

@@ -25,7 +25,7 @@ tags:
- openshift - openshift
- okd - okd
- cluster - cluster
version: 3.0.0 version: 2.4.1
build_ignore: build_ignore:
- .DS_Store - .DS_Store
- "*.tar.gz" - "*.tar.gz"

View File

@@ -1,5 +1,5 @@
--- ---
requires_ansible: '>=2.14.0' requires_ansible: ">=2.9.17"
action_groups: action_groups:
helm: helm:
@@ -20,12 +20,6 @@ plugin_routing:
inventory: inventory:
openshift: openshift:
redirect: community.okd.openshift redirect: community.okd.openshift
k8s:
deprecation:
removal_version: 4.0.0
warning_text: >-
The k8s inventory plugin has been deprecated and
will be removed in release 4.0.0.
modules: modules:
k8s_auth: k8s_auth:
redirect: community.okd.k8s_auth redirect: community.okd.k8s_auth
@@ -35,18 +29,18 @@ plugin_routing:
warning_text: Use kubernetes.core.k8s_info instead. warning_text: Use kubernetes.core.k8s_info instead.
k8s_raw: k8s_raw:
tombstone: tombstone:
removal_version: 0.1.0 removal_version: "0.1.0"
warning_text: The k8s_raw module was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s instead. warning_text: The k8s_raw module was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s instead.
openshift_raw: openshift_raw:
tombstone: tombstone:
removal_version: 0.1.0 removal_version: "0.1.0"
warning_text: The openshift_raw module was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s instead. warning_text: The openshift_raw module was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s instead.
openshift_scale: openshift_scale:
tombstone: tombstone:
removal_version: 0.1.0 removal_version: "0.1.0"
warning_text: The openshift_scale module was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s_scale instead. warning_text: The openshift_scale module was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s_scale instead.
lookup: lookup:
openshift: openshift:
tombstone: tombstone:
removal_version: 0.1.0 removal_version: "0.1.0"
warning_text: The openshift lookup plugin was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s instead. warning_text: The openshift lookup plugin was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s instead.

View File

@@ -8,21 +8,21 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
import copy import copy
import os
import platform
import traceback import traceback
import os
from contextlib import contextmanager from contextlib import contextmanager
import platform
from ansible.config.manager import ensure_type from ansible.config.manager import ensure_type
from ansible.errors import ( from ansible.errors import (
AnsibleAction,
AnsibleActionFail,
AnsibleError, AnsibleError,
AnsibleFileNotFound, AnsibleFileNotFound,
AnsibleAction,
AnsibleActionFail,
) )
from ansible.module_utils._text import to_bytes, to_native, to_text
from ansible.module_utils.parsing.convert_bool import boolean from ansible.module_utils.parsing.convert_bool import boolean
from ansible.module_utils.six import iteritems, string_types from ansible.module_utils.six import string_types, iteritems
from ansible.module_utils._text import to_text, to_bytes, to_native
from ansible.plugins.action import ActionBase from ansible.plugins.action import ActionBase
@@ -55,6 +55,7 @@ ENV_KUBECONFIG_PATH_SEPARATOR = ";" if platform.system() == "Windows" else ":"
class ActionModule(ActionBase): class ActionModule(ActionBase):
TRANSFERS_FILES = True TRANSFERS_FILES = True
DEFAULT_NEWLINE_SEQUENCE = "\n" DEFAULT_NEWLINE_SEQUENCE = "\n"

View File

@@ -172,18 +172,18 @@ DOCUMENTATION = r"""
aliases: [ kubectl_verify_ssl ] aliases: [ kubectl_verify_ssl ]
""" """
import json
import os import os
import os.path import os.path
import shutil import shutil
import subprocess import subprocess
import tempfile import tempfile
import json
from ansible.errors import AnsibleError, AnsibleFileNotFound
from ansible.module_utils._text import to_bytes
from ansible.module_utils.six.moves import shlex_quote
from ansible.parsing.yaml.loader import AnsibleLoader from ansible.parsing.yaml.loader import AnsibleLoader
from ansible.plugins.connection import BUFSIZE, ConnectionBase from ansible.errors import AnsibleError, AnsibleFileNotFound
from ansible.module_utils.six.moves import shlex_quote
from ansible.module_utils._text import to_bytes
from ansible.plugins.connection import ConnectionBase, BUFSIZE
from ansible.utils.display import Display from ansible.utils.display import Display
display = Display() display = Display()

View File

@@ -12,6 +12,7 @@ __metaclass__ = type
class ModuleDocFragment(object): class ModuleDocFragment(object):
DOCUMENTATION = r""" DOCUMENTATION = r"""
options: options:
binary_path: binary_path:

View File

@@ -11,6 +11,7 @@ __metaclass__ = type
class ModuleDocFragment(object): class ModuleDocFragment(object):
DOCUMENTATION = r""" DOCUMENTATION = r"""
options: options:
host: host:

View File

@@ -11,6 +11,7 @@ __metaclass__ = type
class ModuleDocFragment(object): class ModuleDocFragment(object):
DOCUMENTATION = r""" DOCUMENTATION = r"""
options: options:
delete_options: delete_options:

View File

@@ -11,6 +11,7 @@ __metaclass__ = type
class ModuleDocFragment(object): class ModuleDocFragment(object):
DOCUMENTATION = r""" DOCUMENTATION = r"""
options: options:
api_version: api_version:

View File

@@ -11,6 +11,7 @@ __metaclass__ = type
class ModuleDocFragment(object): class ModuleDocFragment(object):
DOCUMENTATION = r""" DOCUMENTATION = r"""
options: options:
resource_definition: resource_definition:

View File

@@ -11,6 +11,7 @@ __metaclass__ = type
class ModuleDocFragment(object): class ModuleDocFragment(object):
DOCUMENTATION = r""" DOCUMENTATION = r"""
options: options:
replicas: replicas:

View File

@@ -11,6 +11,7 @@ __metaclass__ = type
class ModuleDocFragment(object): class ModuleDocFragment(object):
DOCUMENTATION = r""" DOCUMENTATION = r"""
options: options:
state: state:

View File

@@ -11,6 +11,7 @@ __metaclass__ = type
class ModuleDocFragment(object): class ModuleDocFragment(object):
DOCUMENTATION = r""" DOCUMENTATION = r"""
options: options:
wait: wait:

View File

@@ -1,12 +1,50 @@
# Copyright (c) 2017 Ansible Project # Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = r"""
name: k8s_config_resource_name
short_description: Generate resource name for the given resource of type ConfigMap, Secret
description:
- Generate resource name for the given resource of type ConfigMap, Secret.
- Resource must have a C(metadata.name) key to generate a resource name
options:
_input:
description:
- A valid YAML definition for a ConfigMap or a Secret.
type: dict
required: true
author:
- ansible cloud team
"""
EXAMPLES = r"""
# Dump generated name for a configmap into a variable
- set_fact:
generated_name: '{{ definition | kubernetes.core.k8s_config_resource_name }}'
vars:
definition:
apiVersion: v1
kind: ConfigMap
metadata:
name: myconfigmap
namespace: mynamespace
"""
RETURN = r"""
_value:
description: Generated resource name.
type: str
"""
from ansible.errors import AnsibleFilterError from ansible.errors import AnsibleFilterError
from ansible_collections.kubernetes.core.plugins.module_utils.hashes import ( from ansible_collections.kubernetes.core.plugins.module_utils.hashes import (
generate_hash, generate_hash,

View File

@@ -19,13 +19,6 @@ DOCUMENTATION = """
- Uses the kubectl connection plugin to access the Kubernetes cluster. - Uses the kubectl connection plugin to access the Kubernetes cluster.
- Uses k8s.(yml|yaml) YAML configuration file to set parameter values. - Uses k8s.(yml|yaml) YAML configuration file to set parameter values.
deprecated:
removed_in: 4.0.0
why: |
As discussed in U(https://github.com/ansible-collections/kubernetes.core/issues/31), we decided to
remove the k8s inventory plugin in release 4.0.0.
alternative: "Use M(kubernetes.core.k8s_info) and M(ansible.builtin.add_host) instead."
options: options:
plugin: plugin:
description: token that ensures this is a source file for the 'k8s' plugin. description: token that ensures this is a source file for the 'k8s' plugin.
@@ -34,7 +27,7 @@ DOCUMENTATION = """
connections: connections:
description: description:
- Optional list of cluster connection settings. If no connections are provided, the default - Optional list of cluster connection settings. If no connections are provided, the default
I(~/.kube/config) and active context will be used, and objects will be returned for all namespaces '~/.kube/config' and active context will be used, and objects will be returned for all namespaces
the active user is authorized to access. the active user is authorized to access.
suboptions: suboptions:
name: name:
@@ -45,7 +38,7 @@ DOCUMENTATION = """
description: description:
- Path to an existing Kubernetes config file. If not provided, and no other connection - Path to an existing Kubernetes config file. If not provided, and no other connection
options are provided, the Kubernetes client will attempt to load the default options are provided, the Kubernetes client will attempt to load the default
configuration file from I(~/.kube/config). Can also be specified via K8S_AUTH_KUBECONFIG configuration file from '~/.kube/config'. Can also be specified via K8S_AUTH_KUBECONFIG
environment variable. environment variable.
context: context:
description: description:
@@ -93,12 +86,12 @@ DOCUMENTATION = """
to access. to access.
requirements: requirements:
- "python >= 3.9" - "python >= 3.6"
- "kubernetes >= 24.2.0" - "kubernetes >= 12.0.0"
- "PyYAML >= 3.11" - "PyYAML >= 3.11"
""" """
EXAMPLES = r""" EXAMPLES = """
# File must be named k8s.yaml or k8s.yml # File must be named k8s.yaml or k8s.yml
- name: Authenticate with token, and return all pods and services for all namespaces - name: Authenticate with token, and return all pods and services for all namespaces
@@ -124,7 +117,6 @@ EXAMPLES = r"""
import json import json
from ansible.errors import AnsibleError from ansible.errors import AnsibleError
from ansible.plugins.inventory import BaseInventoryPlugin, Cacheable, Constructable
from ansible_collections.kubernetes.core.plugins.module_utils.common import ( from ansible_collections.kubernetes.core.plugins.module_utils.common import (
HAS_K8S_MODULE_HELPER, HAS_K8S_MODULE_HELPER,
k8s_import_exception, k8s_import_exception,
@@ -132,6 +124,7 @@ from ansible_collections.kubernetes.core.plugins.module_utils.common import (
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import ( from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
get_api_client, get_api_client,
) )
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable
try: try:
from kubernetes.dynamic.exceptions import DynamicApiError from kubernetes.dynamic.exceptions import DynamicApiError
@@ -162,12 +155,6 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
def parse(self, inventory, loader, path, cache=True): def parse(self, inventory, loader, path, cache=True):
super(InventoryModule, self).parse(inventory, loader, path) super(InventoryModule, self).parse(inventory, loader, path)
self.display.deprecated(
"The 'k8s' inventory plugin has been deprecated and will be removed in release 4.0.0",
version="4.0.0",
collection_name="kubernetes.core",
)
cache_key = self._get_cache_prefix(path) cache_key = self._get_cache_prefix(path)
config_data = self._read_config_data(path) config_data = self._read_config_data(path)
self.setup(config_data, cache, cache_key) self.setup(config_data, cache, cache_key)
@@ -193,6 +180,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
self.fetch_objects(connections) self.fetch_objects(connections)
def fetch_objects(self, connections): def fetch_objects(self, connections):
if connections: if connections:
if not isinstance(connections, list): if not isinstance(connections, list):
raise K8sInventoryException("Expecting connections to be a list.") raise K8sInventoryException("Expecting connections to be a list.")

View File

@@ -114,8 +114,8 @@ DOCUMENTATION = """
aliases: [ verify_ssl ] aliases: [ verify_ssl ]
requirements: requirements:
- "python >= 3.9" - "python >= 3.6"
- "kubernetes >= 24.2.0" - "kubernetes >= 12.0.0"
- "PyYAML >= 3.11" - "PyYAML >= 3.11"
""" """
@@ -179,6 +179,7 @@ import os
from ansible.errors import AnsibleError from ansible.errors import AnsibleError
from ansible.module_utils.common._collections_compat import KeysView from ansible.module_utils.common._collections_compat import KeysView
from ansible.module_utils.common.validation import check_type_bool from ansible.module_utils.common.validation import check_type_bool
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import ( from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
get_api_client, get_api_client,
) )
@@ -213,6 +214,7 @@ except ImportError as e:
class KubernetesLookup(object): class KubernetesLookup(object):
def __init__(self): def __init__(self):
if not HAS_K8S_MODULE_HELPER: if not HAS_K8S_MODULE_HELPER:
raise Exception( raise Exception(
"Requires the Kubernetes Python client. Try `pip install kubernetes`. Detail: {0}".format( "Requires the Kubernetes Python client. Try `pip install kubernetes`. Detail: {0}".format(

View File

@@ -64,11 +64,12 @@ RETURN = """
key1: val1 key1: val1
""" """
import subprocess
from ansible.errors import AnsibleLookupError from ansible.errors import AnsibleLookupError
from ansible.module_utils.common.process import get_bin_path
from ansible.plugins.lookup import LookupBase from ansible.plugins.lookup import LookupBase
from ansible.module_utils.common.process import get_bin_path
import subprocess
def get_binary_from_path(name, opt_dirs=None): def get_binary_from_path(name, opt_dirs=None):

View File

@@ -14,9 +14,9 @@ except TypeError:
if enable_turbo_mode: if enable_turbo_mode:
try: try:
from ansible_collections.cloud.common.plugins.module_utils.turbo.module import ( # noqa: F401 from ansible_collections.cloud.common.plugins.module_utils.turbo.module import (
AnsibleTurboModule as AnsibleModule, AnsibleTurboModule as AnsibleModule,
) ) # noqa: F401
AnsibleModule.collection_name = "kubernetes.core" AnsibleModule.collection_name = "kubernetes.core"
except ImportError: except ImportError:

View File

@@ -17,8 +17,8 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
import json
from collections import OrderedDict from collections import OrderedDict
import json
from ansible.module_utils.common.dict_transformations import dict_merge from ansible.module_utils.common.dict_transformations import dict_merge
from ansible_collections.kubernetes.core.plugins.module_utils.exceptions import ( from ansible_collections.kubernetes.core.plugins.module_utils.exceptions import (
@@ -31,6 +31,7 @@ from ansible_collections.kubernetes.core.plugins.module_utils.version import (
LooseVersion, LooseVersion,
) )
try: try:
from kubernetes.dynamic.exceptions import NotFoundError from kubernetes.dynamic.exceptions import NotFoundError
except ImportError: except ImportError:

View File

@@ -13,18 +13,15 @@
# limitations under the License. # limitations under the License.
import hashlib
import json import json
import os import os
import tempfile
from collections import defaultdict from collections import defaultdict
import hashlib
import tempfile
from functools import partial from functools import partial
import kubernetes.dynamic import kubernetes.dynamic
import kubernetes.dynamic.discovery import kubernetes.dynamic.discovery
from ansible_collections.kubernetes.core.plugins.module_utils.client.resource import (
ResourceList,
)
from kubernetes import __version__ from kubernetes import __version__
from kubernetes.dynamic.exceptions import ( from kubernetes.dynamic.exceptions import (
ResourceNotFoundError, ResourceNotFoundError,
@@ -32,6 +29,10 @@ from kubernetes.dynamic.exceptions import (
ServiceUnavailableError, ServiceUnavailableError,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.client.resource import (
ResourceList,
)
class Discoverer(kubernetes.dynamic.discovery.Discoverer): class Discoverer(kubernetes.dynamic.discovery.Discoverer):
def __init__(self, client, cache_file): def __init__(self, client, cache_file):
@@ -113,7 +114,7 @@ class Discoverer(kubernetes.dynamic.discovery.Discoverer):
filter(lambda resource: "/" in resource["name"], resources_response) filter(lambda resource: "/" in resource["name"], resources_response)
) )
for subresource in subresources_raw: for subresource in subresources_raw:
resource, name = subresource["name"].split("/") resource, name = subresource["name"].split("/", 1)
subresources[resource][name] = subresource subresources[resource][name] = subresource
for resource in resources_raw: for resource in resources_raw:

View File

@@ -20,20 +20,17 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
import base64 import base64
import hashlib
import os
import sys
import time import time
import os
import traceback import traceback
import sys
import hashlib
from datetime import datetime from datetime import datetime
from tempfile import NamedTemporaryFile from tempfile import NamedTemporaryFile
from ansible.module_utils._text import to_bytes, to_native, to_text from ansible_collections.kubernetes.core.plugins.module_utils.version import (
from ansible.module_utils.basic import missing_required_lib LooseVersion,
from ansible.module_utils.common.dict_transformations import dict_merge )
from ansible.module_utils.parsing.convert_bool import boolean
from ansible.module_utils.six import iteritems, string_types
from ansible.module_utils.urls import Request
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import ( from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
AUTH_ARG_MAP, AUTH_ARG_MAP,
AUTH_ARG_SPEC, AUTH_ARG_SPEC,
@@ -45,23 +42,27 @@ from ansible_collections.kubernetes.core.plugins.module_utils.hashes import (
from ansible_collections.kubernetes.core.plugins.module_utils.selector import ( from ansible_collections.kubernetes.core.plugins.module_utils.selector import (
LabelSelectorFilter, LabelSelectorFilter,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.version import (
LooseVersion, from ansible.module_utils.basic import missing_required_lib
) from ansible.module_utils.six import iteritems, string_types
from ansible.module_utils._text import to_native, to_bytes, to_text
from ansible.module_utils.common.dict_transformations import dict_merge
from ansible.module_utils.parsing.convert_bool import boolean
from ansible.module_utils.urls import Request
K8S_IMP_ERR = None K8S_IMP_ERR = None
try: try:
import kubernetes import kubernetes
from kubernetes.dynamic.exceptions import ( from kubernetes.dynamic.exceptions import (
BadRequestError,
ConflictError,
DynamicApiError,
ForbiddenError,
KubernetesValidateMissing,
MethodNotAllowedError,
NotFoundError, NotFoundError,
ResourceNotFoundError, ResourceNotFoundError,
ResourceNotUniqueError, ResourceNotUniqueError,
DynamicApiError,
ConflictError,
ForbiddenError,
MethodNotAllowedError,
BadRequestError,
KubernetesValidateMissing,
) )
HAS_K8S_MODULE_HELPER = True HAS_K8S_MODULE_HELPER = True
@@ -796,8 +797,8 @@ class K8sAnsibleMixin(object):
self.resource_definitions = [implicit_definition] self.resource_definitions = [implicit_definition]
def check_library_version(self): def check_library_version(self):
if LooseVersion(self.kubernetes_version) < LooseVersion("24.2.0"): if LooseVersion(self.kubernetes_version) < LooseVersion("12.0.0"):
self.fail_json(msg="kubernetes >= 24.2.0 is required") self.fail_json(msg="kubernetes >= 12.0.0 is required")
def flatten_list_kind(self, list_resource, definitions): def flatten_list_kind(self, list_resource, definitions):
flattened = [] flattened = []
@@ -818,7 +819,7 @@ class K8sAnsibleMixin(object):
try: try:
self.client = get_api_client(self.module) self.client = get_api_client(self.module)
# Hopefully the kubernetes client will provide its own exception class one day # Hopefully the kubernetes client will provide its own exception class one day
except urllib3.exceptions.RequestError as e: except (urllib3.exceptions.RequestError) as e:
self.fail_json(msg="Couldn't connect to Kubernetes: %s" % str(e)) self.fail_json(msg="Couldn't connect to Kubernetes: %s" % str(e))
flattened_definitions = [] flattened_definitions = []
@@ -836,7 +837,7 @@ class K8sAnsibleMixin(object):
resource = self.find_resource(kind, api_version, fail=True) resource = self.find_resource(kind, api_version, fail=True)
flattened_definitions.append((resource, definition)) flattened_definitions.append((resource, definition))
for resource, definition in flattened_definitions: for (resource, definition) in flattened_definitions:
kind = definition.get("kind", self.kind) kind = definition.get("kind", self.kind)
api_version = definition.get("apiVersion", self.api_version) api_version = definition.get("apiVersion", self.api_version)
definition = self.set_defaults(resource, definition) definition = self.set_defaults(resource, definition)
@@ -1435,7 +1436,7 @@ class K8sAnsibleMixin(object):
if merge_type == "json": if merge_type == "json":
self.module.deprecate( self.module.deprecate(
msg="json as a merge_type value is deprecated. Please use the k8s_json_patch module instead.", msg="json as a merge_type value is deprecated. Please use the k8s_json_patch module instead.",
version="4.0.0", version="3.0.0",
collection_name="kubernetes.core", collection_name="kubernetes.core",
) )
try: try:

View File

@@ -18,26 +18,25 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
import os import os
import tarfile from tempfile import TemporaryFile, NamedTemporaryFile
from abc import ABCMeta, abstractmethod
from select import select from select import select
from tempfile import NamedTemporaryFile, TemporaryFile from abc import ABCMeta, abstractmethod
import tarfile
from ansible.module_utils._text import to_native
# from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import AnsibleModule # from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import AnsibleModule
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import ( from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
CoreException, CoreException,
) )
from ansible.module_utils._text import to_native
try: try:
from kubernetes.client.api import core_v1_api from kubernetes.client.api import core_v1_api
from kubernetes.stream import stream from kubernetes.stream import stream
from kubernetes.stream.ws_client import ( from kubernetes.stream.ws_client import (
ABNF,
ERROR_CHANNEL,
STDERR_CHANNEL,
STDOUT_CHANNEL, STDOUT_CHANNEL,
STDERR_CHANNEL,
ERROR_CHANNEL,
ABNF,
) )
except ImportError: except ImportError:
pass pass

View File

@@ -19,8 +19,8 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
import hashlib
import json import json
import hashlib
try: try:
import string import string
@@ -37,7 +37,7 @@ except ImportError:
def sorted_dict(unsorted_dict): def sorted_dict(unsorted_dict):
result = OrderedDict() result = OrderedDict()
for k, v in sorted(unsorted_dict.items()): for (k, v) in sorted(unsorted_dict.items()):
if isinstance(v, dict): if isinstance(v, dict):
v = sorted_dict(v) v = sorted_dict(v)
result[k] = v result[k] = v

View File

@@ -7,18 +7,19 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
import copy
import json
import os import os
import re
import tempfile import tempfile
import traceback import traceback
import re
import json
import copy
from ansible.module_utils.basic import AnsibleModule, missing_required_lib from ansible.module_utils.basic import missing_required_lib
from ansible.module_utils.six import string_types from ansible.module_utils.six import string_types
from ansible_collections.kubernetes.core.plugins.module_utils.version import ( from ansible_collections.kubernetes.core.plugins.module_utils.version import (
LooseVersion, LooseVersion,
) )
from ansible.module_utils.basic import AnsibleModule
try: try:
import yaml import yaml
@@ -83,6 +84,7 @@ class AnsibleHelmModule(object):
""" """
def __init__(self, **kwargs): def __init__(self, **kwargs):
self._module = None self._module = None
if "module" in kwargs: if "module" in kwargs:
self._module = kwargs.get("module") self._module = kwargs.get("module")
@@ -115,7 +117,7 @@ class AnsibleHelmModule(object):
kubeconfig = self.params.get("kubeconfig") kubeconfig = self.params.get("kubeconfig")
if kubeconfig: if kubeconfig:
if isinstance(kubeconfig, string_types): if isinstance(kubeconfig, string_types):
with open(kubeconfig) as fd: with open(os.path.expanduser(kubeconfig)) as fd:
kubeconfig_content = yaml.safe_load(fd) kubeconfig_content = yaml.safe_load(fd)
elif isinstance(kubeconfig, dict): elif isinstance(kubeconfig, dict):
kubeconfig_content = kubeconfig kubeconfig_content = kubeconfig
@@ -182,6 +184,7 @@ class AnsibleHelmModule(object):
) )
def get_helm_version(self): def get_helm_version(self):
command = self.get_helm_binary() + " version" command = self.get_helm_binary() + " version"
rc, out, err = self.run_command(command) rc, out, err = self.run_command(command)
m = re.match(r'version.BuildInfo{Version:"v([0-9\.]*)",', out) m = re.match(r'version.BuildInfo{Version:"v([0-9\.]*)",', out)
@@ -213,6 +216,7 @@ class AnsibleHelmModule(object):
return yaml.safe_load(out) return yaml.safe_load(out)
def parse_yaml_content(self, content): def parse_yaml_content(self, content):
if not HAS_YAML: if not HAS_YAML:
self.fail_json(msg=missing_required_lib("yaml"), exception=HAS_YAML) self.fail_json(msg=missing_required_lib("yaml"), exception=HAS_YAML)
@@ -224,6 +228,7 @@ class AnsibleHelmModule(object):
) )
def get_manifest(self, release_name): def get_manifest(self, release_name):
command = [ command = [
self.get_helm_binary(), self.get_helm_binary(),
"get", "get",
@@ -236,6 +241,7 @@ class AnsibleHelmModule(object):
return self.parse_yaml_content(out) return self.parse_yaml_content(out)
def get_notes(self, release_name): def get_notes(self, release_name):
command = [ command = [
self.get_helm_binary(), self.get_helm_binary(),
"get", "get",

View File

@@ -1,11 +1,12 @@
# Copyright: (c) 2021, Red Hat | Ansible # Copyright: (c) 2021, Red Hat | Ansible
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
import hashlib
import os import os
import hashlib
from typing import Any, Dict, List, Optional from typing import Any, Dict, List, Optional
from ansible.module_utils.six import iteritems, string_types from ansible.module_utils.six import iteritems, string_types
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import ( from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
AUTH_ARG_MAP, AUTH_ARG_MAP,
AUTH_ARG_SPEC, AUTH_ARG_SPEC,

View File

@@ -1,12 +1,15 @@
import traceback import traceback
from typing import Optional from typing import Optional
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
from ansible.module_utils.common.text.converters import to_text
from ansible_collections.kubernetes.core.plugins.module_utils.version import ( from ansible_collections.kubernetes.core.plugins.module_utils.version import (
LooseVersion, LooseVersion,
) )
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.basic import missing_required_lib
from ansible.module_utils.common.text.converters import to_text
class AnsibleK8SModule: class AnsibleK8SModule:
"""A base module class for K8S modules. """A base module class for K8S modules.
@@ -35,7 +38,7 @@ class AnsibleK8SModule:
if self.settings["check_k8s"]: if self.settings["check_k8s"]:
self.requires("kubernetes") self.requires("kubernetes")
self.has_at_least("kubernetes", "24.2.0", warn=True) self.has_at_least("kubernetes", "12.0.0", warn=True)
if self.settings["check_pyyaml"]: if self.settings["check_pyyaml"]:
self.requires("pyyaml") self.requires("pyyaml")

View File

@@ -2,7 +2,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
import os import os
from typing import Dict, Iterable, List, Optional, Union, cast from typing import cast, Dict, Iterable, List, Optional, Union
from ansible.module_utils.six import string_types from ansible.module_utils.six import string_types
from ansible.module_utils.urls import Request from ansible.module_utils.urls import Request

View File

@@ -4,12 +4,12 @@
from typing import Dict from typing import Dict
from ansible.module_utils._text import to_native from ansible.module_utils._text import to_native
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import ( from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
get_api_client, get_api_client,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import ( from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
CoreException, CoreException,
ResourceTimeout,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.resource import ( from ansible_collections.kubernetes.core.plugins.module_utils.k8s.resource import (
create_definitions, create_definitions,
@@ -17,7 +17,9 @@ from ansible_collections.kubernetes.core.plugins.module_utils.k8s.resource impor
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.service import ( from ansible_collections.kubernetes.core.plugins.module_utils.k8s.service import (
K8sService, K8sService,
diff_objects, diff_objects,
hide_fields, )
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
ResourceTimeout,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.waiter import exists from ansible_collections.kubernetes.core.plugins.module_utils.k8s.waiter import exists
from ansible_collections.kubernetes.core.plugins.module_utils.selector import ( from ansible_collections.kubernetes.core.plugins.module_utils.selector import (
@@ -44,51 +46,16 @@ def validate(client, module, resource):
return [_prepend_resource_info(resource, msg) for msg in warnings + errors] return [_prepend_resource_info(resource, msg) for msg in warnings + errors]
def get_definitions(svc, params):
try:
definitions = create_definitions(params)
except Exception as e:
msg = "Failed to load resource definition: {0}".format(e)
raise CoreException(msg) from e
delete_all = params.get("delete_all")
src = params.get("src")
resource_definition = params.get("resource_definition")
name = params.get("name")
state = params.get("state")
if (
delete_all
and state == "absent"
and name is None
and resource_definition is None
and src is None
):
# Delete all resources in the namespace for the specified resource type
if params.get("kind") is None:
raise CoreException(
"'kind' option is required to specify the resource type."
)
resource = svc.find_resource(
params.get("kind"), params.get("api_version"), fail=True
)
definitions = svc.retrieve_all(
resource,
params.get("namespace"),
params.get("label_selectors"),
)
return definitions
def run_module(module) -> None: def run_module(module) -> None:
results = [] results = []
changed = False changed = False
client = get_api_client(module) client = get_api_client(module)
svc = K8sService(client, module) svc = K8sService(client, module)
try:
definitions = get_definitions(svc, module.params) definitions = create_definitions(module.params)
except Exception as e:
msg = "Failed to load resource definition: {0}".format(e)
raise CoreException(msg) from e
for definition in definitions: for definition in definitions:
result = {"changed": False, "result": {}} result = {"changed": False, "result": {}}
@@ -135,7 +102,6 @@ def perform_action(svc, definition: Dict, params: Dict) -> Dict:
state = params.get("state", None) state = params.get("state", None)
kind = definition.get("kind") kind = definition.get("kind")
api_version = definition.get("apiVersion") api_version = definition.get("apiVersion")
hidden_fields = params.get("hidden_fields")
result = {"changed": False, "result": {}} result = {"changed": False, "result": {}}
instance = {} instance = {}
@@ -211,7 +177,7 @@ def perform_action(svc, definition: Dict, params: Dict) -> Dict:
existing = existing.to_dict() existing = existing.to_dict()
else: else:
existing = {} existing = {}
match, diffs = diff_objects(existing, instance, hidden_fields) match, diffs = diff_objects(existing, instance)
if match and diffs: if match and diffs:
result.setdefault("warnings", []).append( result.setdefault("warnings", []).append(
"No meaningful diff was generated, but the API may not be idempotent " "No meaningful diff was generated, but the API may not be idempotent "
@@ -221,7 +187,7 @@ def perform_action(svc, definition: Dict, params: Dict) -> Dict:
if svc.module._diff: if svc.module._diff:
result["diff"] = diffs result["diff"] = diffs
result["result"] = hide_fields(instance, hidden_fields) result["result"] = instance
if not success: if not success:
raise ResourceTimeout( raise ResourceTimeout(
'"{0}" "{1}": Timed out waiting on resource'.format( '"{0}" "{1}": Timed out waiting on resource'.format(

View File

@@ -1,33 +1,38 @@
# Copyright: (c) 2021, Red Hat | Ansible # Copyright: (c) 2021, Red Hat | Ansible
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
import copy
from typing import Any, Dict, List, Optional, Tuple from typing import Any, Dict, List, Optional, Tuple
from ansible.module_utils.common.dict_transformations import dict_merge
from ansible_collections.kubernetes.core.plugins.module_utils.hashes import ( from ansible_collections.kubernetes.core.plugins.module_utils.hashes import (
generate_hash, generate_hash,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import requires
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
CoreException,
)
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.waiter import ( from ansible_collections.kubernetes.core.plugins.module_utils.k8s.waiter import (
Waiter, Waiter,
exists, exists,
get_waiter,
resource_absent, resource_absent,
get_waiter,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import (
requires,
)
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
CoreException,
)
from ansible.module_utils.common.dict_transformations import dict_merge
try: try:
from kubernetes.dynamic.exceptions import ( from kubernetes.dynamic.exceptions import (
BadRequestError,
ConflictError,
ForbiddenError,
MethodNotAllowedError,
NotFoundError, NotFoundError,
ResourceNotFoundError, ResourceNotFoundError,
ResourceNotUniqueError, ResourceNotUniqueError,
ConflictError,
ForbiddenError,
MethodNotAllowedError,
BadRequestError,
) )
except ImportError: except ImportError:
# Handled in module setup # Handled in module setup
@@ -146,7 +151,7 @@ class K8sService:
if merge_type == "json": if merge_type == "json":
self.module.deprecate( self.module.deprecate(
msg="json as a merge_type value is deprecated. Please use the k8s_json_patch module instead.", msg="json as a merge_type value is deprecated. Please use the k8s_json_patch module instead.",
version="4.0.0", version="3.0.0",
collection_name="kubernetes.core", collection_name="kubernetes.core",
) )
try: try:
@@ -206,30 +211,6 @@ class K8sService:
return existing return existing
def retrieve_all(
self, resource: Resource, namespace: str, label_selectors: List[str] = None
) -> List[Dict]:
definitions: List[ResourceInstance] = []
try:
params = dict(namespace=namespace)
if label_selectors:
params["label_selector"] = ",".join(label_selectors)
resource_list = self.client.get(resource, **params)
for item in resource_list.items:
existing = self.client.get(
resource, name=item.metadata.name, namespace=namespace
)
definitions.append(existing.to_dict())
except (NotFoundError, MethodNotAllowedError):
pass
except Exception as e:
reason = e.body if hasattr(e, "body") else e
msg = "Failed to retrieve requested object: {0}".format(reason)
raise CoreException(msg) from e
return definitions
def find( def find(
self, self,
kind: str, kind: str,
@@ -243,7 +224,6 @@ class K8sService:
wait_timeout: Optional[int] = 120, wait_timeout: Optional[int] = 120,
state: Optional[str] = "present", state: Optional[str] = "present",
condition: Optional[Dict] = None, condition: Optional[Dict] = None,
hidden_fields: Optional[List] = None,
) -> Dict: ) -> Dict:
resource = self.find_resource(kind, api_version) resource = self.find_resource(kind, api_version)
api_found = bool(resource) api_found = bool(resource)
@@ -306,9 +286,7 @@ class K8sService:
instances = resources.get("items") or [resources] instances = resources.get("items") or [resources]
if not wait: if not wait:
result["resources"] = [ result["resources"] = instances
hide_fields(instance, hidden_fields) for instance in instances
]
return result return result
# Now wait for the specified state of any resource instances we have found. # Now wait for the specified state of any resource instances we have found.
@@ -327,7 +305,7 @@ class K8sService:
"Failed to gather information about %s(s) even" "Failed to gather information about %s(s) even"
" after waiting for %s seconds" % (res.get("kind"), duration) " after waiting for %s seconds" % (res.get("kind"), duration)
) )
result["resources"].append(hide_fields(res, hidden_fields)) result["resources"].append(res)
return result return result
def create(self, resource: Resource, definition: Dict) -> Dict: def create(self, resource: Resource, definition: Dict) -> Dict:
@@ -493,9 +471,7 @@ class K8sService:
return k8s_obj return k8s_obj
def diff_objects( def diff_objects(existing: Dict, new: Dict) -> Tuple[bool, Dict]:
existing: Dict, new: Dict, hidden_fields: Optional[list] = None
) -> Tuple[bool, Dict]:
result = {} result = {}
diff = recursive_diff(existing, new) diff = recursive_diff(existing, new)
if not diff: if not diff:
@@ -517,29 +493,4 @@ def diff_objects(
if not set(result["before"]["metadata"].keys()).issubset(ignored_keys): if not set(result["before"]["metadata"].keys()).issubset(ignored_keys):
return False, result return False, result
result["before"] = hide_fields(result["before"], hidden_fields)
result["after"] = hide_fields(result["after"], hidden_fields)
return True, result return True, result
def hide_fields(definition: dict, hidden_fields: Optional[list]) -> dict:
if not hidden_fields:
return definition
result = copy.deepcopy(definition)
for hidden_field in hidden_fields:
result = hide_field(result, hidden_field)
return result
# hide_field is not hugely sophisticated and designed to cope
# with e.g. status or metadata.managedFields rather than e.g.
# spec.template.spec.containers[0].env[3].value
def hide_field(definition: dict, hidden_field: str) -> dict:
split = hidden_field.split(".", 1)
if split[0] in definition:
if len(split) == 2:
definition[split[0]] = hide_field(definition[split[0]], split[1])
else:
del definition[split[0]]
return definition

View File

@@ -3,6 +3,7 @@ from functools import partial
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union
from ansible.module_utils.parsing.convert_bool import boolean from ansible.module_utils.parsing.convert_bool import boolean
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import ( from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
CoreException, CoreException,
) )
@@ -60,13 +61,6 @@ def daemonset_ready(daemonset: ResourceInstance) -> bool:
def statefulset_ready(statefulset: ResourceInstance) -> bool: def statefulset_ready(statefulset: ResourceInstance) -> bool:
if statefulset.spec.updateStrategy.type == "OnDelete":
return bool(
statefulset.status
and statefulset.status.observedGeneration
== (statefulset.metadata.generation or 0)
and statefulset.status.replicas == statefulset.spec.replicas
)
# These may be None # These may be None
updated_replicas = statefulset.status.updatedReplicas or 0 updated_replicas = statefulset.status.updatedReplicas or 0
ready_replicas = statefulset.status.readyReplicas or 0 ready_replicas = statefulset.status.readyReplicas or 0

View File

@@ -18,11 +18,12 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
from kubernetes.dynamic import DynamicClient
from ansible_collections.kubernetes.core.plugins.module_utils.apply import k8s_apply from ansible_collections.kubernetes.core.plugins.module_utils.apply import k8s_apply
from ansible_collections.kubernetes.core.plugins.module_utils.exceptions import ( from ansible_collections.kubernetes.core.plugins.module_utils.exceptions import (
ApplyException, ApplyException,
) )
from kubernetes.dynamic import DynamicClient
class K8SDynamicClient(DynamicClient): class K8SDynamicClient(DynamicClient):

View File

@@ -16,6 +16,7 @@ import re
class Selector(object): class Selector(object):
equality_based_operators = ("==", "!=", "=") equality_based_operators = ("==", "!=", "=")
def __init__(self, data): def __init__(self, data):

View File

@@ -130,21 +130,6 @@ options:
- json - json
- file - file
version_added: '2.4.0' version_added: '2.4.0'
reuse_values:
description:
- When upgrading package, specifies wether to reuse the last release's values and merge in any overrides from parameters I(release_values),
I(values_files) or I(set_values).
- If I(reset_values) is set to C(True), this is ignored.
type: bool
required: false
version_added: '2.5.0'
reset_values:
description:
- When upgrading package, reset the values to the ones built into the chart.
type: bool
required: false
default: True
version_added: '2.5.0'
#Helm options #Helm options
disable_hook: disable_hook:
@@ -325,17 +310,6 @@ EXAMPLES = r"""
enabled: True enabled: True
logging: logging:
enabled: True enabled: True
# Deploy latest version
- name: Deploy latest version of Grafana chart using reuse_values
kubernetes.core.helm:
name: test
chart_ref: stable/grafana
release_namespace: monitoring
reuse_values: true
values:
replicas: 2
version: 3e8ec0b2dffa40fb97d5342e4af887de95faa8c61a62480dd7f8aa03dffcf533
""" """
RETURN = r""" RETURN = r"""
@@ -393,11 +367,10 @@ command:
sample: helm upgrade ... sample: helm upgrade ...
""" """
import copy
import re import re
import tempfile import tempfile
import traceback import traceback
import copy
from ansible_collections.kubernetes.core.plugins.module_utils.version import ( from ansible_collections.kubernetes.core.plugins.module_utils.version import (
LooseVersion, LooseVersion,
) )
@@ -433,20 +406,14 @@ def get_release(state, release_name):
return None return None
def get_release_status(module, release_name, all_status=False): def get_release_status(module, release_name):
""" """
Get Release state from all release status (deployed, failed, pending-install, etc) Get Release state from deployed release
""" """
list_command = [ list_command = (
module.get_helm_binary(), module.get_helm_binary() + " list --output=yaml --filter " + release_name
"list", )
"--output=yaml",
"--filter",
release_name,
]
if all_status:
list_command.append("--all")
rc, out, err = module.run_helm_command(list_command) rc, out, err = module.run_helm_command(list_command)
@@ -472,7 +439,7 @@ def run_dep_update(module, chart_ref):
""" """
Run dependency update Run dependency update
""" """
dep_update = module.get_helm_binary() + f" dependency update '{chart_ref}'" dep_update = module.get_helm_binary() + " dependency update " + chart_ref
rc, out, err = module.run_helm_command(dep_update) rc, out, err = module.run_helm_command(dep_update)
@@ -480,7 +447,7 @@ def fetch_chart_info(module, command, chart_ref):
""" """
Get chart info Get chart info
""" """
inspect_command = command + f" show chart '{chart_ref}'" inspect_command = command + " show chart " + chart_ref
rc, out, err = module.run_helm_command(inspect_command) rc, out, err = module.run_helm_command(inspect_command)
@@ -488,7 +455,6 @@ def fetch_chart_info(module, command, chart_ref):
def deploy( def deploy(
module,
command, command,
release_name, release_name,
release_values, release_values,
@@ -507,8 +473,6 @@ def deploy(
timeout=None, timeout=None,
dependency_update=None, dependency_update=None,
set_value_args=None, set_value_args=None,
reuse_values=None,
reset_values=True,
): ):
""" """
Install/upgrade/rollback release chart Install/upgrade/rollback release chart
@@ -520,11 +484,9 @@ def deploy(
deploy_command += " --dependency-update" deploy_command += " --dependency-update"
else: else:
deploy_command = command + " upgrade -i" # install/upgrade deploy_command = command + " upgrade -i" # install/upgrade
if reset_values:
deploy_command += " --reset-values"
if reuse_values is not None: # Always reset values to keep release_values equal to values released
deploy_command += " --reuse-values=" + str(reuse_values) deploy_command += " --reset-values"
if wait: if wait:
deploy_command += " --wait" deploy_command += " --wait"
@@ -558,10 +520,9 @@ def deploy(
with open(path, "w") as yaml_file: with open(path, "w") as yaml_file:
yaml.dump(release_values, yaml_file, default_flow_style=False) yaml.dump(release_values, yaml_file, default_flow_style=False)
deploy_command += " -f=" + path deploy_command += " -f=" + path
module.add_cleanup_file(path)
if post_renderer: if post_renderer:
deploy_command += " --post-renderer=" + post_renderer deploy_command = " --post-renderer=" + post_renderer
if skip_crds: if skip_crds:
deploy_command += " --skip-crds" deploy_command += " --skip-crds"
@@ -572,7 +533,7 @@ def deploy(
if set_value_args: if set_value_args:
deploy_command += " " + set_value_args deploy_command += " " + set_value_args
deploy_command += " " + release_name + f" '{chart_name}'" deploy_command += " " + release_name + " " + chart_name
return deploy_command return deploy_command
@@ -638,7 +599,6 @@ def helmdiff_check(
chart_version=None, chart_version=None,
replace=False, replace=False,
chart_repo_url=None, chart_repo_url=None,
post_renderer=False,
): ):
""" """
Use helm diff to determine if a release would change by upgrading a chart. Use helm diff to determine if a release would change by upgrading a chart.
@@ -653,8 +613,6 @@ def helmdiff_check(
cmd += " " + "--version=" + chart_version cmd += " " + "--version=" + chart_version
if not replace: if not replace:
cmd += " " + "--reset-values" cmd += " " + "--reset-values"
if post_renderer:
cmd += " --post-renderer=" + post_renderer
if release_values != {}: if release_values != {}:
fd, path = tempfile.mkstemp(suffix=".yml") fd, path = tempfile.mkstemp(suffix=".yml")
@@ -724,8 +682,6 @@ def argument_spec():
skip_crds=dict(type="bool", default=False), skip_crds=dict(type="bool", default=False),
history_max=dict(type="int"), history_max=dict(type="int"),
set_values=dict(type="list", elements="dict"), set_values=dict(type="list", elements="dict"),
reuse_values=dict(type="bool"),
reset_values=dict(type="bool", default=True),
) )
) )
return arg_spec return arg_spec
@@ -776,38 +732,34 @@ def main():
history_max = module.params.get("history_max") history_max = module.params.get("history_max")
timeout = module.params.get("timeout") timeout = module.params.get("timeout")
set_values = module.params.get("set_values") set_values = module.params.get("set_values")
reuse_values = module.params.get("reuse_values")
reset_values = module.params.get("reset_values")
if update_repo_cache: if update_repo_cache:
run_repo_update(module) run_repo_update(module)
# Get real/deployed release status # Get real/deployed release status
all_status = release_state == "absent" release_status = get_release_status(module, release_name)
release_status = get_release_status(module, release_name, all_status=all_status)
helm_cmd = module.get_helm_binary() helm_cmd = module.get_helm_binary()
opt_result = {} opt_result = {}
if release_state == "absent" and release_status is not None: if release_state == "absent" and release_status is not None:
# skip release statuses 'uninstalled' and 'uninstalling' if replace:
if not release_status["status"].startswith("uninstall"): module.fail_json(msg="replace is not applicable when state is absent")
if replace:
module.fail_json(msg="replace is not applicable when state is absent")
if wait: if wait:
helm_version = module.get_helm_version() helm_version = module.get_helm_version()
if LooseVersion(helm_version) < LooseVersion("3.7.0"): if LooseVersion(helm_version) < LooseVersion("3.7.0"):
opt_result["warnings"] = [] opt_result["warnings"] = []
opt_result["warnings"].append( opt_result["warnings"].append(
"helm uninstall support option --wait for helm release >= 3.7.0" "helm uninstall support option --wait for helm release >= 3.7.0"
) )
wait = False wait = False
helm_cmd = delete( helm_cmd = delete(
helm_cmd, release_name, purge, disable_hook, wait, wait_timeout helm_cmd, release_name, purge, disable_hook, wait, wait_timeout
) )
changed = True changed = True
elif release_state == "present": elif release_state == "present":
if chart_version is not None: if chart_version is not None:
helm_cmd += " --version=" + chart_version helm_cmd += " --version=" + chart_version
@@ -853,7 +805,6 @@ def main():
set_value_args = module.get_helm_set_values_args(set_values) set_value_args = module.get_helm_set_values_args(set_values)
helm_cmd = deploy( helm_cmd = deploy(
module,
helm_cmd, helm_cmd,
release_name, release_name,
release_values, release_values,
@@ -872,12 +823,11 @@ def main():
history_max=history_max, history_max=history_max,
timeout=timeout, timeout=timeout,
set_value_args=set_value_args, set_value_args=set_value_args,
reuse_values=reuse_values,
reset_values=reset_values,
) )
changed = True changed = True
else: else:
helm_diff_version = get_plugin_version("diff") helm_diff_version = get_plugin_version("diff")
if helm_diff_version and ( if helm_diff_version and (
not chart_repo_url not chart_repo_url
@@ -895,7 +845,6 @@ def main():
chart_version, chart_version,
replace, replace,
chart_repo_url, chart_repo_url,
post_renderer,
) )
if would_change and module._diff: if would_change and module._diff:
opt_result["diff"] = {"prepared": prepared} opt_result["diff"] = {"prepared": prepared}
@@ -914,7 +863,6 @@ def main():
set_value_args = module.get_helm_set_values_args(set_values) set_value_args = module.get_helm_set_values_args(set_values)
helm_cmd = deploy( helm_cmd = deploy(
module,
helm_cmd, helm_cmd,
release_name, release_name,
release_values, release_values,
@@ -933,8 +881,6 @@ def main():
timeout=timeout, timeout=timeout,
dependency_update=dependency_update, dependency_update=dependency_update,
set_value_args=set_value_args, set_value_args=set_value_args,
reuse_values=reuse_values,
reset_values=reset_values,
) )
changed = True changed = True
@@ -968,7 +914,7 @@ def main():
changed=changed, changed=changed,
stdout=out, stdout=out,
stderr=err, stderr=err,
status=get_release_status(module, release_name, all_status=True), status=get_release_status(module, release_name),
command=helm_cmd, command=helm_cmd,
**opt_result, **opt_result,
) )

View File

@@ -137,8 +137,8 @@ status:
version_added: "2.4.0" version_added: "2.4.0"
""" """
import copy
import traceback import traceback
import copy
try: try:
import yaml import yaml

View File

@@ -109,7 +109,6 @@ rc:
""" """
import copy import copy
from ansible_collections.kubernetes.core.plugins.module_utils.helm import ( from ansible_collections.kubernetes.core.plugins.module_utils.helm import (
AnsibleHelmModule, AnsibleHelmModule,
parse_helm_plugin_list, parse_helm_plugin_list,

View File

@@ -71,10 +71,9 @@ rc:
""" """
import copy import copy
from ansible_collections.kubernetes.core.plugins.module_utils.helm import ( from ansible_collections.kubernetes.core.plugins.module_utils.helm import (
AnsibleHelmModule,
parse_helm_plugin_list, parse_helm_plugin_list,
AnsibleHelmModule,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.helm_args_common import ( from ansible_collections.kubernetes.core.plugins.module_utils.helm_args_common import (
HELM_AUTH_ARG_SPEC, HELM_AUTH_ARG_SPEC,
@@ -83,6 +82,7 @@ from ansible_collections.kubernetes.core.plugins.module_utils.helm_args_common i
def main(): def main():
argument_spec = copy.deepcopy(HELM_AUTH_ARG_SPEC) argument_spec = copy.deepcopy(HELM_AUTH_ARG_SPEC)
argument_spec.update( argument_spec.update(
dict( dict(

View File

@@ -166,8 +166,8 @@ msg:
sample: 'Repository already have a repository named bitnami' sample: 'Repository already have a repository named bitnami'
""" """
import copy
import traceback import traceback
import copy
try: try:
import yaml import yaml

View File

@@ -172,31 +172,10 @@ options:
- When set to True, server-side apply will force the changes against conflicts. - When set to True, server-side apply will force the changes against conflicts.
type: bool type: bool
default: False default: False
delete_all:
description:
- When this option is set to I(true) and I(state=absent),
module will delete all resources of the specified resource type in the requested namespace.
- Ignored when C(state) is not set to I(absent) or when one of (src),
C(name) or C(resource_definition) is provided.
- Parameter C(kind) is required to use this option.
- This parameter can be used with C(label_selectors) to restrict the resources to be deleted.
type: bool
default: false
version_added: 2.5.0
aliases:
- all
hidden_fields:
description:
- Hide fields matching this option in the result
- An example might be C(hidden_fields=[metadata.managedFields])
- Only field definitions that don't reference list items are supported (so V(spec.containers[0]) would not work)
type: list
elements: str
version_added: 2.5.0
requirements: requirements:
- "python >= 3.9" - "python >= 3.6"
- "kubernetes >= 24.2.0" - "kubernetes >= 12.0.0"
- "PyYAML >= 3.11" - "PyYAML >= 3.11"
- "jsonpatch" - "jsonpatch"
""" """
@@ -364,14 +343,6 @@ EXAMPLES = r"""
apply: yes apply: yes
server_side_apply: server_side_apply:
field_manager: ansible field_manager: ansible
# Delete all Deployment from specified namespace
- name: Delete all Deployment from specified namespace
kubernetes.core.k8s:
api_version: apps/v1
namespace: testing
kind: Deployment
delete_all: true
""" """
RETURN = r""" RETURN = r"""
@@ -423,10 +394,10 @@ from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule impo
) )
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import ( from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
AUTH_ARG_SPEC, AUTH_ARG_SPEC,
DELETE_OPTS_ARG_SPEC, WAIT_ARG_SPEC,
NAME_ARG_SPEC, NAME_ARG_SPEC,
RESOURCE_ARG_SPEC, RESOURCE_ARG_SPEC,
WAIT_ARG_SPEC, DELETE_OPTS_ARG_SPEC,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import ( from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import (
AnsibleK8SModule, AnsibleK8SModule,
@@ -479,8 +450,6 @@ def argspec():
argument_spec["server_side_apply"] = dict( argument_spec["server_side_apply"] = dict(
type="dict", default=None, options=server_apply_spec() type="dict", default=None, options=server_apply_spec()
) )
argument_spec["delete_all"] = dict(type="bool", default=False, aliases=["all"])
argument_spec["hidden_fields"] = dict(type="list", elements="str")
return argument_spec return argument_spec

View File

@@ -34,8 +34,8 @@ extends_documentation_fragment:
- kubernetes.core.k8s_auth_options - kubernetes.core.k8s_auth_options
requirements: requirements:
- "python >= 3.9" - "python >= 3.6"
- "kubernetes >= 24.2.0" - "kubernetes >= 12.0.0"
- "PyYAML >= 3.11" - "PyYAML >= 3.11"
""" """
@@ -154,15 +154,15 @@ except ImportError:
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import ( from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
AnsibleModule, AnsibleModule,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
AUTH_ARG_SPEC,
)
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import ( from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import (
AnsibleK8SModule, AnsibleK8SModule,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import ( from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
CoreException, CoreException,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
AUTH_ARG_SPEC,
)
def execute_module(module, client): def execute_module(module, client):

View File

@@ -26,8 +26,8 @@ extends_documentation_fragment:
- kubernetes.core.k8s_auth_options - kubernetes.core.k8s_auth_options
requirements: requirements:
- "python >= 3.9" - "python >= 3.6"
- "kubernetes >= 24.2.0" - "kubernetes >= 12.0.0"
options: options:
namespace: namespace:
@@ -139,18 +139,9 @@ result:
import copy import copy
from ansible.module_utils._text import to_native
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import ( from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
AnsibleModule, AnsibleModule,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
AUTH_ARG_SPEC,
)
from ansible_collections.kubernetes.core.plugins.module_utils.copy import (
K8SCopyFromPod,
K8SCopyToPod,
check_pod,
)
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import ( from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
get_api_client, get_api_client,
) )
@@ -164,6 +155,16 @@ from ansible_collections.kubernetes.core.plugins.module_utils.k8s.service import
K8sService, K8sService,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
AUTH_ARG_SPEC,
)
from ansible_collections.kubernetes.core.plugins.module_utils.copy import (
K8SCopyFromPod,
K8SCopyToPod,
check_pod,
)
from ansible.module_utils._text import to_native
def argspec(): def argspec():
argument_spec = copy.deepcopy(AUTH_ARG_SPEC) argument_spec = copy.deepcopy(AUTH_ARG_SPEC)

View File

@@ -41,21 +41,12 @@ options:
- The name of the node. - The name of the node.
required: true required: true
type: str type: str
pod_selectors:
description:
- Label selector to filter pods on the node.
- This option has effect only when C(state) is set to I(drain).
type: list
elements: str
version_added: 2.5.0
aliases:
- label_selectors
delete_options: delete_options:
type: dict type: dict
default: {}
description: description:
- Specify options to delete pods. - Specify options to delete pods.
- This option has effect only when C(state) is set to I(drain). - This option has effect only when C(state) is set to I(drain).
default: {}
suboptions: suboptions:
terminate_grace_period: terminate_grace_period:
description: description:
@@ -97,8 +88,8 @@ options:
type: int type: int
requirements: requirements:
- python >= 3.9 - python >= 3.6
- kubernetes >= 24.2.0 - kubernetes >= 12.0.0
""" """
EXAMPLES = r""" EXAMPLES = r"""
@@ -124,14 +115,6 @@ EXAMPLES = r"""
kubernetes.core.k8s_drain: kubernetes.core.k8s_drain:
state: cordon state: cordon
name: foo name: foo
- name: Drain node "foo" using label selector to filter the list of pods to be drained.
kubernetes.core.k8s_drain:
state: drain
name: foo
pod_selectors:
- 'app!=csi-attacher'
- 'app!=csi-provisioner'
""" """
RETURN = r""" RETURN = r"""
@@ -145,9 +128,8 @@ result:
import copy import copy
import time import time
import traceback import traceback
from datetime import datetime
from ansible.module_utils._text import to_native from datetime import datetime
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import ( from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
AnsibleModule, AnsibleModule,
) )
@@ -164,10 +146,12 @@ from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions imp
CoreException, CoreException,
) )
from ansible.module_utils._text import to_native
try: try:
from kubernetes.client.api import core_v1_api from kubernetes.client.api import core_v1_api
from kubernetes.client.exceptions import ApiException
from kubernetes.client.models import V1DeleteOptions, V1ObjectMeta from kubernetes.client.models import V1DeleteOptions, V1ObjectMeta
from kubernetes.client.exceptions import ApiException
except ImportError: except ImportError:
# ImportError are managed by the common module already. # ImportError are managed by the common module already.
pass pass
@@ -344,17 +328,6 @@ class K8sDrainAnsible(object):
) )
) )
def list_pods(self):
params = {
"field_selector": "spec.nodeName={name}".format(
name=self._module.params.get("name")
)
}
pod_selectors = self._module.params.get("pod_selectors")
if pod_selectors:
params["label_selector"] = ",".join(pod_selectors)
return self._api_instance.list_pod_for_all_namespaces(**params)
def delete_or_evict_pods(self, node_unschedulable): def delete_or_evict_pods(self, node_unschedulable):
# Mark node as unschedulable # Mark node as unschedulable
result = [] result = []
@@ -377,7 +350,12 @@ class K8sDrainAnsible(object):
self.patch_node(unschedulable=False) self.patch_node(unschedulable=False)
try: try:
pod_list = self.list_pods() field_selector = "spec.nodeName={name}".format(
name=self._module.params.get("name")
)
pod_list = self._api_instance.list_pod_for_all_namespaces(
field_selector=field_selector
)
# Filter pods # Filter pods
force = self._drain_options.get("force", False) force = self._drain_options.get("force", False)
ignore_daemonset = self._drain_options.get("ignore_daemonsets", False) ignore_daemonset = self._drain_options.get("ignore_daemonsets", False)
@@ -428,6 +406,7 @@ class K8sDrainAnsible(object):
return dict(result=" ".join(result)) return dict(result=" ".join(result))
def patch_node(self, unschedulable): def patch_node(self, unschedulable):
body = {"spec": {"unschedulable": unschedulable}} body = {"spec": {"unschedulable": unschedulable}}
try: try:
self._api_instance.patch_node( self._api_instance.patch_node(
@@ -439,6 +418,7 @@ class K8sDrainAnsible(object):
) )
def execute_module(self): def execute_module(self):
state = self._module.params.get("state") state = self._module.params.get("state")
name = self._module.params.get("name") name = self._module.params.get("name")
try: try:
@@ -506,11 +486,6 @@ def argspec():
wait_sleep=dict(type="int", default=5), wait_sleep=dict(type="int", default=5),
), ),
), ),
pod_selectors=dict(
type="list",
elements="str",
aliases=["label_selectors"],
),
) )
) )
return argument_spec return argument_spec

View File

@@ -26,8 +26,8 @@ extends_documentation_fragment:
- kubernetes.core.k8s_auth_options - kubernetes.core.k8s_auth_options
requirements: requirements:
- "python >= 3.9" - "python >= 3.6"
- "kubernetes >= 24.2.0" - "kubernetes >= 12.0.0"
- "PyYAML >= 3.11" - "PyYAML >= 3.11"
notes: notes:
@@ -131,27 +131,27 @@ except ImportError:
# ImportError are managed by the common module already. # ImportError are managed by the common module already.
pass pass
from ansible.module_utils._text import to_native
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import ( from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
AnsibleModule, AnsibleModule,
) )
from ansible.module_utils._text import to_native
from ansible_collections.kubernetes.core.plugins.module_utils.common import ( from ansible_collections.kubernetes.core.plugins.module_utils.common import (
AUTH_ARG_SPEC, AUTH_ARG_SPEC,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
get_api_client,
)
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import ( from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import (
AnsibleK8SModule, AnsibleK8SModule,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
get_api_client,
)
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import ( from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
CoreException, CoreException,
) )
try: try:
from kubernetes.client.apis import core_v1_api from kubernetes.client.apis import core_v1_api
from kubernetes.client.exceptions import ApiException
from kubernetes.stream import stream from kubernetes.stream import stream
from kubernetes.client.exceptions import ApiException
except ImportError: except ImportError:
# ImportError are managed by the common module already. # ImportError are managed by the common module already.
pass pass

View File

@@ -44,14 +44,6 @@ options:
type: list type: list
elements: str elements: str
default: [] default: []
hidden_fields:
description:
- Hide fields matching any of the field definitions in the result
- An example might be C(hidden_fields=[metadata.managedFields])
- Only field definitions that don't reference list items are supported (so V(spec.containers[0]) would not work)
type: list
elements: str
version_added: 2.5.0
extends_documentation_fragment: extends_documentation_fragment:
- kubernetes.core.k8s_auth_options - kubernetes.core.k8s_auth_options
@@ -59,8 +51,8 @@ extends_documentation_fragment:
- kubernetes.core.k8s_wait_options - kubernetes.core.k8s_wait_options
requirements: requirements:
- "python >= 3.9" - "python >= 3.6"
- "kubernetes >= 24.2.0" - "kubernetes >= 12.0.0"
- "PyYAML >= 3.11" - "PyYAML >= 3.11"
""" """
@@ -165,12 +157,12 @@ from ansible_collections.kubernetes.core.plugins.module_utils.args_common import
AUTH_ARG_SPEC, AUTH_ARG_SPEC,
WAIT_ARG_SPEC, WAIT_ARG_SPEC,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
get_api_client,
)
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import ( from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import (
AnsibleK8SModule, AnsibleK8SModule,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
get_api_client,
)
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import ( from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
CoreException, CoreException,
) )
@@ -191,7 +183,6 @@ def execute_module(module, svc):
wait_sleep=module.params["wait_sleep"], wait_sleep=module.params["wait_sleep"],
wait_timeout=module.params["wait_timeout"], wait_timeout=module.params["wait_timeout"],
condition=module.params["wait_condition"], condition=module.params["wait_condition"],
hidden_fields=module.params["hidden_fields"],
) )
module.exit_json(changed=False, **facts) module.exit_json(changed=False, **facts)
@@ -207,7 +198,6 @@ def argspec():
namespace=dict(), namespace=dict(),
label_selectors=dict(type="list", elements="str", default=[]), label_selectors=dict(type="list", elements="str", default=[]),
field_selectors=dict(type="list", elements="str", default=[]), field_selectors=dict(type="list", elements="str", default=[]),
hidden_fields=dict(type="list", elements="str"),
) )
) )
return args return args

View File

@@ -62,8 +62,8 @@ extends_documentation_fragment:
- kubernetes.core.k8s_wait_options - kubernetes.core.k8s_wait_options
requirements: requirements:
- "python >= 3.9" - "python >= 3.6"
- "kubernetes >= 24.2.0" - "kubernetes >= 12.0.0"
- "PyYAML >= 3.11" - "PyYAML >= 3.11"
- "jsonpatch" - "jsonpatch"
""" """
@@ -127,8 +127,8 @@ error:
import copy import copy
import traceback import traceback
from ansible.module_utils._text import to_native
from ansible.module_utils.basic import missing_required_lib from ansible.module_utils.basic import missing_required_lib
from ansible.module_utils._text import to_native
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import ( from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
AnsibleModule, AnsibleModule,
) )
@@ -152,6 +152,7 @@ from ansible_collections.kubernetes.core.plugins.module_utils.k8s.waiter import
get_waiter, get_waiter,
) )
try: try:
from kubernetes.dynamic.exceptions import DynamicApiError from kubernetes.dynamic.exceptions import DynamicApiError
except ImportError: except ImportError:

View File

@@ -83,8 +83,8 @@ options:
version_added: '2.4.0' version_added: '2.4.0'
requirements: requirements:
- "python >= 3.9" - "python >= 3.6"
- "kubernetes >= 24.2.0" - "kubernetes >= 12.0.0"
- "PyYAML >= 3.11" - "PyYAML >= 3.11"
""" """

View File

@@ -34,8 +34,8 @@ extends_documentation_fragment:
- kubernetes.core.k8s_auth_options - kubernetes.core.k8s_auth_options
- kubernetes.core.k8s_name_options - kubernetes.core.k8s_name_options
requirements: requirements:
- "python >= 3.9" - "python >= 3.6"
- "kubernetes >= 24.2.0" - "kubernetes >= 12.0.0"
- "PyYAML >= 3.11" - "PyYAML >= 3.11"
""" """

View File

@@ -6,6 +6,7 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
@@ -45,8 +46,8 @@ options:
version_added: 2.0.0 version_added: 2.0.0
requirements: requirements:
- "python >= 3.9" - "python >= 3.6"
- "kubernetes >= 24.2.0" - "kubernetes >= 12.0.0"
- "PyYAML >= 3.11" - "PyYAML >= 3.11"
""" """
@@ -150,13 +151,14 @@ except ImportError:
pass pass
from ansible.module_utils._text import to_native from ansible.module_utils._text import to_native
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import ( from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
AnsibleModule, AnsibleModule,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import ( from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
AUTH_ARG_SPEC, AUTH_ARG_SPEC,
NAME_ARG_SPEC,
RESOURCE_ARG_SPEC, RESOURCE_ARG_SPEC,
NAME_ARG_SPEC,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import ( from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
get_api_client, get_api_client,
@@ -168,15 +170,15 @@ from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions imp
CoreException, CoreException,
ResourceTimeout, ResourceTimeout,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.resource import (
create_definitions,
)
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.service import ( from ansible_collections.kubernetes.core.plugins.module_utils.k8s.service import (
diff_objects, diff_objects,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.waiter import ( from ansible_collections.kubernetes.core.plugins.module_utils.k8s.waiter import (
get_waiter, get_waiter,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.resource import (
create_definitions,
)
SCALE_ARG_SPEC = { SCALE_ARG_SPEC = {
"replicas": {"type": "int", "required": True}, "replicas": {"type": "int", "required": True},
@@ -389,7 +391,7 @@ def scale(
namespace=namespace, namespace=namespace,
) )
if not success: if not success:
raise ResourceTimeout("Resource scaling timed out", result) raise ResourceTimeout("Resource scaling timed out", **result)
match, diffs = diff_objects(existing.to_dict(), result["result"]) match, diffs = diff_objects(existing.to_dict(), result["result"])
result["changed"] = not match result["changed"] = not match

View File

@@ -83,8 +83,8 @@ options:
type: bool type: bool
requirements: requirements:
- python >= 3.9 - python >= 3.6
- kubernetes >= 24.2.0 - kubernetes >= 12.0.0
""" """
EXAMPLES = r""" EXAMPLES = r"""
@@ -143,6 +143,7 @@ result:
""" """
import copy import copy
from collections import defaultdict from collections import defaultdict
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import ( from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
@@ -153,24 +154,25 @@ from ansible_collections.kubernetes.core.plugins.module_utils.args_common import
COMMON_ARG_SPEC, COMMON_ARG_SPEC,
RESOURCE_ARG_SPEC, RESOURCE_ARG_SPEC,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
get_api_client,
)
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import ( from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import (
AnsibleK8SModule, AnsibleK8SModule,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
get_api_client,
)
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import ( from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
CoreException, CoreException,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.service import (
K8sService,
)
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.resource import ( from ansible_collections.kubernetes.core.plugins.module_utils.k8s.resource import (
create_definitions, create_definitions,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.runner import ( from ansible_collections.kubernetes.core.plugins.module_utils.k8s.runner import (
perform_action, perform_action,
) )
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.service import (
K8sService,
)
SERVICE_ARG_SPEC = { SERVICE_ARG_SPEC = {
"apply": {"type": "bool", "default": False}, "apply": {"type": "bool", "default": False},

View File

@@ -60,8 +60,8 @@ options:
default: false default: false
type: bool type: bool
requirements: requirements:
- python >= 3.9 - python >= 3.6
- kubernetes >= 24.2.0 - kubernetes >= 12.0.0
""" """
EXAMPLES = r""" EXAMPLES = r"""
@@ -127,6 +127,7 @@ result:
import copy import copy
from ansible.module_utils._text import to_native from ansible.module_utils._text import to_native
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import ( from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
AnsibleModule, AnsibleModule,
) )

View File

@@ -1,3 +1,3 @@
kubernetes>=24.2.0 kubernetes>=12.0.0
requests-oauthlib requests-oauthlib
jsonpatch jsonpatch

View File

@@ -24,5 +24,3 @@ test_namespace:
- "helm-local-path-003" - "helm-local-path-003"
- "helm-from-repository" - "helm-from-repository"
- "helm-from-url" - "helm-from-url"
- "helm-reuse-values"
- "helm-chart-with-space-into-name"

View File

@@ -1,130 +0,0 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2023, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
DOCUMENTATION = r"""
---
module: helm_test_pending
short_description: created pending-install release
author:
- Aubin Bikouo (@abikouo)
requirements:
- "helm (https://github.com/helm/helm/releases)"
description:
- This module is used to create a pending install release for integration testing
- The scope of this module is the integration testing of the kubernetes.core collection only.
options:
binary_path:
description:
- The path of a helm binary to use.
required: true
type: path
chart_ref:
description:
- chart reference on chart repository (e.g. my-repo/my-chart-ref)
required: true
type: str
chart_release:
description:
- Release name to manage.
required: true
type: str
chart_release_namespace:
description:
- Kubernetes namespace where the chart should be installed.
required: true
type: str
"""
EXAMPLES = r"""
"""
RETURN = r"""
"""
import json
import subprocess
import time
from ansible.module_utils.basic import AnsibleModule
class HelmReleaseNotFoundError(Exception):
def __init__(self, message):
super().__init__(message)
def create_pending_install_release(helm_binary, chart_ref, chart_release, namespace):
# create pending-install release
command = [
helm_binary,
"install",
chart_release,
chart_ref,
"--namespace",
namespace,
"--wait",
]
proc = subprocess.Popen(command)
time.sleep(2)
proc.kill()
# ensure release status is pending-install
command = [
helm_binary,
"list",
"--all",
"--output=json",
"--namespace",
namespace,
"--filter",
chart_release,
]
cmd = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = cmd.communicate()
data = json.loads(out)
if not data:
error = "Release %s not found." % chart_release
raise HelmReleaseNotFoundError(message=error)
return data[0]["status"] == "pending-install", data[0]["status"]
def main():
module = AnsibleModule(
argument_spec=dict(
binary_path=dict(type="path", required=True),
chart_ref=dict(type="str", required=True),
chart_release=dict(type="str", required=True),
chart_release_namespace=dict(type="str", required=True),
),
)
params = dict(
helm_binary=module.params.get("binary_path"),
chart_release=module.params.get("chart_release"),
chart_ref=module.params.get("chart_ref"),
namespace=module.params.get("chart_release_namespace"),
)
try:
result, status = create_pending_install_release(**params)
if not result:
module.fail_json(
msg="unable to create pending-install release, current status is %s"
% status
)
module.exit_json(changed=True, msg="Release created with status '%s'" % status)
except HelmReleaseNotFoundError as err:
module.fail_json(
msg="Error while trying to create pending-install release due to '%s'" % err
)
if __name__ == "__main__":
main()

View File

@@ -52,12 +52,12 @@ result:
""" """
import re import re
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.kubernetes.core.plugins.module_utils.version import ( from ansible_collections.kubernetes.core.plugins.module_utils.version import (
LooseVersion, LooseVersion,
) )
from ansible.module_utils.basic import AnsibleModule
def main(): def main():
module = AnsibleModule( module = AnsibleModule(

View File

@@ -1,7 +0,0 @@
---
- connection: local
gather_facts: true
hosts: localhost
roles:
- helm

View File

@@ -1,5 +0,0 @@
#!/usr/bin/env bash
set -eux
export ANSIBLE_CALLBACKS_ENABLED=profile_tasks
export ANSIBLE_ROLES_PATH=../
ansible-playbook playbook.yaml "$@"

View File

@@ -25,18 +25,12 @@
- from_repository - from_repository
- from_url - from_url
- name: test helm upgrade with reuse_values
include_tasks: test_helm_reuse_values.yml
- name: test helm dependency update - name: test helm dependency update
include_tasks: test_up_dep.yml include_tasks: test_up_dep.yml
- name: Test helm uninstall - name: Test helm uninstall
include_tasks: test_helm_uninstall.yml include_tasks: test_helm_uninstall.yml
- name: Test helm install with chart name containing space
include_tasks: test_helm_with_space_into_chart_name.yml
# https://github.com/ansible-collections/community.kubernetes/issues/296 # https://github.com/ansible-collections/community.kubernetes/issues/296
- name: Test Skip CRDS feature in helm chart install - name: Test Skip CRDS feature in helm chart install
include_tasks: test_crds.yml include_tasks: test_crds.yml

View File

@@ -1,75 +0,0 @@
---
- 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

View File

@@ -7,7 +7,6 @@
- vars: - vars:
chart_source: "https://github.com/kubernetes/kube-state-metrics/releases/download/kube-state-metrics-helm-chart-2.13.3/kube-state-metrics-2.13.3.tgz" chart_source: "https://github.com/kubernetes/kube-state-metrics/releases/download/kube-state-metrics-helm-chart-2.13.3/kube-state-metrics-2.13.3.tgz"
chart_name: "test-wait-uninstall" chart_name: "test-wait-uninstall"
chart_name_pending: "test-uninstall-pending-release"
helm_namespace: "{{ test_namespace[1] }}" helm_namespace: "{{ test_namespace[1] }}"
block: block:
@@ -65,36 +64,6 @@
wait: yes wait: yes
register: uninstall register: uninstall
# Test uninstall chart release with 'pending-install' status
- name: Create chart release with 'pending-install' status
helm_test_pending:
binary_path: "{{ helm_binary }}"
chart_ref: "{{ chart_source }}"
chart_release: "{{ chart_name_pending }}"
chart_release_namespace: "{{ helm_namespace }}"
- name: Uninstall chart release with 'pending-install' status
helm:
binary_path: "{{ helm_binary }}"
release_name: "{{ chart_name_pending }}"
namespace: "{{ helm_namespace }}"
release_state: absent
register: _uninstall
- name: Get Helm release details
helm_info:
binary_path: "{{ helm_binary }}"
release_namespace: "{{ helm_namespace }}"
release_state: pending
release_name: "{{ chart_name_pending }}"
register: _info
- name: assert release does not exist anymore
assert:
that:
- _uninstall is changed
- _info.status is undefined
always: always:
- name: Delete temp directory - name: Delete temp directory
file: file:

View File

@@ -1,58 +0,0 @@
---
- name: Create test directory
ansible.builtin.tempfile:
state: directory
suffix: .helm
register: test_dir
- name: Test helm using directory with space
vars:
helm_dir: "{{ test_dir.path }}/Deploy Chart"
helm_namespace: "{{ test_namespace[10] }}"
chart_release_name: "deploy-chart-with-space-into-name"
helm_local_src: "test-chart"
block:
- name: Copy helm file into destination
ansible.builtin.copy:
src: "{{ helm_local_src }}"
dest: "{{ helm_dir }}"
- name: Install chart from local source with Space into name
helm:
binary_path: "{{ helm_binary }}"
name: "{{ chart_release_name }}"
chart_ref: "{{ helm_dir }}/{{ helm_local_src | basename }}"
namespace: "{{ helm_namespace }}"
create_namespace: true
register: install_chart
- name: Assert that chart is installed
assert:
that:
- install_chart is changed
- install_chart.status.status | lower == 'deployed'
- name: Check helm_info content
helm_info:
binary_path: "{{ helm_binary }}"
name: "{{ chart_release_name }}"
namespace: "{{ helm_namespace }}"
register: chart_info
- name: Assert that Chart is installed (using helm_info)
assert:
that:
- chart_info.status.status | lower == 'deployed'
always:
- name: Delete temporary directory
ansible.builtin.file:
state: absent
name: "{{ test_dir.path }}"
- name: Remove helm namespace
k8s:
api_version: v1
kind: Namespace
name: "{{ helm_namespace }}"
state: absent

View File

@@ -1,7 +0,0 @@
---
- connection: local
gather_facts: true
hosts: localhost
roles:
- helm_diff

View File

@@ -1,5 +0,0 @@
#!/usr/bin/env bash
set -eux
export ANSIBLE_CALLBACKS_ENABLED=profile_tasks
export ANSIBLE_ROLES_PATH=../
ansible-playbook playbook.yaml "$@"

View File

@@ -1,4 +1,3 @@
--- ---
dependencies: dependencies:
- remove_namespace - remove_namespace
- install_helm

View File

@@ -1,7 +0,0 @@
---
- connection: local
gather_facts: true
hosts: localhost
roles:
- helm_kubeconfig

View File

@@ -1,5 +0,0 @@
#!/usr/bin/env bash
set -eux
export ANSIBLE_CALLBACKS_ENABLED=profile_tasks
export ANSIBLE_ROLES_PATH=../
ansible-playbook playbook.yaml "$@"

View File

@@ -1,6 +1,10 @@
--- ---
- name: Test helm with in-memory kubeconfig - name: Test helm with in-memory kubeconfig
include_tasks: "from_in_memory_kubeconfig.yml" include_tasks: "from_in_memory_kubeconfig.yml"
loop_control:
loop_var: test_helm_version
with_items:
- "v3.10.3"
- name: Test helm with custom kubeconfig and validate_certs=false - name: Test helm with custom kubeconfig and validate_certs=false
include_tasks: "from_kubeconfig_with_validate_certs.yml" include_tasks: "from_kubeconfig_with_validate_certs.yml"
@@ -8,12 +12,10 @@
loop_var: test_helm_version loop_var: test_helm_version
with_items: with_items:
- "v3.10.3" - "v3.10.3"
- "v3.8.2"
- name: Test helm with custom kubeconfig and ca_cert - name: Test helm with custom kubeconfig and ca_cert
include_tasks: "from_kubeconfig_with_cacert.yml" include_tasks: "from_kubeconfig_with_cacert.yml"
loop_control: loop_control:
loop_var: test_helm_version loop_var: test_helm_version
with_items: with_items:
- "v3.5.1" - "v3.10.3"
- "v3.4.2"

View File

@@ -1,7 +0,0 @@
---
- connection: local
gather_facts: true
hosts: localhost
roles:
- helm_plugin

View File

@@ -1,5 +0,0 @@
#!/usr/bin/env bash
set -eux
export ANSIBLE_CALLBACKS_ENABLED=profile_tasks
export ANSIBLE_ROLES_PATH=../
ansible-playbook playbook.yaml "$@"

View File

@@ -1,7 +0,0 @@
---
- connection: local
gather_facts: true
hosts: localhost
roles:
- helm_pull

Some files were not shown because too many files have changed in this diff Show More