Compare commits

6 Commits
2.3.0 ... 2.2.1

Author SHA1 Message Date
Mike Graves
f2d899b939 Release 2.2.1 (#267)
Release 2.2.1

Release 2.2.1

Reviewed-by: Gonéri Le Bouder <goneri@lebouder.net>
Reviewed-by: None <None>
2021-10-19 14:10:21 +00:00
Mike Graves
bc391218a4 common/_wait_for: ensure label_selectors is optional (#239) (#256)
[backport/2.2] common/_wait_for: ensure label_selectors is optional (#239)

Depends-On: ansible/ansible-zuul-jobs#1170
Depends-On: ansible/ansible-zuul-jobs#1169
Depends-On: ansible/ansible-zuul-jobs#1171
common/_wait_for: ensure label_selectors is optional
The label_selectors is a new parameter for _wait_for that was
introduced in #158.
The value is new and it can be set to None to make it optional. It should
not be mandatory a non optional parameter.
Reviewed-by: None 
Reviewed-by: Alina Buzachis 
Reviewed-by: None 
(cherry picked from commit 938f7e1)

Reviewed-by: None <None>
Reviewed-by: Gonéri Le Bouder <goneri@lebouder.net>
Reviewed-by: None <None>
2021-10-15 18:29:21 +00:00
Mike Graves
83b3a1aa39 Use yaml.safe_load in unit tests (#265) (#266)
[backport/2.2] Use yaml.safe_load in unit tests (#265)

Use yaml.safe_load in unit tests
SUMMARY
The function signature in pyyaml 6 for yaml.load changed. Using
safe_load fixes this.
ISSUE TYPE
Bugfix Pull Request
COMPONENT NAME
ADDITIONAL INFORMATION
Reviewed-by: Jill R 
Reviewed-by: None 
Reviewed-by: Gonéri Le Bouder goneri@lebouder.net
(cherry picked from commit 281ff56)

Reviewed-by: None <None>
Reviewed-by: None <None>
2021-10-15 13:02:29 +00:00
Mike Graves
aa41055503 Fix sanity test - devel drops support for python 2.6 (#251) (#258)
Fix sanity test - devel drops support for python 2.6

SUMMARY

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: None <None>
(cherry picked from commit 8436ad1341)

Co-authored-by: abikouo <79859644+abikouo@users.noreply.github.com>
2021-10-14 10:11:05 -04:00
Mike Graves
256fa58ca8 Remove molecule dependencies (#261) (#263)
Remove molecule dependencies

SUMMARY

Depends-on: ansible-collections/cloud.common#92
Molecule is overwriting the cloud.common dependency installed by zuul,
which is causing issues with the CI job for turbo mode. We still need to
find a way to test against the latest released version of cloud.common.

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Gonéri Le Bouder <goneri@lebouder.net>
Reviewed-by: None <None>
(cherry picked from commit ff43353de6)
2021-10-14 08:39:16 -04:00
Mike Graves
70db517265 Copy ignore-2.12.txt to ignore-2.13.txt (#247) (#257)
Copy ignore-2.12.txt to ignore-2.13.txt

SUMMARY
Relates to ansible-collections/overview#45 (comment)

Reviewed-by: Alina Buzachis <None>
Reviewed-by: None <None>
(cherry picked from commit 45ba8b1a0d)

Co-authored-by: Andrew Klychkov <aklychko@redhat.com>
2021-10-08 14:09:11 -04:00
283 changed files with 4654 additions and 10096 deletions

View File

@@ -1,4 +0,0 @@
---
backport_branch_prefix: patchback/backports/
backport_label_prefix: backport-
target_branch_prefix: stable-

6
.gitignore vendored
View File

@@ -15,8 +15,4 @@ tests/integration/cloud-config-*
.cache .cache
# Helm charts # Helm charts
tests/integration/*-chart-*.tgz molecule/default/*-chart-*.tgz
# ansible-test generated file
tests/integration/inventory
tests/integration/*-*.yml

View File

@@ -5,53 +5,13 @@ Kubernetes Collection Release Notes
.. contents:: Topics .. contents:: Topics
v2.3.0 v2.2.1
====== ======
Minor Changes
-------------
- add support for dry run with kubernetes client version >=18.20 (https://github.com/ansible-collections/kubernetes.core/pull/245).
- fixed module_defaults by removing routing hacks from runtime.yml (https://github.com/ansible-collections/kubernetes.core/pull/347).
- helm - add support for timeout cli parameter to allow setting Helm timeout independent of wait (https://github.com/ansible-collections/kubernetes.core/issues/67).
- helm - add support for wait parameter for helm uninstall command. (https://github.com/ansible-collections/kubernetes/core/issues/33).
- helm - support repo location for helm diff (https://github.com/ansible-collections/kubernetes.core/issues/174).
- helm - when ansible is executed in check mode, return the diff between what's deployed and what will be deployed.
- helm_info - add release state as a module argument (https://github.com/ansible-collections/kubernetes.core/issues/377).
- helm_plugin - Add plugin_version parameter to the helm_plugin module (https://github.com/ansible-collections/kubernetes.core/issues/157).
- helm_plugin - Add support for helm plugin update using state=update.
- helm_repository - add support for pass-credentials cli parameter (https://github.com/ansible-collections/kubernetes.core/pull/282).
- helm_repository - added support for ``host``, ``api_key``, ``validate_certs``, and ``ca_cert``.
- helm_template - add show_only and release_namespace as module arguments (https://github.com/ansible-collections/kubernetes.core/issues/313).
- k8s - add no_proxy support to k8s* (https://github.com/ansible-collections/kubernetes.core/pull/272).
- k8s - add support for server_side_apply. (https://github.com/ansible-collections/kubernetes.core/issues/87).
- k8s - add support for user impersonation. (https://github.com/ansible-collections/kubernetes/core/issues/40).
- k8s - allow resource definition using metadata.generateName (https://github.com/ansible-collections/kubernetes.core/issues/35).
- k8s lookup plugin - Enable turbo mode via environment variable (https://github.com/ansible-collections/kubernetes.core/issues/291).
- k8s_drain - Adds ``delete_emptydir_data`` option to ``k8s_drain.delete_options`` to evict pods with an ``emptyDir`` volume attached (https://github.com/ansible-collections/kubernetes.core/pull/322).
- k8s_exec - select first container from the pod if none specified (https://github.com/ansible-collections/kubernetes.core/issues/358).
- k8s_rollback - add support for check_mode. (https://github.com/ansible-collections/kubernetes/core/issues/243).
- k8s_scale - add support for check_mode. (https://github.com/ansible-collections/kubernetes/core/issues/244).
- kubectl - wait for dd command to complete before proceeding (https://github.com/ansible-collections/kubernetes.core/pull/321).
Bugfixes Bugfixes
-------- --------
- Various modules and plugins - use vendored version of ``distutils.version`` instead of the deprecated Python standard library ``distutils`` (https://github.com/ansible-collections/kubernetes.core/pull/314).
- common - Ensure the label_selectors parameter of _wait_for method is optional. - common - Ensure the label_selectors parameter of _wait_for method is optional.
- helm_template - evaluate release_values after values_files, insuring highest precedence (now same behavior as in helm module). (https://github.com/ansible-collections/kubernetes.core/pull/348)
- import exception from ``kubernetes.client.rest``.
- k8s_drain - fix error caused by accessing an undefined variable when pods have local storage (https://github.com/ansible-collections/kubernetes.core/issues/292).
- k8s_info - don't wait on empty List resources (https://github.com/ansible-collections/kubernetes.core/pull/253).
- k8s_scale - fix waiting on statefulset when scaled down to 0 replicas (https://github.com/ansible-collections/kubernetes.core/issues/203).
- module_utils.common - change default opening mode to read-bytes to avoid bad interpretation of non ascii characters and strings, often present in 3rd party manifests.
- remove binary file from k8s_cp test suite (https://github.com/ansible-collections/kubernetes.core/pull/298).
- use resource prefix when finding resource and apiVersion is v1 (https://github.com/ansible-collections/kubernetes.core/issues/351).
New Modules
-----------
- k8s_taint - Taint a node in a Kubernetes/OpenShift cluster
v2.2.0 v2.2.0
====== ======

View File

@@ -1,5 +1,5 @@
# Also needs to be updated in galaxy.yml # Also needs to be updated in galaxy.yml
VERSION = 2.3.0 VERSION = 2.2.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]))'`
@@ -22,7 +22,10 @@ test-sanity:
ansible-test sanity --docker -v --color --python $(PYTHON_VERSION) $(?TEST_ARGS) ansible-test sanity --docker -v --color --python $(PYTHON_VERSION) $(?TEST_ARGS)
test-integration: test-integration:
ansible-test integration --diff --no-temp-workdir --color --skip-tags False --retry-on-error --continue-on-error --python $(PYTHON_VERSION) -v --coverage $(?TEST_ARGS) ansible-test integration --docker -v --color --retry-on-error --python $(PYTHON_VERSION) --continue-on-error --diff --coverage $(?TEST_ARGS)
test-molecule:
molecule test
test-unit: test-unit:
ansible-test units --docker -v --color --python $(PYTHON_VERSION) $(?TEST_ARGS) ansible-test units --docker -v --color --python $(PYTHON_VERSION) $(?TEST_ARGS)

View File

@@ -22,10 +22,6 @@ PEP440 is the schema used to describe the versions of Ansible.
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
This collection supports Kubernetes versions >=1.19.
## Included content ## Included content
Click on the name of a plugin or module to view that content's documentation: Click on the name of a plugin or module to view that content's documentation:
@@ -72,7 +68,6 @@ Name | Description
[kubernetes.core.k8s_rollback](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_rollback_module.rst)|Rollback Kubernetes (K8S) Deployments and DaemonSets [kubernetes.core.k8s_rollback](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_rollback_module.rst)|Rollback Kubernetes (K8S) Deployments and DaemonSets
[kubernetes.core.k8s_scale](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_scale_module.rst)|Set a new size for a Deployment, ReplicaSet, Replication Controller, or Job. [kubernetes.core.k8s_scale](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_scale_module.rst)|Set a new size for a Deployment, ReplicaSet, Replication Controller, or Job.
[kubernetes.core.k8s_service](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_service_module.rst)|Manage Services on Kubernetes [kubernetes.core.k8s_service](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_service_module.rst)|Manage Services on Kubernetes
[kubernetes.core.k8s_taint](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_taint_module.rst)|Taint a node in a Kubernetes/OpenShift cluster
<!--end collection content--> <!--end collection content-->
@@ -90,7 +85,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: 2.3.0 version: 2.2.1
``` ```
### Installing the Kubernetes Python Library ### Installing the Kubernetes Python Library
@@ -170,7 +165,7 @@ For documentation on how to use individual modules and other content included in
## Ansible Turbo mode Tech Preview ## Ansible Turbo mode Tech Preview
The ``kubernetes.core`` collection supports Ansible Turbo mode as a tech preview via the ``cloud.common`` collection. By default, this feature is disabled. To enable Turbo mode for modules, set the environment variable `ENABLE_TURBO_MODE=1` on the managed node. For example: The ``kubernetes.core`` collection supports Ansible Turbo mode as a tech preview via the ``cloud.common`` collection. By default, this feature is disabled. To enable Turbo mode, set the environment variable `ENABLE_TURBO_MODE=1` on the managed node. For example:
```yaml ```yaml
--- ---
@@ -181,9 +176,6 @@ The ``kubernetes.core`` collection supports Ansible Turbo mode as a tech preview
... ...
``` ```
To enable Turbo mode for k8s lookup plugin, set the environment variable `ENABLE_TURBO_MODE=1` on the managed node. This is not working when
defined in the playbook using `environment` keyword as above, you must set it using `export ENABLE_TURBO_MODE=1`.
Please read more about Ansible Turbo mode - [here](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/ansible_turbo_mode.rst). Please read more about Ansible Turbo mode - [here](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/ansible_turbo_mode.rst).
## Testing and Development ## Testing and Development

View File

@@ -1,2 +1 @@
kubernetes-client [platform:fedora] kubernetes-client [platform:fedora]
openshift-clients [platform:rhel-8]

View File

@@ -486,85 +486,11 @@ releases:
name: kustomize name: kustomize
namespace: null namespace: null
release_date: '2021-09-15' release_date: '2021-09-15'
2.3.0: 2.2.1:
changes: changes:
bugfixes: bugfixes:
- Various modules and plugins - use vendored version of ``distutils.version``
instead of the deprecated Python standard library ``distutils`` (https://github.com/ansible-collections/kubernetes.core/pull/314).
- common - Ensure the label_selectors parameter of _wait_for method is optional. - common - Ensure the label_selectors parameter of _wait_for method is optional.
- helm_template - evaluate release_values after values_files, insuring highest
precedence (now same behavior as in helm module). (https://github.com/ansible-collections/kubernetes.core/pull/348)
- import exception from ``kubernetes.client.rest``.
- k8s_drain - fix error caused by accessing an undefined variable when pods
have local storage (https://github.com/ansible-collections/kubernetes.core/issues/292).
- k8s_info - don't wait on empty List resources (https://github.com/ansible-collections/kubernetes.core/pull/253).
- k8s_scale - fix waiting on statefulset when scaled down to 0 replicas (https://github.com/ansible-collections/kubernetes.core/issues/203).
- module_utils.common - change default opening mode to read-bytes to avoid bad
interpretation of non ascii characters and strings, often present in 3rd party
manifests.
- remove binary file from k8s_cp test suite (https://github.com/ansible-collections/kubernetes.core/pull/298).
- use resource prefix when finding resource and apiVersion is v1 (https://github.com/ansible-collections/kubernetes.core/issues/351).
minor_changes:
- add support for dry run with kubernetes client version >=18.20 (https://github.com/ansible-collections/kubernetes.core/pull/245).
- fixed module_defaults by removing routing hacks from runtime.yml (https://github.com/ansible-collections/kubernetes.core/pull/347).
- helm - add support for timeout cli parameter to allow setting Helm timeout
independent of wait (https://github.com/ansible-collections/kubernetes.core/issues/67).
- helm - add support for wait parameter for helm uninstall command. (https://github.com/ansible-collections/kubernetes/core/issues/33).
- helm - support repo location for helm diff (https://github.com/ansible-collections/kubernetes.core/issues/174).
- helm - when ansible is executed in check mode, return the diff between what's
deployed and what will be deployed.
- helm_info - add release state as a module argument (https://github.com/ansible-collections/kubernetes.core/issues/377).
- helm_plugin - Add plugin_version parameter to the helm_plugin module (https://github.com/ansible-collections/kubernetes.core/issues/157).
- helm_plugin - Add support for helm plugin update using state=update.
- helm_repository - add support for pass-credentials cli parameter (https://github.com/ansible-collections/kubernetes.core/pull/282).
- helm_repository - added support for ``host``, ``api_key``, ``validate_certs``,
and ``ca_cert``.
- helm_template - add show_only and release_namespace as module arguments (https://github.com/ansible-collections/kubernetes.core/issues/313).
- k8s - add no_proxy support to k8s* (https://github.com/ansible-collections/kubernetes.core/pull/272).
- k8s - add support for server_side_apply. (https://github.com/ansible-collections/kubernetes.core/issues/87).
- k8s - add support for user impersonation. (https://github.com/ansible-collections/kubernetes/core/issues/40).
- k8s - allow resource definition using metadata.generateName (https://github.com/ansible-collections/kubernetes.core/issues/35).
- k8s lookup plugin - Enable turbo mode via environment variable (https://github.com/ansible-collections/kubernetes.core/issues/291).
- k8s_drain - Adds ``delete_emptydir_data`` option to ``k8s_drain.delete_options``
to evict pods with an ``emptyDir`` volume attached (https://github.com/ansible-collections/kubernetes.core/pull/322).
- k8s_exec - select first container from the pod if none specified (https://github.com/ansible-collections/kubernetes.core/issues/358).
- k8s_rollback - add support for check_mode. (https://github.com/ansible-collections/kubernetes/core/issues/243).
- k8s_scale - add support for check_mode. (https://github.com/ansible-collections/kubernetes/core/issues/244).
- kubectl - wait for dd command to complete before proceeding (https://github.com/ansible-collections/kubernetes.core/pull/321).
fragments: fragments:
- 0-copy_ignore_txt.yml - 0-copy_ignore_txt.yml
- 226-add-version-parameter-to-helm_plugin.yml
- 231-helm-add-timeout-parameter.yaml
- 238-helm-add-support-for-helm-uninstall-wait.yaml
- 238-k8s-add-support-for-generate_name.yml
- 245-add-dry-run.yaml
- 250-k8s-add-support-for-impersonation.yaml
- 253-dont-wait-on-list-resources.yaml
- 255-k8s_scale-k8s_rollback-add-support-for-check_mode.yml
- 260-k8s-add-support-for-server_side_apply.yml
- 272-k8s-add-support-no_proxy.yaml
- 282-helm-repository-add-pass-credentials.yaml
- 290-returns-diff-in-check-mode.yaml
- 295-fix-k8s-drain-variable-declaration.yaml
- 298-remove-binary-file.yaml
- 308-fix-for-common-non-ascii-characters-in-resources.yaml
- 313-helm-template-add-support-for-show-only-and-release-namespace.yml
- 321-kubectl_sleep.yml
- 322-Add-delete_emptydir_data-to-drain-delete_options.yaml
- 335-k8s-lookup-add-support-for-turbo-mode.yml
- 347-routing.yml
- 348-helm_template-fix-precedence-of-release-values-over-values-files.yaml
- 358-k8s_exec.yml
- 364-use-resource-prefix.yaml
- 377-helm-info-state.yml
- 389-helm-add-support-chart_repo_url-on-helm_diff.yml
- 391-fix-statefulset-wait.yaml
- _wait_for_label_selector_optional.yaml - _wait_for_label_selector_optional.yaml
- disutils.version.yml release_date: '2021-10-18'
- exception.yml
- helm_repository.yml
modules:
- description: Taint a node in a Kubernetes/OpenShift cluster
name: k8s_taint
namespace: ''
release_date: '2022-03-11'

View File

@@ -54,7 +54,7 @@ In this use case / example, we will create a Pod in the given Kubernetes Cluster
- kubernetes.core - kubernetes.core
tasks: tasks:
- name: Create a pod - name: Create a pod
kubernetes.core.k8s: k8s:
state: present state: present
definition: definition:
apiVersion: v1 apiVersion: v1

View File

@@ -172,31 +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>
</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>
@@ -229,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

View File

@@ -413,24 +413,6 @@ Parameters
<div>Skip custom resource definitions when installing or upgrading.</div> <div>Skip custom resource definitions when installing or upgrading.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>timeout</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>A Go duration (described here <em>https://pkg.go.dev/time#ParseDuration</em>) value to wait for Kubernetes commands to complete. This defaults to 5m0s.</div>
<div>similar to <code>wait_timeout</code> but does not required <code>wait</code> to be activated.</div>
<div>Mutually exclusive with <code>wait_timeout</code>.</div>
</td>
</tr>
<tr> <tr>
<td colspan="1"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -447,7 +429,7 @@ Parameters
</ul> </ul>
</td> </td>
<td> <td>
<div>Run <code>helm repo update</code> before the operation. Can be run as part of the package installation or as a separate step (see Examples).</div> <div>Run <code>helm repo update</code> before the operation. Can be run as part of the package installation or as a separate step.</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -508,8 +490,7 @@ Parameters
</ul> </ul>
</td> </td>
<td> <td>
<div>When <em>release_state</em> is set to <code>present</code>, wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment are in a ready state before marking the release as successful.</div> <div>Wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment are in a ready state before marking the release as successful.</div>
<div>When <em>release_state</em> is set to <code>absent</code>, will wait until all the resources are deleted before returning. It will wait for as long as <em>wait_timeout</em>. This feature requires helm&gt;=3.7.0. Added in version 2.3.0.</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -525,19 +506,12 @@ Parameters
</td> </td>
<td> <td>
<div>Timeout when wait option is enabled (helm2 is a number of seconds, helm3 is a duration).</div> <div>Timeout when wait option is enabled (helm2 is a number of seconds, helm3 is a duration).</div>
<div>The use of <em>wait_timeout</em> to wait for kubernetes commands to complete has been deprecated and will be removed after 2022-12-01.</div>
</td> </td>
</tr> </tr>
</table> </table>
<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
@@ -587,13 +561,6 @@ Examples
state: absent state: absent
wait: true wait: true
- name: Separately update the repository cache
kubernetes.core.helm:
name: dummy
namespace: kube-system
state: absent
update_repo_cache: true
# From git # From git
- name: Git clone stable repo on HEAD - name: Git clone stable repo on HEAD
ansible.builtin.git: ansible.builtin.git:

View File

@@ -150,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>
@@ -170,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>
@@ -200,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>
@@ -256,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

@@ -39,22 +39,6 @@ Parameters
<th colspan="1">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>
<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> <tr>
<td colspan="1"> <td colspan="1">
@@ -71,59 +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>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>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>
@@ -211,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

@@ -131,22 +131,6 @@ Parameters
<div>If the directory already exists, it will be overwritten.</div> <div>If the directory already exists, it will be overwritten.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="1">
<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.3.0</div>
</td>
<td>
</td>
<td>
<div>namespace scope for this request.</div>
</td>
</tr>
<tr> <tr>
<td colspan="1"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -164,23 +148,6 @@ Parameters
<div style="font-size: small; color: darkgreen"><br/>aliases: values</div> <div style="font-size: small; color: darkgreen"><br/>aliases: values</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="1">
<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.3.0</div>
</td>
<td>
</td>
<td>
<div>Only show manifests rendered from the given templates.</div>
</td>
</tr>
<tr> <tr>
<td colspan="1"> <td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -246,24 +213,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

@@ -136,41 +136,6 @@ Parameters
<div>Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.</div> <div>Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>impersonate_groups</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>
</td>
<td>
<div>Group(s) to impersonate for the operation.</div>
<div>Can also be specified via K8S_AUTH_IMPERSONATE_GROUPS environment. Example: &#x27;Group1,Group2&#x27;</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>impersonate_user</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>Username to impersonate for the operation.</div>
<div>Can also be specified via K8S_AUTH_IMPERSONATE_USER environment.</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -206,25 +171,6 @@ Parameters
<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

@@ -167,41 +167,6 @@ Parameters
<div>Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.</div> <div>Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>impersonate_groups</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>
</td>
<td>
<div>Group(s) to impersonate for the operation.</div>
<div>Can also be specified via K8S_AUTH_IMPERSONATE_GROUPS environment. Example: &#x27;Group1,Group2&#x27;</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>impersonate_user</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>Username to impersonate for the operation.</div>
<div>Can also be specified via K8S_AUTH_IMPERSONATE_USER environment.</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -271,25 +236,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>

View File

@@ -137,27 +137,6 @@ Parameters
<div>Specify options to delete pods.</div> <div>Specify options to delete pods.</div>
<div>This option has effect only when <code>state</code> is set to <em>drain</em>.</div> <div>This option has effect only when <code>state</code> is set to <em>drain</em>.</div>
</td> </td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>delete_emptydir_data</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>Continue even if there are pods using emptyDir (local data that will be deleted when the node is drained).</div>
</td>
</tr> </tr>
<tr> <tr>
<td class="elbow-placeholder"></td> <td class="elbow-placeholder"></td>
@@ -287,41 +266,6 @@ Parameters
<div>Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.</div> <div>Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>impersonate_groups</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>
</td>
<td>
<div>Group(s) to impersonate for the operation.</div>
<div>Can also be specified via K8S_AUTH_IMPERSONATE_GROUPS environment. Example: &#x27;Group1,Group2&#x27;</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>impersonate_user</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>Username to impersonate for the operation.</div>
<div>Can also be specified via K8S_AUTH_IMPERSONATE_USER environment.</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -354,25 +298,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>

View File

@@ -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>
@@ -167,41 +166,6 @@ Parameters
<div>Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.</div> <div>Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>impersonate_groups</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>
</td>
<td>
<div>Group(s) to impersonate for the operation.</div>
<div>Can also be specified via K8S_AUTH_IMPERSONATE_GROUPS environment. Example: &#x27;Group1,Group2&#x27;</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>impersonate_user</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>Username to impersonate for the operation.</div>
<div>Can also be specified via K8S_AUTH_IMPERSONATE_USER environment.</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -231,26 +195,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>
@@ -305,7 +250,7 @@ Parameters
<td> <td>
</td> </td>
<td> <td>
<div>The pod name.</div> <div>The pod name</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -322,7 +267,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>
@@ -469,13 +414,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

@@ -173,41 +173,6 @@ Parameters
<div>Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.</div> <div>Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>impersonate_groups</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>
</td>
<td>
<div>Group(s) to impersonate for the operation.</div>
<div>Can also be specified via K8S_AUTH_IMPERSONATE_GROUPS environment. Example: &#x27;Group1,Group2&#x27;</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>impersonate_user</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>Username to impersonate for the operation.</div>
<div>Can also be specified via K8S_AUTH_IMPERSONATE_USER environment.</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -295,25 +260,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

@@ -351,8 +351,8 @@ Status
Authors Authors
~~~~~~~ ~~~~~~~
- Chris Houseknecht (@chouseknecht) - Chris Houseknecht <@chouseknecht>
- Fabian von Feilitzsch (@fabianvf) - Fabian von Feilitzsch <@fabianvf>
.. hint:: .. hint::

View File

@@ -155,41 +155,6 @@ Parameters
<div>Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.</div> <div>Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>impersonate_groups</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>
</td>
<td>
<div>Group(s) to impersonate for the operation.</div>
<div>Can also be specified via K8S_AUTH_IMPERSONATE_GROUPS environment. Example: &#x27;Group1,Group2&#x27;</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>impersonate_user</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>Username to impersonate for the operation.</div>
<div>Can also be specified via K8S_AUTH_IMPERSONATE_USER environment.</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -256,25 +221,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>

View File

@@ -174,41 +174,6 @@ Parameters
<div>Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.</div> <div>Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>impersonate_groups</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>
</td>
<td>
<div>Group(s) to impersonate for the operation.</div>
<div>Can also be specified via K8S_AUTH_IMPERSONATE_GROUPS environment. Example: &#x27;Group1,Group2&#x27;</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>impersonate_user</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>Username to impersonate for the operation.</div>
<div>Can also be specified via K8S_AUTH_IMPERSONATE_USER environment.</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -295,25 +260,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

@@ -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

@@ -336,26 +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> <tr>
<td colspan="3"> <td colspan="3">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -371,41 +351,6 @@ Parameters
<div>Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.</div> <div>Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="3">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>impersonate_groups</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>
</td>
<td>
<div>Group(s) to impersonate for the operation.</div>
<div>Can also be specified via K8S_AUTH_IMPERSONATE_GROUPS environment. Example: &#x27;Group1,Group2&#x27;</div>
</td>
</tr>
<tr>
<td colspan="3">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>impersonate_user</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>Username to impersonate for the operation.</div>
<div>Can also be specified via K8S_AUTH_IMPERSONATE_USER environment.</div>
</td>
</tr>
<tr> <tr>
<td colspan="3"> <td colspan="3">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -519,25 +464,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>
@@ -679,63 +605,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>
@@ -750,7 +619,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>Mutually exclusive with <em>template</em> in case of <span class='module'>kubernetes.core.k8s</span> module.</div> <div>Mutually exclusive with <em>template</em> in case of <span class='module'>k8s</span> module.</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -1189,33 +1058,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
Return Values Return Values

View File

@@ -172,41 +172,6 @@ Parameters
<div>Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.</div> <div>Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>impersonate_groups</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>
</td>
<td>
<div>Group(s) to impersonate for the operation.</div>
<div>Can also be specified via K8S_AUTH_IMPERSONATE_GROUPS environment. Example: &#x27;Group1,Group2&#x27;</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>impersonate_user</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>Username to impersonate for the operation.</div>
<div>Can also be specified via K8S_AUTH_IMPERSONATE_USER environment.</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -293,25 +258,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

@@ -189,41 +189,6 @@ Parameters
<div>Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.</div> <div>Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>impersonate_groups</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>
</td>
<td>
<div>Group(s) to impersonate for the operation.</div>
<div>Can also be specified via K8S_AUTH_IMPERSONATE_GROUPS environment. Example: &#x27;Group1,Group2&#x27;</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>impersonate_user</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>Username to impersonate for the operation.</div>
<div>Can also be specified via K8S_AUTH_IMPERSONATE_USER environment.</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -311,25 +276,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>
@@ -516,7 +462,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>Mutually exclusive with <em>template</em> in case of <span class='module'>kubernetes.core.k8s</span> module.</div> <div>Mutually exclusive with <em>template</em> in case of <span class='module'>k8s</span> module.</div>
</td> </td>
</tr> </tr>
<tr> <tr>

View File

@@ -172,41 +172,6 @@ Parameters
<div>Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.</div> <div>Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>impersonate_groups</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>
</td>
<td>
<div>Group(s) to impersonate for the operation.</div>
<div>Can also be specified via K8S_AUTH_IMPERSONATE_GROUPS environment. Example: &#x27;Group1,Group2&#x27;</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>impersonate_user</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>Username to impersonate for the operation.</div>
<div>Can also be specified via K8S_AUTH_IMPERSONATE_USER environment.</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -280,25 +245,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>
@@ -487,7 +433,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>Mutually exclusive with <em>template</em> in case of <span class='module'>kubernetes.core.k8s</span> module.</div> <div>Mutually exclusive with <em>template</em> in case of <span class='module'>k8s</span> module.</div>
</td> </td>
</tr> </tr>
<tr> <tr>

View File

@@ -1,660 +0,0 @@
.. _kubernetes.core.k8s_taint_module:
*************************
kubernetes.core.k8s_taint
*************************
**Taint a node in a Kubernetes/OpenShift cluster**
Version added: 2.3.0
.. contents::
:local:
:depth: 1
Synopsis
--------
- Taint allows a node to refuse Pod to be scheduled unless that Pod has a matching toleration.
- Untaint will remove taints from nodes as needed.
Requirements
------------
The below requirements are needed on the host that executes this module.
- python >= 3.6
- kubernetes >= 12.0.0
Parameters
----------
.. raw:: html
<table border=0 cellpadding=0 class="documentation-table">
<tr>
<th colspan="2">Parameter</th>
<th>Choices/<font color="blue">Defaults</font></th>
<th width="100%">Comments</th>
</tr>
<tr>
<td colspan="2">
<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>
</td>
<td>
</td>
<td>
<div>Token used to authenticate with the API. Can also be specified via K8S_AUTH_API_KEY environment variable.</div>
</td>
</tr>
<tr>
<td colspan="2">
<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>
</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 K8S_AUTH_SSL_CA_CERT environment variable.</div>
<div style="font-size: small; color: darkgreen"><br/>aliases: ssl_ca_cert</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>client_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>
</td>
<td>
</td>
<td>
<div>Path to a certificate used to authenticate with the API. Can also be specified via K8S_AUTH_CERT_FILE environment variable.</div>
<div style="font-size: small; color: darkgreen"><br/>aliases: cert_file</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>client_key</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">path</span>
</div>
</td>
<td>
</td>
<td>
<div>Path to a key file used to authenticate with the API. Can also be specified via K8S_AUTH_KEY_FILE environment variable.</div>
<div style="font-size: small; color: darkgreen"><br/>aliases: key_file</div>
</td>
</tr>
<tr>
<td colspan="2">
<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>
</td>
<td>
</td>
<td>
<div>The name of a context found in the config file. Can also be specified via K8S_AUTH_CONTEXT environment variable.</div>
</td>
</tr>
<tr>
<td colspan="2">
<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>
</td>
<td>
</td>
<td>
<div>Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>impersonate_groups</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>
</td>
<td>
<div>Group(s) to impersonate for the operation.</div>
<div>Can also be specified via K8S_AUTH_IMPERSONATE_GROUPS environment. Example: &#x27;Group1,Group2&#x27;</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>impersonate_user</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>Username to impersonate for the operation.</div>
<div>Can also be specified via K8S_AUTH_IMPERSONATE_USER environment.</div>
</td>
</tr>
<tr>
<td colspan="2">
<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>
</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>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>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>name</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>The name of the node.</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>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>password</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
</td>
<td>
</td>
<td>
<div>Provide a password for authenticating with the API. Can also be specified via K8S_AUTH_PASSWORD environment variable.</div>
<div>Please read the description of the <code>username</code> option for a discussion of when this option is applicable.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>persist_config</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>no</li>
<li>yes</li>
</ul>
</td>
<td>
<div>Whether or not to save the kube config refresh tokens. Can also be specified via K8S_AUTH_PERSIST_CONFIG environment variable.</div>
<div>When the k8s context is using a user credentials with refresh tokens (like oidc or gke/gcloud auth), the token is refreshed by the k8s python client library but not saved by default. So the old refresh token can expire and the next auth might fail. Setting this flag to true will tell the k8s python client to save the new refresh token to the kube config file.</div>
<div>Default to false.</div>
<div>Please note that the current version of the k8s python client library does not support setting this flag to True yet.</div>
<div>The fix for this k8s python library is here: https://github.com/kubernetes-client/python-base/pull/169</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>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>
</td>
<td>
</td>
<td>
<div>The URL of an HTTP proxy to use for the connection. Can also be specified via K8S_AUTH_PROXY environment variable.</div>
<div>Please note that this module does not pick up typical proxy settings from the environment (e.g. HTTP_PROXY).</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>proxy_headers</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.0.0</div>
</td>
<td>
</td>
<td>
<div>The Header used for the HTTP proxy.</div>
<div>Documentation can be found here <a href='https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html?highlight=proxy_headers#urllib3.util.make_headers'>https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html?highlight=proxy_headers#urllib3.util.make_headers</a>.</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>basic_auth</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
</td>
<td>
</td>
<td>
<div>Colon-separated username:password for basic authentication header.</div>
<div>Can also be specified via K8S_AUTH_PROXY_HEADERS_BASIC_AUTH environment.</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>proxy_basic_auth</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
</td>
<td>
</td>
<td>
<div>Colon-separated username:password for proxy basic authentication header.</div>
<div>Can also be specified via K8S_AUTH_PROXY_HEADERS_PROXY_BASIC_AUTH environment.</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>user_agent</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
</td>
<td>
</td>
<td>
<div>String representing the user-agent you want, such as foo/1.0.</div>
<div>Can also be specified via K8S_AUTH_PROXY_HEADERS_USER_AGENT environment.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>replace</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>If <code>true</code>, allow taints to be replaced.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>state</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li><div style="color: blue"><b>present</b>&nbsp;&larr;</div></li>
<li>absent</li>
</ul>
</td>
<td>
<div>Determines whether to add or remove taints.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>taints</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>
/ <span style="color: red">required</span>
</div>
</td>
<td>
</td>
<td>
<div>List containing the taints.</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>effect</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li>NoSchedule</li>
<li>NoExecute</li>
<li>PreferNoSchedule</li>
</ul>
</td>
<td>
<div>The effect of the taint on Pods that do not tolerate the taint.</div>
<div>Required when <em>state=present</em>.</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>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>
</td>
<td>
</td>
<td>
<div>The taint key to be applied to a node.</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<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>
</div>
</td>
<td>
</td>
<td>
<div>The taint value corresponding to the taint key.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>username</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
</td>
<td>
</td>
<td>
<div>Provide a username for authenticating with the API. Can also be specified via K8S_AUTH_USERNAME environment variable.</div>
<div>Please note that this only works with clusters configured to use HTTP Basic Auth. If your cluster has a different form of authentication (e.g. OAuth2 in OpenShift), this option will not work as expected and you should look into the <span class='module'>community.okd.k8s_auth</span> module, as that might do what you need.</div>
</td>
</tr>
<tr>
<td colspan="2">
<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>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li>no</li>
<li>yes</li>
</ul>
</td>
<td>
<div>Whether or not to verify the API server&#x27;s SSL certificates. Can also be specified via K8S_AUTH_VERIFY_SSL environment variable.</div>
<div style="font-size: small; color: darkgreen"><br/>aliases: verify_ssl</div>
</td>
</tr>
</table>
<br/>
Notes
-----
.. note::
- To avoid SSL certificate validation errors when ``validate_certs`` is *True*, the full certificate chain for the API server must be provided via ``ca_cert`` or in the kubeconfig file.
Examples
--------
.. code-block:: yaml
- name: Taint node "foo"
kubernetes.core.k8s_taint:
state: present
name: foo
taints:
- effect: NoExecute
key: "key1"
- name: Taint node "foo"
kubernetes.core.k8s_taint:
state: present
name: foo
taints:
- effect: NoExecute
key: "key1"
value: "value1"
- effect: NoSchedule
key: "key1"
value: "value1"
- name: Remove taint from "foo".
kubernetes.core.k8s_taint:
state: absent
name: foo
taints:
- effect: NoExecute
key: "key1"
value: "value1"
Return Values
-------------
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
.. raw:: html
<table border=0 cellpadding=0 class="documentation-table">
<tr>
<th colspan="2">Key</th>
<th>Returned</th>
<th width="100%">Description</th>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>result</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>The tainted Node object. Will be empty in the case of a deletion.</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">
<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>
<br/><br/>
Status
------
Authors
~~~~~~~
- Alina Buzachis (@alinabuzachis)

View File

@@ -354,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: 2.3.0 version: 2.2.1
build_ignore: build_ignore:
- .DS_Store - .DS_Store
- '*.tar.gz' - '*.tar.gz'

View File

@@ -9,6 +9,7 @@ action_groups:
k8s: k8s:
- k8s - k8s
- k8s_exec - k8s_exec
- k8s_facts
- k8s_info - k8s_info
- k8s_log - k8s_log
- k8s_scale - k8s_scale
@@ -17,6 +18,37 @@ action_groups:
- k8s_drain - k8s_drain
plugin_routing: plugin_routing:
action:
helm:
redirect: kubernetes.core.k8s_info
helm_info:
redirect: kubernetes.core.k8s_info
helm_plugin:
redirect: kubernetes.core.k8s_info
helm_plugin_info:
redirect: kubernetes.core.k8s_info
helm_repository:
redirect: kubernetes.core.k8s_info
k8s:
redirect: kubernetes.core.k8s_info
k8s_cluster_info:
redirect: kubernetes.core.k8s_info
k8s_cp:
redirect: kubernetes.core.k8s_info
k8s_drain:
redirect: kubernetes.core.k8s_info
k8s_event_info:
redirect: kubernetes.core.k8s_info
k8s_exec:
redirect: kubernetes.core.k8s_info
k8s_log:
redirect: kubernetes.core.k8s_info
k8s_rollback:
redirect: kubernetes.core.k8s_info
k8s_scale:
redirect: kubernetes.core.k8s_info
k8s_service:
redirect: kubernetes.core.k8s_info
inventory: inventory:
openshift: openshift:
redirect: community.okd.openshift redirect: community.okd.openshift

View File

@@ -0,0 +1,292 @@
---
- name: Converge
hosts: localhost
connection: local
collections:
- kubernetes.core
vars_files:
- vars/main.yml
tasks:
- name: Verify cluster is working.
k8s_info:
namespace: kube-system
kind: Pod
register: pod_list
- name: Verify cluster has more than 5 pods running.
assert:
that: (pod_list.resources | count) > 5
- name: Include access_review.yml
include_tasks:
file: tasks/access_review.yml
apply:
tags: [ access_review, k8s ]
tags:
- always
- name: Include append_hash.yml
include_tasks:
file: tasks/append_hash.yml
apply:
tags: [ append_hash, k8s ]
tags:
- always
- name: Include apply.yml
include_tasks:
file: tasks/apply.yml
apply:
tags: [ apply, k8s ]
tags:
- always
- name: Include cluster_info.yml
include_tasks:
file: tasks/cluster_info.yml
apply:
tags: [ cluster_info, k8s ]
tags:
- always
- name: Include crd.yml
include_tasks:
file: tasks/crd.yml
apply:
tags: [ crd, k8s ]
tags:
- always
- name: Include delete.yml
include_tasks:
file: tasks/delete.yml
apply:
tags: [ delete, k8s ]
tags:
- always
- name: Include exec.yml
include_tasks:
file: tasks/exec.yml
apply:
tags: [ exec, k8s ]
tags:
- always
- name: Include full.yml
include_tasks:
file: tasks/full.yml
apply:
tags: [ full, k8s ]
tags:
- always
- name: Include gc.yml
include_tasks:
file: tasks/gc.yml
apply:
tags: [ gc, k8s ]
tags:
- always
- name: Include info.yml
include_tasks:
file: tasks/info.yml
apply:
tags: [ info, k8s ]
tags:
- always
- name: Include json_patch.yml
include_tasks:
file: tasks/json_patch.yml
apply:
tags: [ json_patch, k8s ]
tags:
- always
- name: Include lists.yml
include_tasks:
file: tasks/lists.yml
apply:
tags: [ lists, k8s ]
tags:
- always
- name: Include log.yml
include_tasks:
file: tasks/log.yml
apply:
tags: [ log, k8s ]
tags:
- always
- name: Include rollback.yml
include_tasks:
file: tasks/rollback.yml
apply:
tags: [ rollback, k8s ]
tags:
- always
- name: Include scale.yml
include_tasks:
file: tasks/scale.yml
apply:
tags: [ scale, k8s ]
tags:
- always
- name: Include template.yml
include_tasks:
file: tasks/template.yml
apply:
tags: [ template, k8s ]
tags:
- always
- name: Include validate.yml
include_tasks:
file: tasks/validate.yml
apply:
tags: [ validate, k8s ]
tags:
- always
- name: Include waiter.yml
include_tasks:
file: tasks/waiter.yml
apply:
tags: [ waiter, k8s ]
tags:
- always
- name: Include merge_type.yml
include_tasks:
file: tasks/merge_type.yml
apply:
tags: [ merge_type, k8s ]
tags:
- always
- name: Include patched.yml
include_tasks:
file: tasks/patched.yml
apply:
tags: [ patched, k8s ]
tags:
- always
- name: Include lookup_k8s.yml
include_tasks:
file: tasks/lookup_k8s.yml
apply:
tags: [ lookup_k8s, k8s ]
tags:
- always
- name: Include label_selectors.yml
include_tasks:
file: tasks/label_selectors.yml
apply:
tags: [ label_selectors, k8s ]
tags:
- always
- name: Include diff.yml
include_tasks:
file: tasks/diff.yml
apply:
tags: [ diff, k8s ]
tags:
- always
- name: Include lookup_kustomize.yml
include_tasks:
file: tasks/lookup_kustomize.yml
apply:
tags: [ lookup_kustomize, k8s ]
tags:
- always
roles:
- role: helm
tags:
- helm
- role: k8scopy
tags:
- copy
- k8s
post_tasks:
- name: Ensure namespace exists
k8s:
api_version: v1
kind: Namespace
name: inventory
- name: Add a deployment
k8s:
definition:
apiVersion: apps/v1
kind: Deployment
metadata:
name: inventory
namespace: inventory
spec:
replicas: 1
selector:
matchLabels:
app: "{{ k8s_pod_name }}"
template: "{{ k8s_pod_template }}"
wait: yes
wait_timeout: 120
vars:
k8s_pod_name: inventory
k8s_pod_image: python
k8s_pod_command:
- python
- '-m'
- http.server
k8s_pod_env:
- name: TEST
value: test
- meta: refresh_inventory
- name: Verify inventory and connection plugins
hosts: namespace_inventory_pods
gather_facts: no
vars:
file_content: |
Hello world
tasks:
- name: End play if host not running (TODO should we not add these to the inventory?)
meta: end_host
when: pod_phase != "Running"
- debug: var=hostvars
- setup:
- debug: var=ansible_facts
- name: Assert the TEST environment variable was retrieved
assert:
that: ansible_facts.env.TEST == 'test'
- name: Copy a file into the host
copy:
content: '{{ file_content }}'
dest: /tmp/test_file
- name: Retrieve the file from the host
slurp:
src: /tmp/test_file
register: slurped_file
- name: Assert the file content matches expectations
assert:
that: (slurped_file.content|b64decode) == file_content
- name: Delete inventory namespace
hosts: localhost
connection: local
gather_facts: no
tasks:
- name: Remove inventory namespace
k8s:
api_version: v1
kind: Namespace
name: inventory
state: absent

View File

@@ -0,0 +1,35 @@
---
driver:
name: delegated
options:
managed: false
login_cmd_template: 'docker exec -ti {instance} bash'
ansible_connection_options:
ansible_connection: docker
platforms:
- name: instance-kind
provisioner:
name: ansible
log: true
config_options:
inventory:
enable_plugins: kubernetes.core.k8s,yaml
lint: {}
inventory:
hosts:
plugin: kubernetes.core.k8s
host_vars:
localhost:
ansible_python_interpreter: '{{ ansible_playbook_python }}'
env:
ANSIBLE_FORCE_COLOR: 'true'
options:
vvv: True
scenario:
name: default
test_sequence:
- dependency
- syntax
- prepare
- converge
- verify

View File

@@ -0,0 +1,12 @@
---
- name: Prepare
hosts: localhost
connection: local
collections:
- kubernetes.core
tasks:
- name: Include drain.yml
include_tasks:
file: tasks/drain.yml

View File

@@ -1,6 +1,10 @@
--- ---
helm_archive_name: "helm-{{ helm_version }}-{{ ansible_system | lower }}-amd64.tar.gz" helm_archive_name: "helm-{{ helm_version }}-{{ ansible_system | lower }}-amd64.tar.gz"
helm_binary: "/tmp/helm/{{ ansible_system | lower }}-amd64/helm" helm_binary: "/tmp/helm/{{ ansible_system | lower }}-amd64/helm"
helm_namespace: helm
tiller_namespace: tiller
tiller_cluster_role: cluster-admin
chart_test: "ingress-nginx" chart_test: "ingress-nginx"
chart_test_local_path: "nginx-ingress" chart_test_local_path: "nginx-ingress"
@@ -13,15 +17,3 @@ chart_test_git_repo: "http://github.com/helm/charts.git"
chart_test_values: chart_test_values:
revisionHistoryLimit: 0 revisionHistoryLimit: 0
myValue: "changed" myValue: "changed"
test_namespace:
- "helm-diff"
- "helm-envvars"
- "helm-uninstall"
- "helm-not-installed"
- "helm-crd"
- "helm-url"
- "helm-repository"
- "helm-local-path-001"
- "helm-local-path-002"
- "helm-local-path-003"

View File

@@ -1,9 +1,9 @@
apiVersion: apiextensions.k8s.io/v1 apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition kind: CustomResourceDefinition
metadata: metadata:
name: foos.ansible.com name: foos.example.com
spec: spec:
group: ansible.com group: example.com
versions: versions:
- name: v1 - name: v1
served: true served: true

View File

@@ -1,5 +1,3 @@
--- ---
collections: collections:
- kubernetes.core - kubernetes.core
dependencies:
- setup_namespace

View File

@@ -9,7 +9,3 @@
src: 'https://get.helm.sh/{{ helm_archive_name }}' src: 'https://get.helm.sh/{{ helm_archive_name }}'
dest: /tmp/helm/ dest: /tmp/helm/
remote_src: yes remote_src: yes
retries: 10
delay: 5
register: result
until: result is not failed

View File

@@ -33,9 +33,6 @@
- name: Test helm diff - name: Test helm diff
include_tasks: tests_helm_diff.yml include_tasks: tests_helm_diff.yml
- name: Test helm uninstall
include_tasks: test_helm_uninstall.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

@@ -6,7 +6,7 @@
- name: Create namespace - name: Create namespace
k8s: k8s:
kind: Namespace kind: Namespace
name: "{{ test_namespace[4] }}" name: "{{ helm_namespace }}"
- name: Copy test chart - name: Copy test chart
copy: copy:
@@ -17,7 +17,7 @@
helm: helm:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
chart_ref: "/tmp/helm_test_crds/{{ test_chart }}" chart_ref: "/tmp/helm_test_crds/{{ test_chart }}"
namespace: "{{ test_namespace[4] }}" namespace: "{{ helm_namespace }}"
name: test-crds name: test-crds
skip_crds: true skip_crds: true
register: install register: install
@@ -30,10 +30,10 @@
- name: Fail to create custom resource - name: Fail to create custom resource
k8s: k8s:
definition: definition:
apiVersion: ansible.com/v1 apiVersion: example.com/v1
kind: Foo kind: Foo
metadata: metadata:
namespace: "{{ test_namespace[4] }}" namespace: "{{ helm_namespace }}"
name: test-foo name: test-foo
foobar: footest foobar: footest
ignore_errors: true ignore_errors: true
@@ -42,13 +42,13 @@
- assert: - assert:
that: that:
- result is failed - result is failed
- "result.msg.startswith('Failed to find exact match for ansible.com/v1.Foo')" - "result.msg.startswith('Failed to find exact match for example.com/v1.Foo')"
# Helm won't install CRDs into an existing release, so we need to delete this, first # Helm won't install CRDs into an existing release, so we need to delete this, first
- name: Uninstall chart - name: Uninstall chart
helm: helm:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
namespace: "{{ test_namespace[4] }}" namespace: "{{ helm_namespace }}"
name: test-crds name: test-crds
state: absent state: absent
@@ -56,16 +56,16 @@
helm: helm:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
chart_ref: "/tmp/helm_test_crds/{{ test_chart }}" chart_ref: "/tmp/helm_test_crds/{{ test_chart }}"
namespace: "{{ test_namespace[4] }}" namespace: "{{ helm_namespace }}"
name: test-crds name: test-crds
- name: Create custom resource - name: Create custom resource
k8s: k8s:
definition: definition:
apiVersion: ansible.com/v1 apiVersion: example.com/v1
kind: Foo kind: Foo
metadata: metadata:
namespace: "{{ test_namespace[4] }}" namespace: "{{ helm_namespace }}"
name: test-foo name: test-foo
foobar: footest foobar: footest
register: result register: result
@@ -85,14 +85,16 @@
- name: Remove namespace - name: Remove namespace
k8s: k8s:
kind: Namespace kind: Namespace
name: "{{ test_namespace[4] }}" name: "{{ helm_namespace }}"
state: absent state: absent
wait: true
wait_timeout: 180
ignore_errors: true ignore_errors: true
# CRDs aren't deleted with a namespace, so we need to manually delete it # CRDs aren't deleted with a namespace, so we need to manually delete it
- name: Remove CRD - name: Remove CRD
k8s: k8s:
kind: CustomResourceDefinition kind: CustomResourceDefinition
name: foos.ansible.com name: foos.example.com
state: absent state: absent
ignore_errors: true ignore_errors: true

View File

@@ -4,7 +4,7 @@
binary_path: "{{ helm_binary}}_fake" binary_path: "{{ helm_binary}}_fake"
name: test name: test
chart_ref: "{{ chart_test }}" chart_ref: "{{ chart_test }}"
namespace: "{{ test_namespace[3] }}" namespace: "{{ helm_namespace }}"
ignore_errors: yes ignore_errors: yes
register: helm_missing_binary register: helm_missing_binary

View File

@@ -3,7 +3,7 @@
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
state: absent state: absent
name: does-not-exist name: does-not-exist
namespace: "{{ test_namespace[1] }}" namespace: "{{ helm_namespace }}"
environment: environment:
K8S_AUTH_HOST: somewhere K8S_AUTH_HOST: somewhere
register: _helm_result register: _helm_result

View File

@@ -1,8 +1,5 @@
--- ---
- name: Chart tests - name: Chart tests
vars:
chart_release_name: "test-{{ chart_name | default(source) }}"
chart_release_replaced_name: "test-{{ chart_name | default(source) }}-001"
block: block:
- name: Create temp directory - name: Create temp directory
tempfile: tempfile:
@@ -16,7 +13,7 @@
- name: Check helm_info empty - name: Check helm_info empty
helm_info: helm_info:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
name: "{{ chart_release_name }}" name: test
namespace: "{{ helm_namespace }}" namespace: "{{ helm_namespace }}"
register: empty_info register: empty_info
@@ -28,7 +25,7 @@
- name: "Install fail {{ chart_test }} from {{ source }}" - name: "Install fail {{ chart_test }} from {{ source }}"
helm: helm:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
name: "{{ chart_release_name }}" name: test
chart_ref: "{{ chart_source }}" chart_ref: "{{ chart_source }}"
chart_version: "{{ chart_source_version | default(omit) }}" chart_version: "{{ chart_source_version | default(omit) }}"
namespace: "{{ helm_namespace }}" namespace: "{{ helm_namespace }}"
@@ -44,7 +41,7 @@
- name: "Install {{ chart_test }} from {{ source }} in check mode" - name: "Install {{ chart_test }} from {{ source }} in check mode"
helm: helm:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
name: "{{ chart_release_name }}" name: test
chart_ref: "{{ chart_source }}" chart_ref: "{{ chart_source }}"
chart_version: "{{ chart_source_version | default(omit) }}" chart_version: "{{ chart_source_version | default(omit) }}"
namespace: "{{ helm_namespace }}" namespace: "{{ helm_namespace }}"
@@ -62,7 +59,7 @@
- name: "Install {{ chart_test }} from {{ source }}" - name: "Install {{ chart_test }} from {{ source }}"
helm: helm:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
name: "{{ chart_release_name }}" name: test
chart_ref: "{{ chart_source }}" chart_ref: "{{ chart_source }}"
chart_version: "{{ chart_source_version | default(omit) }}" chart_version: "{{ chart_source_version | default(omit) }}"
namespace: "{{ helm_namespace }}" namespace: "{{ helm_namespace }}"
@@ -79,30 +76,20 @@
- name: Check helm_info content - name: Check helm_info content
helm_info: helm_info:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
name: "{{ chart_release_name }}" name: test
namespace: "{{ helm_namespace }}" namespace: "{{ helm_namespace }}"
register: content_info register: content_info
- name: Check helm_info content using release_state
helm_info:
binary_path: "{{ helm_binary }}"
name: "{{ chart_release_name }}"
namespace: "{{ helm_namespace }}"
release_state:
- deployed
register: release_state_content_info
- name: "Assert that {{ chart_test }} is installed from {{ source }} with helm_info" - name: "Assert that {{ chart_test }} is installed from {{ source }} with helm_info"
assert: assert:
that: that:
- content_info.status.chart == "{{ chart_test }}-{{ chart_test_version }}" - content_info.status.chart == "{{ chart_test }}-{{ chart_test_version }}"
- content_info.status.status | lower == 'deployed' - content_info.status.status | lower == 'deployed'
- release_state_content_info.status.status | lower == 'deployed'
- name: Check idempotency - name: Check idempotency
helm: helm:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
name: "{{ chart_release_name }}" name: test
chart_ref: "{{ chart_source }}" chart_ref: "{{ chart_source }}"
chart_version: "{{ chart_source_version | default(omit) }}" chart_version: "{{ chart_source_version | default(omit) }}"
namespace: "{{ helm_namespace }}" namespace: "{{ helm_namespace }}"
@@ -118,7 +105,7 @@
- name: "Add vars to {{ chart_test }} from {{ source }}" - name: "Add vars to {{ chart_test }} from {{ source }}"
helm: helm:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
name: "{{ chart_release_name }}" name: test
chart_ref: "{{ chart_source }}" chart_ref: "{{ chart_source }}"
chart_version: "{{ chart_source_version | default(omit) }}" chart_version: "{{ chart_source_version | default(omit) }}"
namespace: "{{ helm_namespace }}" namespace: "{{ helm_namespace }}"
@@ -136,7 +123,7 @@
- name: Check idempotency after adding vars - name: Check idempotency after adding vars
helm: helm:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
name: "{{ chart_release_name }}" name: test
chart_ref: "{{ chart_source }}" chart_ref: "{{ chart_source }}"
chart_version: "{{ chart_source_version | default(omit) }}" chart_version: "{{ chart_source_version | default(omit) }}"
namespace: "{{ helm_namespace }}" namespace: "{{ helm_namespace }}"
@@ -154,7 +141,7 @@
- name: "Remove Vars to {{ chart_test }} from {{ source }}" - name: "Remove Vars to {{ chart_test }} from {{ source }}"
helm: helm:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
name: "{{ chart_release_name }}" name: test
chart_ref: "{{ chart_source }}" chart_ref: "{{ chart_source }}"
chart_version: "{{ chart_source_version | default(omit) }}" chart_version: "{{ chart_source_version | default(omit) }}"
namespace: "{{ helm_namespace }}" namespace: "{{ helm_namespace }}"
@@ -171,7 +158,7 @@
- name: Check idempotency after removing vars - name: Check idempotency after removing vars
helm: helm:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
name: "{{ chart_release_name }}" name: test
chart_ref: "{{ chart_source }}" chart_ref: "{{ chart_source }}"
chart_version: "{{ chart_source_version | default(omit) }}" chart_version: "{{ chart_source_version | default(omit) }}"
namespace: "{{ helm_namespace }}" namespace: "{{ helm_namespace }}"
@@ -188,7 +175,7 @@
- name: "Upgrade {{ chart_test }} from {{ source }}" - name: "Upgrade {{ chart_test }} from {{ source }}"
helm: helm:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
name: "{{ chart_release_name }}" name: test
chart_ref: "{{ chart_source_upgrade | default(chart_source) }}" chart_ref: "{{ chart_source_upgrade | default(chart_source) }}"
chart_version: "{{ chart_source_version_upgrade | default(omit) }}" chart_version: "{{ chart_source_version_upgrade | default(omit) }}"
namespace: "{{ helm_namespace }}" namespace: "{{ helm_namespace }}"
@@ -204,7 +191,7 @@
- name: Check idempotency after upgrade - name: Check idempotency after upgrade
helm: helm:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
name: "{{ chart_release_name }}" name: test
chart_ref: "{{ chart_source_upgrade | default(chart_source) }}" chart_ref: "{{ chart_source_upgrade | default(chart_source) }}"
chart_version: "{{ chart_source_version_upgrade | default(omit) }}" chart_version: "{{ chart_source_version_upgrade | default(omit) }}"
namespace: "{{ helm_namespace }}" namespace: "{{ helm_namespace }}"
@@ -221,7 +208,7 @@
helm: helm:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
state: absent state: absent
name: "{{ chart_release_name }}" name: test
namespace: "{{ helm_namespace }}" namespace: "{{ helm_namespace }}"
register: install register: install
@@ -234,7 +221,7 @@
helm: helm:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
state: absent state: absent
name: "{{ chart_release_name }}" name: test
namespace: "{{ helm_namespace }}" namespace: "{{ helm_namespace }}"
register: install register: install
@@ -247,7 +234,7 @@
- name: Install chart for replace option - name: Install chart for replace option
helm: helm:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
name: "{{ chart_release_replaced_name }}" name: test-0001
chart_ref: "{{ chart_source }}" chart_ref: "{{ chart_source }}"
chart_version: "{{ chart_source_version | default(omit) }}" chart_version: "{{ chart_source_version | default(omit) }}"
namespace: "{{ helm_namespace }}" namespace: "{{ helm_namespace }}"
@@ -258,11 +245,11 @@
that: that:
- install is changed - install is changed
- name: "Remove {{ chart_release_replaced_name }} with --purge" - name: Remove {{ chart_test }} with --purge
helm: helm:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
state: absent state: absent
name: "{{ chart_release_replaced_name }}" name: test-0001
purge: False purge: False
namespace: "{{ helm_namespace }}" namespace: "{{ helm_namespace }}"
register: install register: install
@@ -272,10 +259,10 @@
that: that:
- install is changed - install is changed
- name: "Install chart again with same name {{ chart_release_replaced_name }}" - name: Install chart again with same name test-0001
helm: helm:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
name: "{{ chart_release_replaced_name }}" name: test-0001
chart_ref: "{{ chart_source }}" chart_ref: "{{ chart_source }}"
chart_version: "{{ chart_source_version | default(omit) }}" chart_version: "{{ chart_source_version | default(omit) }}"
namespace: "{{ helm_namespace }}" namespace: "{{ helm_namespace }}"
@@ -291,7 +278,7 @@
helm: helm:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
state: absent state: absent
name: "{{ chart_release_replaced_name }}" name: test-0001
namespace: "{{ helm_namespace }}" namespace: "{{ helm_namespace }}"
register: install register: install
@@ -303,7 +290,7 @@
- name: "Install {{ chart_test }} from {{ source }} with values_files" - name: "Install {{ chart_test }} from {{ source }} with values_files"
helm: helm:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
name: "{{ chart_release_name }}" name: test
chart_ref: "{{ chart_source }}" chart_ref: "{{ chart_source }}"
chart_version: "{{ chart_source_version | default(omit) }}" chart_version: "{{ chart_source_version | default(omit) }}"
namespace: "{{ helm_namespace }}" namespace: "{{ helm_namespace }}"
@@ -322,7 +309,7 @@
- name: "Install {{ chart_test }} from {{ source }} with values_files (again)" - name: "Install {{ chart_test }} from {{ source }} with values_files (again)"
helm: helm:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
name: "{{ chart_release_name }}" name: test
chart_ref: "{{ chart_source }}" chart_ref: "{{ chart_source }}"
chart_version: "{{ chart_source_version | default(omit) }}" chart_version: "{{ chart_source_version | default(omit) }}"
namespace: "{{ helm_namespace }}" namespace: "{{ helm_namespace }}"
@@ -364,7 +351,7 @@
- name: Release using non-existent context - name: Release using non-existent context
helm: helm:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
name: "{{ chart_release_name }}" name: test
chart_ref: "{{ chart_source }}" chart_ref: "{{ chart_source }}"
chart_version: "{{ chart_source_version | default(omit) }}" chart_version: "{{ chart_source_version | default(omit) }}"
namespace: "{{ helm_namespace }}" namespace: "{{ helm_namespace }}"
@@ -392,3 +379,5 @@
kind: Namespace kind: Namespace
name: "{{ helm_namespace }}" name: "{{ helm_namespace }}"
state: absent state: absent
wait: true
wait_timeout: 180

View File

@@ -22,8 +22,6 @@
chart_source_upgrade: "/tmp/helm_test_repo_upgrade/stable/{{ chart_test_local_path }}/" chart_source_upgrade: "/tmp/helm_test_repo_upgrade/stable/{{ chart_test_local_path }}/"
chart_test_version: "{{ chart_test_version_local_path }}" chart_test_version: "{{ chart_test_version_local_path }}"
chart_test_version_upgrade: "{{ chart_test_version_upgrade_local_path }}" chart_test_version_upgrade: "{{ chart_test_version_upgrade_local_path }}"
chart_name: "local-path-001"
helm_namespace: "{{ test_namespace[7] }}"
- name: Test appVersion idempotence - name: Test appVersion idempotence
vars: vars:
@@ -68,8 +66,6 @@
source: local_path source: local_path
chart_source: "/tmp/helm_test_appversion/test-chart/{{ chart_test }}-{{ chart_test_app_version }}-{{ chart_test_version }}.tgz" chart_source: "/tmp/helm_test_appversion/test-chart/{{ chart_test }}-{{ chart_test_app_version }}-{{ chart_test_version }}.tgz"
chart_source_upgrade: "/tmp/helm_test_appversion/test-chart/{{ chart_test }}-{{ chart_test_upgrade_app_version }}-{{ chart_test_version_upgrade }}.tgz" chart_source_upgrade: "/tmp/helm_test_appversion/test-chart/{{ chart_test }}-{{ chart_test_upgrade_app_version }}-{{ chart_test_version_upgrade }}.tgz"
chart_name: "local-path-002"
helm_namespace: "{{ test_namespace[8] }}"
- name: Test appVersion handling when null - name: Test appVersion handling when null
vars: vars:
@@ -98,8 +94,6 @@
source: local_path source: local_path
chart_source: "/tmp/helm_test_appversion/test-null/{{ chart_test }}/" chart_source: "/tmp/helm_test_appversion/test-null/{{ chart_test }}/"
chart_source_upgrade: "{{ chart_test }}-{{ chart_test_version_upgrade }}.tgz" chart_source_upgrade: "{{ chart_test }}-{{ chart_test_version_upgrade }}.tgz"
chart_name: "local-path-003"
helm_namespace: "{{ test_namespace[9] }}"
- name: Remove clone repos - name: Remove clone repos
file: file:

View File

@@ -12,7 +12,6 @@
chart_source: "test_helm/{{ chart_test }}" chart_source: "test_helm/{{ chart_test }}"
chart_source_version: "{{ chart_test_version }}" chart_source_version: "{{ chart_test_version }}"
chart_source_version_upgrade: "{{ chart_test_version_upgrade }}" chart_source_version_upgrade: "{{ chart_test_version_upgrade }}"
helm_namespace: "{{ test_namespace[6] }}"
- name: Add chart repo - name: Add chart repo
helm_repository: helm_repository:

View File

@@ -5,4 +5,3 @@
source: url source: url
chart_source: "https://github.com/kubernetes/ingress-nginx/releases/download/{{ chart_test }}-{{ chart_test_version }}/{{ chart_test }}-{{ chart_test_version }}.tgz" chart_source: "https://github.com/kubernetes/ingress-nginx/releases/download/{{ chart_test }}-{{ chart_test_version }}/{{ chart_test }}-{{ chart_test_version }}.tgz"
chart_source_upgrade: "https://github.com/kubernetes/ingress-nginx/releases/download/{{ chart_test }}-{{ chart_test_version_upgrade }}/{{ chart_test }}-{{ chart_test_version_upgrade }}.tgz" chart_source_upgrade: "https://github.com/kubernetes/ingress-nginx/releases/download/{{ chart_test }}-{{ chart_test_version_upgrade }}/{{ chart_test }}-{{ chart_test_version_upgrade }}.tgz"
helm_namespace: "{{ test_namespace[5] }}"

View File

@@ -4,15 +4,11 @@
test_chart_ref: "/tmp/test-chart" test_chart_ref: "/tmp/test-chart"
block: block:
- set_fact:
helm_namespace: "{{ test_namespace[0] }}"
- name: Install helm diff - name: Install helm diff
helm_plugin: helm_plugin:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
state: present state: present
plugin_path: https://github.com/databus23/helm-diff plugin_path: https://github.com/databus23/helm-diff
plugin_version: 3.4.0
- name: Copy test chart - name: Copy test chart
copy: copy:
@@ -44,23 +40,6 @@
data: data:
foo: {{ .Values.foo | default "bar" }} foo: {{ .Values.foo | default "bar" }}
- name: Test helm diff in check mode
helm:
binary_path: "{{ helm_binary }}"
name: test-chart
namespace: "{{ helm_namespace }}"
chart_ref: "{{ test_chart_ref }}"
check_mode: yes
diff: yes
register: diff_result
- name: Check if helm diff check is correct
vars:
foo_bar_value: "+ foo: bar"
assert:
that:
- foo_bar_value in diff_result.diff.prepared
- name: Upgrade local chart with modifications - name: Upgrade local chart with modifications
helm: helm:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
@@ -73,21 +52,6 @@
that: that:
- install is changed - install is changed
- name: No diff in check mode when no change
helm:
binary_path: "{{ helm_binary }}"
name: test-chart
namespace: "{{ helm_namespace }}"
chart_ref: "{{ test_chart_ref }}"
check_mode: yes
diff: yes
register: diff_result
- name: Check if no diff in check mode when no change
assert:
that:
- '"diff" not in diff_result'
- name: Upgrade modified local chart idempotency check - name: Upgrade modified local chart idempotency check
helm: helm:
binary_path: "{{ helm_binary }}" binary_path: "{{ helm_binary }}"
@@ -164,79 +128,6 @@
that: that:
- install is not changed - install is not changed
# Test helm diff with chart_repo_url
- name: Define Redis chart values
set_fact:
redis_chart_values:
commonLabels:
phase: testing
company: RedHat
image:
tag: 6.2.6-debian-10-r135
architecture: standalone
- name: Install Redis chart
helm:
binary_path: "{{ helm_binary }}"
chart_repo_url: https://charts.bitnami.com/bitnami
chart_ref: redis
namespace: "{{ helm_namespace }}"
name: redis-chart
chart_version: '16.0.0'
release_values: "{{ redis_chart_values }}"
- name: Upgrade Redis chart
helm:
binary_path: "{{ helm_binary }}"
chart_repo_url: https://charts.bitnami.com/bitnami
chart_ref: redis
namespace: "{{ helm_namespace }}"
name: redis-chart
chart_version: '16.0.0'
release_values: "{{ redis_chart_values }}"
check_mode: yes
register: redis_upgrade
- name: Assert that module raised a warning
assert:
that:
- not redis_upgrade.changed
- redis_upgrade.warnings is defined
- redis_upgrade.warnings | length == 1
- redis_upgrade.warnings[0] == "The default idempotency check can fail to report changes in certain cases. Install helm diff >= 3.4.1 for better results."
- name: Uninstall helm diff
helm_plugin:
binary_path: "{{ helm_binary }}"
state: absent
plugin_name: diff
ignore_errors: yes
- name: Install helm diff (version=3.4.1)
helm_plugin:
binary_path: "{{ helm_binary }}"
state: present
plugin_path: https://github.com/databus23/helm-diff
plugin_version: 3.4.1
- name: Upgrade Redis chart once again
helm:
binary_path: "{{ helm_binary }}"
chart_repo_url: https://charts.bitnami.com/bitnami
chart_ref: redis
namespace: "{{ helm_namespace }}"
name: redis-chart
chart_version: '16.0.0'
release_values: "{{ redis_chart_values }}"
check_mode: yes
register: redis_upgrade_2
- name: Assert that module raised a warning
assert:
that:
- redis_upgrade_2.changed
- redis_upgrade_2.warnings is not defined
always: always:
- name: Remove chart directory - name: Remove chart directory
file: file:
@@ -257,4 +148,6 @@
kind: Namespace kind: Namespace
name: "{{ helm_namespace }}" name: "{{ helm_namespace }}"
state: absent state: absent
wait: yes
wait_timeout: 180
ignore_errors: yes ignore_errors: yes

View File

@@ -117,49 +117,3 @@
state: absent state: absent
plugin_name: sample_plugin plugin_name: sample_plugin
ignore_errors: yes ignore_errors: yes
- block:
- name: uninstall helm plugin secrets
helm_plugin:
binary_path: "{{ helm_binary }}"
plugin_name: secrets
state: absent
- name: install helm-secrets on a specific version
helm_plugin:
binary_path: "{{ helm_binary }}"
plugin_path: https://github.com/jkroepke/helm-secrets
plugin_version: 3.4.1
state: present
- name: list helm plugin
helm_plugin_info:
plugin_name: secrets
binary_path: "{{ helm_binary }}"
register: plugin_list
- name: assert that secrets has been installed with specified version
assert:
that:
- plugin_list.plugin_list[0].version == "3.4.1"
- name: Update helm plugin version to latest
helm_plugin:
binary_path: "{{ helm_binary }}"
plugin_name: secrets
state: latest
register: _update
- name: assert update was performed
assert:
that:
- _update.changed
- '"Updated plugin: secrets" in _update.stdout'
always:
- name: Uninstall sample_plugin
helm_plugin:
binary_path: "{{ helm_binary }}"
state: absent
plugin_name: secrets
ignore_errors: yes

View File

@@ -1,6 +1,6 @@
--- ---
# defaults file for k8copy # defaults file for k8copy
test_namespace: copy copy_namespace: copy
pod_with_one_container: pod_with_one_container:
name: pod-copy-0 name: pod-copy-0
@@ -11,3 +11,5 @@ pod_with_two_container:
container: container:
- container-10 - container-10
- container-11 - container-11
kubectl_path: /tmp/kubectl

Binary file not shown.

View File

@@ -8,9 +8,9 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = r""" DOCUMENTATION = r'''
module: k8s_create_file module: k8s_diff
short_description: Create large file with a defined size. short_description: Create large file with a defined size.
@@ -36,18 +36,18 @@ options:
- If this flag is set to yes, the generated file content binary data. - If this flag is set to yes, the generated file content binary data.
type: bool type: bool
default: False default: False
""" '''
EXAMPLES = r""" EXAMPLES = r'''
- name: create 150MB file - name: create 150MB file
k8s_diff: k8s_diff:
path: large_file.txt path: large_file.txt
size: 150 size: 150
""" '''
RETURN = r""" RETURN = r'''
""" '''
import os import os
@@ -57,19 +57,17 @@ from ansible.module_utils._text import to_native
def execute_module(module): def execute_module(module):
try: try:
size = module.params.get("size") * 1024 * 1024 size = module.params.get('size') * 1024 * 1024
path = module.params.get("path") path = module.params.get('path')
write_mode = "w" write_mode = "w"
if module.params.get("binary"): if module.params.get('binary'):
content = os.urandom(size) content = os.urandom(size)
write_mode = "wb" write_mode = "wb"
else: else:
content = "" content = ""
count = 0 count = 0
while len(content) < size: while len(content) < size:
content += "This file has been generated using ansible: {0}\n".format( content += "This file has been generated using ansible: {0}\n".format(count)
count
)
count += 1 count += 1
with open(path, write_mode) as f: with open(path, write_mode) as f:
@@ -81,13 +79,13 @@ def execute_module(module):
def main(): def main():
argument_spec = {} argument_spec = {}
argument_spec["size"] = {"type": "int", "default": 400} argument_spec['size'] = {'type': 'int', 'default': 400}
argument_spec["path"] = {"type": "path", "required": True} argument_spec['path'] = {'type': 'path', 'required': True}
argument_spec["binary"] = {"type": "bool", "default": False} argument_spec['binary'] = {'type': 'bool', 'default': False}
module = AnsibleModule(argument_spec=argument_spec) module = AnsibleModule(argument_spec=argument_spec)
execute_module(module) execute_module(module)
if __name__ == "__main__": if __name__ == '__main__':
main() main()

View File

@@ -0,0 +1,217 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2021, Aubin Bikouo <@abikouo>
# 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: kubectl_file_compare
short_description: Compare file and directory using kubectl
author:
- Aubin Bikouo (@abikouo)
description:
- This module is used to validate k8s_cp module.
- Compare the local file/directory with the remote pod version
notes:
- This module authenticates on kubernetes cluster using default kubeconfig only.
options:
namespace:
description:
- The pod namespace name
type: str
required: yes
pod:
description:
- The pod name
type: str
required: yes
container:
description:
- The container to retrieve files from.
type: str
remote_path:
description:
- Path of the file or directory on Pod.
type: path
required: yes
local_path:
description:
- Path of the local file or directory.
type: path
content:
description:
- local content to compare with remote file from pod.
- mutually exclusive with option I(local_path).
type: path
required: yes
args:
description:
- The file is considered to be an executable.
- The tool will be run locally and on pod and compare result from output and stderr.
type: list
kubectl_path:
description:
- Path to the kubectl executable, if not specified it will be download.
type: path
'''
EXAMPLES = r'''
- name: compare local /tmp/foo with /tmp/bar in a remote pod
kubectl_file_compare:
namespace: some-namespace
pod: some-pod
remote_path: /tmp/bar
local_path: /tmp/foo
kubectl_path: /tmp/test/kubectl
- name: Compare executable running help command
kubectl_file_compare:
namespace: some-namespace
pod: some-pod
remote_path: /tmp/test/kubectl
local_path: kubectl
kubectl_path: /tmp/test/kubectl
args:
- "--help"
'''
RETURN = r'''
'''
import os
import filecmp
from tempfile import NamedTemporaryFile, TemporaryDirectory
from ansible.module_utils.basic import AnsibleModule
def kubectl_get_content(module, dest_dir):
kubectl_path = module.params.get('kubectl_path')
if kubectl_path is None:
kubectl_path = module.get_bin_path('kubectl', required=True)
namespace = module.params.get('namespace')
pod = module.params.get('pod')
file = module.params.get('remote_path')
cmd = [
kubectl_path,
'cp',
"{0}/{1}:{2}".format(namespace, pod, file)
]
container = module.params.get('container')
if container:
cmd += ['-c', container]
local_file = os.path.join(dest_dir, os.path.basename(module.params.get('remote_path')))
cmd.append(local_file)
rc, out, err = module.run_command(cmd)
return local_file, err, rc, out
def kubectl_run_from_pod(module):
kubectl_path = module.params.get('kubectl_path')
if kubectl_path is None:
kubectl_path = module.get_bin_path('kubectl', required=True)
cmd = [
kubectl_path,
'exec',
module.params.get('pod'),
'-n',
module.params.get('namespace')
]
container = module.params.get('container')
if container:
cmd += ['-c', container]
cmd += ['--', module.params.get('remote_path')]
cmd += module.params.get('args')
return module.run_command(cmd)
def compare_directories(dir1, dir2):
test = filecmp.dircmp(dir1, dir2)
if any([len(test.left_only) > 0, len(test.right_only) > 0, len(test.funny_files) > 0]):
return False
(t, mismatch, errors) = filecmp.cmpfiles(dir1, dir2, test.common_files, shallow=False)
if len(mismatch) > 0 or len(errors) > 0:
return False
for common_dir in test.common_dirs:
new_dir1 = os.path.join(dir1, common_dir)
new_dir2 = os.path.join(dir2, common_dir)
if not compare_directories(new_dir1, new_dir2):
return False
return True
def execute_module(module):
args = module.params.get('args')
local_path = module.params.get('local_path')
namespace = module.params.get('namespace')
pod = module.params.get('pod')
file = module.params.get('remote_path')
content = module.params.get('content')
if args:
pod_rc, pod_out, pod_err = kubectl_run_from_pod(module)
rc, out, err = module.run_command([module.params.get('local_path')] + args)
if rc == pod_rc and out == pod_out:
module.exit_json(msg="{0} and {1}/{2}:{3} are same.".format(
local_path, namespace, pod, file
), rc=rc, stderr=err, stdout=out)
result = dict(local=dict(rc=rc, out=out, err=err), remote=dict(rc=pod_rc, out=pod_out, err=pod_err))
module.fail_json(msg=f"{local_path} and {namespace}/{pod}:{file} are same.", **result)
else:
with TemporaryDirectory() as tmpdirname:
file_from_pod, err, rc, out = kubectl_get_content(module=module, dest_dir=tmpdirname)
if not os.path.exists(file_from_pod):
module.fail_json(msg="failed to copy content from pod", error=err, output=out)
if content is not None:
with NamedTemporaryFile(mode="w") as tmp_file:
tmp_file.write(content)
tmp_file.flush()
if filecmp.cmp(file_from_pod, tmp_file.name):
module.exit_json(msg=f"defined content and {namespace}/{pod}:{file} are same.")
module.fail_json(msg=f"defined content and {namespace}/{pod}:{file} are same.")
if os.path.isfile(local_path):
if filecmp.cmp(file_from_pod, local_path):
module.exit_json(msg=f"{local_path} and {namespace}/{pod}:{file} are same.")
module.fail_json(msg=f"{local_path} and {namespace}/{pod}:{file} are same.")
if os.path.isdir(local_path):
if compare_directories(file_from_pod, local_path):
module.exit_json(msg=f"{local_path} and {namespace}/{pod}:{file} are same.")
module.fail_json(msg=f"{local_path} and {namespace}/{pod}:{file} are same.")
def main():
argument_spec = {}
argument_spec['namespace'] = {'type': 'str', 'required': True}
argument_spec['pod'] = {'type': 'str', 'required': True}
argument_spec['container'] = {}
argument_spec['remote_path'] = {'type': 'path', 'required': True}
argument_spec['local_path'] = {'type': 'path'}
argument_spec['content'] = {'type': 'str'}
argument_spec['kubectl_path'] = {'type': 'path'}
argument_spec['args'] = {'type': 'list'}
module = AnsibleModule(argument_spec=argument_spec,
mutually_exclusive=[('local_path', 'content')],
required_one_of=[['local_path', 'content']])
execute_module(module)
if __name__ == '__main__':
main()

View File

@@ -1,5 +1,3 @@
--- ---
collections: collections:
- kubernetes.core - kubernetes.core
dependencies:
- remove_namespace

View File

@@ -1,8 +1,15 @@
--- ---
- set_fact:
copy_namespace: "{{ test_namespace }}"
- block: - block:
- name: Download kubeclt executable used to compare results
get_url:
url: https://dl.k8s.io/release/v1.21.3/bin/linux/amd64/kubectl
dest: "{{ kubectl_path }}"
- name: make kubectl executable
ansible.builtin.file:
path: "{{ kubectl_path }}"
mode: "+x"
# Ensure namespace and create pod to perform tests on # Ensure namespace and create pod to perform tests on
- name: Ensure namespace exists - name: Ensure namespace exists
k8s: k8s:
@@ -25,6 +32,11 @@
- include_tasks: test_copy_large_file.yml - include_tasks: test_copy_large_file.yml
always: always:
- name: Remove kubectl executable
ansible.builtin.file:
path: "{{ kubectl_path }}"
state: absent
ignore_errors: true
- name: Remove namespace - name: Remove namespace
k8s: k8s:

View File

@@ -14,6 +14,7 @@
pod: '{{ pod_with_one_container.name }}' pod: '{{ pod_with_one_container.name }}'
remote_path: /dest_data remote_path: /dest_data
local_path: '{{ role_path }}/files/data' local_path: '{{ role_path }}/files/data'
kubectl_path: "{{ kubectl_path }}"
- name: copy directory into remote Pod (existing directory) - name: copy directory into remote Pod (existing directory)
k8s_cp: k8s_cp:
@@ -29,6 +30,7 @@
pod: '{{ pod_with_one_container.name }}' pod: '{{ pod_with_one_container.name }}'
remote_path: /tmp/data remote_path: /tmp/data
local_path: '{{ role_path }}/files/data' local_path: '{{ role_path }}/files/data'
kubectl_path: "{{ kubectl_path }}"
- name: copy directory from Pod into local filesystem (new directory to create) - name: copy directory from Pod into local filesystem (new directory to create)
k8s_cp: k8s_cp:
@@ -44,6 +46,7 @@
pod: '{{ pod_with_one_container.name }}' pod: '{{ pod_with_one_container.name }}'
remote_path: /tmp/data remote_path: /tmp/data
local_path: /tmp/test local_path: /tmp/test
kubectl_path: "{{ kubectl_path }}"
- name: copy directory from Pod into local filesystem (existing directory) - name: copy directory from Pod into local filesystem (existing directory)
k8s_cp: k8s_cp:
@@ -59,6 +62,7 @@
pod: '{{ pod_with_one_container.name }}' pod: '{{ pod_with_one_container.name }}'
remote_path: /tmp/data remote_path: /tmp/data
local_path: /tmp/data local_path: /tmp/data
kubectl_path: "{{ kubectl_path }}"
always: always:
- name: Remove directories created into remote Pod - name: Remove directories created into remote Pod

View File

@@ -15,6 +15,7 @@
pod: '{{ pod_with_one_container.name }}' pod: '{{ pod_with_one_container.name }}'
remote_path: /tmp/simple_file.txt remote_path: /tmp/simple_file.txt
content: "{{ lookup('file', 'simple_file.txt')}}" content: "{{ lookup('file', 'simple_file.txt')}}"
kubectl_path: "{{ kubectl_path }}"
- name: Copy simple text file from Pod - name: Copy simple text file from Pod
k8s_cp: k8s_cp:
@@ -30,67 +31,53 @@
pod: '{{ pod_with_one_container.name }}' pod: '{{ pod_with_one_container.name }}'
remote_path: /tmp/simple_file.txt remote_path: /tmp/simple_file.txt
local_path: /tmp/copy_from_pod.txt local_path: /tmp/copy_from_pod.txt
kubectl_path: "{{ kubectl_path }}"
# Binary file # Binary file
- name: Generate random content
- name: Create temp binary file set_fact:
tempfile: hello_arg: "{{ lookup('password', '/dev/null chars=ascii_lowercase,digits length=16') }}"
state: file
register: binfile
- name: Generate random binary content
command: dd if=/dev/urandom of={{ binfile.path }} bs=1M count=1
- name: Copy executable into Pod - name: Copy executable into Pod
k8s_cp: k8s_cp:
namespace: '{{ copy_namespace }}' namespace: '{{ copy_namespace }}'
pod: '{{ pod_with_one_container.name }}' pod: '{{ pod_with_one_container.name }}'
remote_path: /tmp/hello.exe remote_path: /tmp/hello.exe
local_path: "{{ binfile.path }}" local_path: files/hello
state: to_pod state: to_pod
- name: Get remote hash - name: Compare executable
kubernetes.core.k8s_exec: kubectl_file_compare:
namespace: "{{ copy_namespace }}" namespace: '{{ copy_namespace }}'
pod: "{{ pod_with_one_container.name }}" pod: '{{ pod_with_one_container.name }}'
command: sha256sum -b /tmp/hello.exe remote_path: /tmp/hello.exe
register: remote_hash local_path: "{{ role_path }}/files/hello"
kubectl_path: "{{ kubectl_path }}"
- name: Get local hash args:
command: sha256sum -b {{ binfile.path }} - "{{ hello_arg }}"
register: local_hash
- assert:
that:
- remote_hash.stdout.split()[0] == local_hash.stdout.split()[0]
- name: Generate tempfile
tempfile:
state: file
register: binfile
- name: Copy executable from Pod - name: Copy executable from Pod
k8s_cp: k8s_cp:
namespace: '{{ copy_namespace }}' namespace: '{{ copy_namespace }}'
pod: '{{ pod_with_one_container.name }}' pod: '{{ pod_with_one_container.name }}'
remote_path: /tmp/hello.exe remote_path: /tmp/hello.exe
local_path: "{{ binfile.path }}" local_path: /tmp/hello
state: from_pod state: from_pod
- name: Get remote hash - name: update executable permission
kubernetes.core.k8s_exec: file:
namespace: "{{ copy_namespace }}" path: /tmp/hello
pod: "{{ pod_with_one_container.name }}" mode: '0755'
command: sha256sum -b /tmp/hello.exe
register: remote_hash
- name: Get local hash - name: Compare executable
command: sha256sum -b {{ binfile.path }} kubectl_file_compare:
register: local_hash namespace: '{{ copy_namespace }}'
pod: '{{ pod_with_one_container.name }}'
- assert: remote_path: /tmp/hello.exe
that: local_path: /tmp/hello
- remote_hash.stdout.split()[0] == local_hash.stdout.split()[0] kubectl_path: "{{ kubectl_path }}"
args:
- "{{ hello_arg }}"
# zip files # zip files
- name: copy zip file into remote pod - name: copy zip file into remote pod
@@ -107,6 +94,7 @@
pod: '{{ pod_with_one_container.name }}' pod: '{{ pod_with_one_container.name }}'
remote_path: /tmp/simple_zip_file.txt.gz remote_path: /tmp/simple_zip_file.txt.gz
local_path: '{{ role_path }}/files/simple_zip_file.txt.gz' local_path: '{{ role_path }}/files/simple_zip_file.txt.gz'
kubectl_path: "{{ kubectl_path }}"
- name: copy zip file from pod into local filesystem - name: copy zip file from pod into local filesystem
k8s_cp: k8s_cp:
@@ -122,6 +110,7 @@
pod: '{{ pod_with_one_container.name }}' pod: '{{ pod_with_one_container.name }}'
remote_path: /tmp/simple_zip_file.txt.gz remote_path: /tmp/simple_zip_file.txt.gz
local_path: /tmp/copied_from_pod.txt.gz local_path: /tmp/copied_from_pod.txt.gz
kubectl_path: "{{ kubectl_path }}"
# tar files # tar files
- name: copy archive into remote pod - name: copy archive into remote pod
@@ -138,6 +127,7 @@
pod: '{{ pod_with_one_container.name }}' pod: '{{ pod_with_one_container.name }}'
remote_path: /tmp/archive.tar remote_path: /tmp/archive.tar
local_path: '{{ role_path }}/files/archive.tar' local_path: '{{ role_path }}/files/archive.tar'
kubectl_path: "{{ kubectl_path }}"
- name: copy archive from remote pod into local filesystem - name: copy archive from remote pod into local filesystem
k8s_cp: k8s_cp:
@@ -153,6 +143,7 @@
pod: '{{ pod_with_one_container.name }}' pod: '{{ pod_with_one_container.name }}'
remote_path: /tmp/archive.tar remote_path: /tmp/archive.tar
local_path: /tmp/local_archive.tar local_path: /tmp/local_archive.tar
kubectl_path: "{{ kubectl_path }}"
# Copy into Pod using content option # Copy into Pod using content option
- name: set content to be copied into Pod - name: set content to be copied into Pod
@@ -173,6 +164,7 @@
pod: '{{ pod_with_one_container.name }}' pod: '{{ pod_with_one_container.name }}'
remote_path: /this_content.txt remote_path: /this_content.txt
content: '{{ pod_content }}' content: '{{ pod_content }}'
kubectl_path: "{{ kubectl_path }}"
always: always:
- name: Delete file created on Pod - name: Delete file created on Pod

View File

@@ -36,6 +36,7 @@
pod: '{{ pod_with_one_container.name }}' pod: '{{ pod_with_one_container.name }}'
remote_path: /large_text_file.txt remote_path: /large_text_file.txt
local_path: "{{ test_directory }}/large_text_file.txt" local_path: "{{ test_directory }}/large_text_file.txt"
kubectl_path: "{{ kubectl_path }}"
- name: copy large file from Pod into local filesystem - name: copy large file from Pod into local filesystem
k8s_cp: k8s_cp:
@@ -51,6 +52,7 @@
pod: '{{ pod_with_one_container.name }}' pod: '{{ pod_with_one_container.name }}'
remote_path: /large_text_file.txt remote_path: /large_text_file.txt
local_path: "{{ test_directory }}/large_text_file_from_pod.txt" local_path: "{{ test_directory }}/large_text_file_from_pod.txt"
kubectl_path: "{{ kubectl_path }}"
# Copy large binary file from/to local filesystem to Pod # Copy large binary file from/to local filesystem to Pod
- name: copy large file into remote Pod - name: copy large file into remote Pod

View File

@@ -18,6 +18,7 @@
remote_path: /file_from_localhost.txt remote_path: /file_from_localhost.txt
container: '{{ pod_with_two_container.container[0] }}' container: '{{ pod_with_two_container.container[0] }}'
content: '{{ random_content }}' content: '{{ random_content }}'
kubectl_path: "{{ kubectl_path }}"
- name: Assert that content has not been copied into second container - name: Assert that content has not been copied into second container
kubectl_file_compare: kubectl_file_compare:
@@ -26,6 +27,7 @@
remote_path: /file_from_localhost.txt remote_path: /file_from_localhost.txt
container: '{{ pod_with_two_container.container[1] }}' container: '{{ pod_with_two_container.container[1] }}'
content: '{{ random_content }}' content: '{{ random_content }}'
kubectl_path: "{{ kubectl_path }}"
register: diff register: diff
ignore_errors: true ignore_errors: true
@@ -50,6 +52,7 @@
remote_path: /file_from_localhost_01.txt remote_path: /file_from_localhost_01.txt
container: '{{ pod_with_two_container.container[0] }}' container: '{{ pod_with_two_container.container[0] }}'
content: '{{ random_content }}-secondpod' content: '{{ random_content }}-secondpod'
kubectl_path: "{{ kubectl_path }}"
ignore_errors: true ignore_errors: true
register: diff_1 register: diff_1
@@ -65,3 +68,4 @@
remote_path: /file_from_localhost_01.txt remote_path: /file_from_localhost_01.txt
container: '{{ pod_with_two_container.container[1] }}' container: '{{ pod_with_two_container.container[1] }}'
content: '{{ random_content }}-secondpod' content: '{{ random_content }}-secondpod'
kubectl_path: "{{ kubectl_path }}"

View File

@@ -3,14 +3,14 @@
- name: Ensure that append_hash namespace exists - name: Ensure that append_hash namespace exists
k8s: k8s:
kind: Namespace kind: Namespace
name: "{{ test_namespace }}" name: append-hash
- name: Create k8s_resource variable - name: Create k8s_resource variable
set_fact: set_fact:
k8s_resource: k8s_resource:
metadata: metadata:
name: config-map-test name: config-map-test
namespace: "{{ test_namespace }}" namespace: append-hash
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap
data: data:
@@ -46,7 +46,7 @@
definition: definition:
metadata: metadata:
name: config-map-test name: config-map-test
namespace: "{{ test_namespace }}" namespace: append-hash
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap
data: data:
@@ -65,5 +65,5 @@
- name: Ensure that namespace is removed - name: Ensure that namespace is removed
k8s: k8s:
kind: Namespace kind: Namespace
name: "{{ test_namespace }}" name: append-hash
state: absent state: absent

View File

@@ -1,17 +1,20 @@
--- ---
- block: - block:
- set_fact:
apply_namespace: apply
- name: Ensure namespace exists - name: Ensure namespace exists
k8s: k8s:
definition: definition:
apiVersion: v1 apiVersion: v1
kind: Namespace kind: Namespace
metadata: metadata:
name: "{{ test_namespace }}" name: "{{ apply_namespace }}"
- name: Add a configmap - name: Add a configmap
k8s: k8s:
name: "apply-configmap" name: "apply-configmap"
namespace: "{{ test_namespace }}" namespace: "{{ apply_namespace }}"
definition: definition:
kind: ConfigMap kind: ConfigMap
apiVersion: v1 apiVersion: v1
@@ -35,7 +38,7 @@
apiVersion: v1 apiVersion: v1
metadata: metadata:
name: "apply-configmap" name: "apply-configmap"
namespace: "{{ test_namespace }}" namespace: "{{ apply_namespace }}"
data: data:
one: "1" one: "1"
two: "2" two: "2"
@@ -55,7 +58,7 @@
apiVersion: v1 apiVersion: v1
metadata: metadata:
name: "apply-configmap" name: "apply-configmap"
namespace: "{{ test_namespace }}" namespace: "{{ apply_namespace }}"
data: data:
one: "1" one: "1"
two: "2" two: "2"
@@ -72,7 +75,7 @@
- name: Add same configmap again but using name and namespace args - name: Add same configmap again but using name and namespace args
k8s: k8s:
name: "apply-configmap" name: "apply-configmap"
namespace: "{{ test_namespace }}" namespace: "{{ apply_namespace }}"
definition: definition:
kind: ConfigMap kind: ConfigMap
apiVersion: v1 apiVersion: v1
@@ -95,7 +98,7 @@
apiVersion: v1 apiVersion: v1
metadata: metadata:
name: "apply-configmap" name: "apply-configmap"
namespace: "{{ test_namespace }}" namespace: "{{ apply_namespace }}"
data: data:
one: "1" one: "1"
three: "3" three: "3"
@@ -117,7 +120,7 @@
kind: Service kind: Service
metadata: metadata:
name: apply-svc name: apply-svc
namespace: "{{ test_namespace }}" namespace: "{{ apply_namespace }}"
spec: spec:
selector: selector:
app: whatever app: whatever
@@ -135,7 +138,7 @@
kind: Service kind: Service
metadata: metadata:
name: apply-svc name: apply-svc
namespace: "{{ test_namespace }}" namespace: "{{ apply_namespace }}"
spec: spec:
selector: selector:
app: whatever app: whatever
@@ -158,7 +161,7 @@
kind: Service kind: Service
metadata: metadata:
name: apply-svc name: apply-svc
namespace: "{{ test_namespace }}" namespace: "{{ apply_namespace }}"
spec: spec:
selector: selector:
app: whatever app: whatever
@@ -182,7 +185,7 @@
kind: Service kind: Service
metadata: metadata:
name: apply-svc name: apply-svc
namespace: "{{ test_namespace }}" namespace: "{{ apply_namespace }}"
spec: spec:
selector: selector:
app: whatever app: whatever
@@ -207,7 +210,7 @@
kind: Service kind: Service
metadata: metadata:
name: apply-svc name: apply-svc
namespace: "{{ test_namespace }}" namespace: "{{ apply_namespace }}"
spec: spec:
selector: selector:
app: whatever app: whatever
@@ -236,7 +239,7 @@
kind: Service kind: Service
metadata: metadata:
name: apply-svc name: apply-svc
namespace: "{{ test_namespace }}" namespace: "{{ apply_namespace }}"
spec: spec:
selector: selector:
app: whatever app: whatever
@@ -262,7 +265,7 @@
kind: Service kind: Service
metadata: metadata:
name: apply-svc name: apply-svc
namespace: "{{ test_namespace }}" namespace: "{{ apply_namespace }}"
spec: spec:
selector: selector:
app: whatever app: whatever
@@ -287,7 +290,7 @@
kind: ServiceAccount kind: ServiceAccount
metadata: metadata:
name: apply-deploy name: apply-deploy
namespace: "{{ test_namespace }}" namespace: "{{ apply_namespace }}"
- name: Add a deployment - name: Add a deployment
k8s: k8s:
@@ -296,7 +299,7 @@
kind: Deployment kind: Deployment
metadata: metadata:
name: apply-deploy name: apply-deploy
namespace: "{{ test_namespace }}" namespace: "{{ apply_namespace }}"
spec: spec:
replicas: 1 replicas: 1
selector: selector:
@@ -304,7 +307,6 @@
app: "{{ k8s_pod_name }}" app: "{{ k8s_pod_name }}"
template: "{{ k8s_pod_template }}" template: "{{ k8s_pod_template }}"
wait: yes wait: yes
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
apply: yes apply: yes
vars: vars:
k8s_pod_name: apply-deploy k8s_pod_name: apply-deploy
@@ -329,7 +331,7 @@
kind: Deployment kind: Deployment
metadata: metadata:
name: apply-deploy name: apply-deploy
namespace: "{{ test_namespace }}" namespace: "{{ apply_namespace }}"
spec: spec:
replicas: 1 replicas: 1
selector: selector:
@@ -337,7 +339,6 @@
app: "{{ k8s_pod_name }}" app: "{{ k8s_pod_name }}"
template: "{{ k8s_pod_template }}" template: "{{ k8s_pod_template }}"
wait: yes wait: yes
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
apply: yes apply: yes
check_mode: yes check_mode: yes
vars: vars:
@@ -369,7 +370,7 @@
kind: Deployment kind: Deployment
metadata: metadata:
name: apply-deploy name: apply-deploy
namespace: "{{ test_namespace }}" namespace: "{{ apply_namespace }}"
spec: spec:
replicas: 1 replicas: 1
selector: selector:
@@ -377,7 +378,6 @@
app: "{{ k8s_pod_name }}" app: "{{ k8s_pod_name }}"
template: "{{ k8s_pod_template }}" template: "{{ k8s_pod_template }}"
wait: yes wait: yes
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
apply: yes apply: yes
vars: vars:
k8s_pod_name: apply-deploy k8s_pod_name: apply-deploy
@@ -409,7 +409,7 @@
kind: ServiceAccount kind: ServiceAccount
metadata: metadata:
name: apply-deploy name: apply-deploy
namespace: "{{ test_namespace }}" namespace: "{{ apply_namespace }}"
- name: Apply deployment after service account removed - name: Apply deployment after service account removed
k8s: k8s:
@@ -418,7 +418,7 @@
kind: Deployment kind: Deployment
metadata: metadata:
name: apply-deploy name: apply-deploy
namespace: "{{ test_namespace }}" namespace: "{{ apply_namespace }}"
spec: spec:
replicas: 1 replicas: 1
selector: selector:
@@ -426,7 +426,6 @@
app: "{{ k8s_pod_name }}" app: "{{ k8s_pod_name }}"
template: "{{ k8s_pod_template }}" template: "{{ k8s_pod_template }}"
wait: yes wait: yes
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
apply: yes apply: yes
vars: vars:
k8s_pod_name: apply-deploy k8s_pod_name: apply-deploy
@@ -450,6 +449,318 @@
that: that:
- deploy_after_serviceaccount_removal is failed - deploy_after_serviceaccount_removal is failed
- name: Insert new service port
k8s:
definition:
apiVersion: v1
kind: Service
metadata:
name: apply-svc
namespace: "{{ apply_namespace }}"
spec:
selector:
app: whatever
ports:
- name: mesh
port: 8080
targetPort: 8080
- name: http
port: 8081
targetPort: 8081
apply: yes
register: k8s_service_4
- name: Check ports are correct
assert:
that:
- k8s_service_4 is changed
- k8s_service_4.result.spec.ports | length == 2
- k8s_service_4.result.spec.ports[0].port == 8080
- k8s_service_4.result.spec.ports[1].port == 8081
- name: Remove new service port (check mode)
k8s:
definition:
apiVersion: v1
kind: Service
metadata:
name: apply-svc
namespace: "{{ apply_namespace }}"
spec:
selector:
app: whatever
ports:
- name: http
port: 8081
targetPort: 8081
apply: yes
check_mode: yes
register: k8s_service_check
- name: Check ports are correct
assert:
that:
- k8s_service_check is changed
- k8s_service_check.result.spec.ports | length == 1
- k8s_service_check.result.spec.ports[0].port == 8081
- name: Remove new service port
k8s:
definition:
apiVersion: v1
kind: Service
metadata:
name: apply-svc
namespace: "{{ apply_namespace }}"
spec:
selector:
app: whatever
ports:
- name: http
port: 8081
targetPort: 8081
apply: yes
register: k8s_service_5
- name: Check ports are correct
assert:
that:
- k8s_service_5 is changed
- k8s_service_5.result.spec.ports | length == 1
- k8s_service_5.result.spec.ports[0].port == 8081
- name: Add a serviceaccount
k8s:
definition:
apiVersion: v1
kind: ServiceAccount
metadata:
name: apply-deploy
namespace: "{{ apply_namespace }}"
- name: Add a deployment
k8s:
definition:
apiVersion: apps/v1
kind: Deployment
metadata:
name: apply-deploy
namespace: "{{ apply_namespace }}"
spec:
replicas: 1
selector:
matchLabels:
app: "{{ k8s_pod_name }}"
template: "{{ k8s_pod_template }}"
wait: yes
apply: yes
vars:
k8s_pod_name: apply-deploy
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:v0.10.0-green
k8s_pod_service_account: apply-deploy
k8s_pod_ports:
- containerPort: 8080
name: http
protocol: TCP
- name: Remove the serviceaccount
k8s:
state: absent
definition:
apiVersion: v1
kind: ServiceAccount
metadata:
name: apply-deploy
namespace: "{{ apply_namespace }}"
- name: Update the earlier deployment
k8s:
definition:
apiVersion: apps/v1
kind: Deployment
metadata:
name: apply-deploy
namespace: "{{ apply_namespace }}"
spec:
replicas: 2
selector:
matchLabels:
app: "{{ k8s_pod_name }}"
template: "{{ k8s_pod_template }}"
wait: yes
apply: yes
vars:
k8s_pod_name: apply-deploy
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:v0.10.0-purple
k8s_pod_service_account: apply-deploy
k8s_pod_ports:
- containerPort: 8080
name: http
protocol: TCP
register: deploy_after_serviceaccount_removal
ignore_errors: yes
- name: Ensure that updating deployment after service account removal failed
assert:
that:
- deploy_after_serviceaccount_removal is failed
- name: Insert new service port
k8s:
definition:
apiVersion: v1
kind: Service
metadata:
name: apply-svc
namespace: "{{ apply_namespace }}"
spec:
selector:
app: whatever
ports:
- name: mesh
port: 8080
targetPort: 8080
- name: http
port: 8081
targetPort: 8081
apply: yes
register: k8s_service_4
- name: Check ports are correct
assert:
that:
- k8s_service_4 is changed
- k8s_service_4.result.spec.ports | length == 2
- k8s_service_4.result.spec.ports[0].port == 8080
- k8s_service_4.result.spec.ports[1].port == 8081
- name: Remove new service port (check mode)
k8s:
definition:
apiVersion: v1
kind: Service
metadata:
name: apply-svc
namespace: "{{ apply_namespace }}"
spec:
selector:
app: whatever
ports:
- name: http
port: 8081
targetPort: 8081
apply: yes
check_mode: yes
register: k8s_service_check
- name: Check ports are correct
assert:
that:
- k8s_service_check is changed
- k8s_service_check.result.spec.ports | length == 1
- k8s_service_check.result.spec.ports[0].port == 8081
- name: Remove new service port
k8s:
definition:
apiVersion: v1
kind: Service
metadata:
name: apply-svc
namespace: "{{ apply_namespace }}"
spec:
selector:
app: whatever
ports:
- name: http
port: 8081
targetPort: 8081
apply: yes
register: k8s_service_5
- name: Check ports are correct
assert:
that:
- k8s_service_5 is changed
- k8s_service_5.result.spec.ports | length == 1
- k8s_service_5.result.spec.ports[0].port == 8081
- name: Add a serviceaccount
k8s:
definition:
apiVersion: v1
kind: ServiceAccount
metadata:
name: apply-deploy
namespace: "{{ apply_namespace }}"
- name: Add a deployment
k8s:
definition:
apiVersion: apps/v1
kind: Deployment
metadata:
name: apply-deploy
namespace: "{{ apply_namespace }}"
spec:
replicas: 1
selector:
matchLabels:
app: "{{ k8s_pod_name }}"
template: "{{ k8s_pod_template }}"
wait: yes
apply: yes
vars:
k8s_pod_name: apply-deploy
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:v0.10.0-green
k8s_pod_service_account: apply-deploy
k8s_pod_ports:
- containerPort: 8080
name: http
protocol: TCP
- name: Remove the serviceaccount
k8s:
state: absent
definition:
apiVersion: v1
kind: ServiceAccount
metadata:
name: apply-deploy
namespace: "{{ apply_namespace }}"
- name: Update the earlier deployment
k8s:
definition:
apiVersion: apps/v1
kind: Deployment
metadata:
name: apply-deploy
namespace: "{{ apply_namespace }}"
spec:
replicas: 2
selector:
matchLabels:
app: "{{ k8s_pod_name }}"
template: "{{ k8s_pod_template }}"
wait: yes
apply: yes
vars:
k8s_pod_name: apply-deploy
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:v0.10.0-purple
k8s_pod_service_account: apply-deploy
k8s_pod_ports:
- containerPort: 8080
name: http
protocol: TCP
register: deploy_after_serviceaccount_removal
ignore_errors: yes
- name: Ensure that updating deployment after service account removal failed
assert:
that:
- deploy_after_serviceaccount_removal is failed
- name: Add a secret - name: Add a secret
k8s: k8s:
definition: definition:
@@ -457,7 +768,7 @@
kind: Secret kind: Secret
metadata: metadata:
name: apply-secret name: apply-secret
namespace: "{{ test_namespace }}" namespace: "{{ apply_namespace }}"
type: Opaque type: Opaque
stringData: stringData:
foo: bar foo: bar
@@ -476,7 +787,7 @@
kind: Secret kind: Secret
metadata: metadata:
name: apply-secret name: apply-secret
namespace: "{{ test_namespace }}" namespace: "{{ apply_namespace }}"
type: Opaque type: Opaque
stringData: stringData:
foo: bar foo: bar
@@ -494,7 +805,7 @@
kind: Secret kind: Secret
metadata: metadata:
name: apply-secret name: apply-secret
namespace: "{{ test_namespace }}" namespace: "{{ apply_namespace }}"
type: Opaque type: Opaque
stringData: stringData:
foo: bar foo: bar
@@ -513,7 +824,7 @@
kind: Secret kind: Secret
metadata: metadata:
name: apply-secret name: apply-secret
namespace: "{{ test_namespace }}" namespace: "{{ apply_namespace }}"
type: Opaque type: Opaque
data: data:
foo: YmFy foo: YmFy
@@ -527,7 +838,7 @@
- name: Create network policy (egress array with empty dict) - name: Create network policy (egress array with empty dict)
k8s: k8s:
namespace: "{{ test_namespace }}" namespace: "{{ apply_namespace }}"
apply: true apply: true
definition: definition:
kind: NetworkPolicy kind: NetworkPolicy
@@ -554,7 +865,7 @@
- name: Apply network policy - name: Apply network policy
k8s: k8s:
namespace: "{{ test_namespace }}" namespace: "{{ apply_namespace }}"
definition: definition:
kind: NetworkPolicy kind: NetworkPolicy
apiVersion: networking.k8s.io/v1 apiVersion: networking.k8s.io/v1
@@ -585,141 +896,9 @@
that: that:
- k8s_networkpolicy is not changed - k8s_networkpolicy is not changed
# Server Side Apply
- name: Create Configmap using server side apply - field_manager not specified
k8s:
namespace: "{{ test_namespace }}"
definition:
apiVersion: v1
kind: ConfigMap
metadata:
name: server-side-cm
data:
key: value-0
apply: yes
server_side_apply:
force_conflicts: false
register: result
ignore_errors: true
- name: Check that configmap creation failed
assert:
that:
- result is failed
- '"field_manager" in result.msg'
- name: Create Configmap using server side apply
k8s:
namespace: "{{ test_namespace }}"
definition:
apiVersion: v1
kind: ConfigMap
metadata:
name: server-side-cm
data:
key: value-0
apply: yes
server_side_apply:
field_manager: "manager-00"
register: result
- name: Check configmap was created with expected manager
assert:
that:
- result is changed
- result.result.metadata.managedFields | length == 1
- result.result.metadata.managedFields[0].manager == 'manager-00'
- name: Apply ConfigMap using same parameters
k8s:
namespace: "{{ test_namespace }}"
definition:
apiVersion: v1
kind: ConfigMap
metadata:
name: server-side-cm
data:
key: value-0
apply: yes
server_side_apply:
field_manager: "manager-00"
register: result
- name: Assert that nothing change using check_mode
assert:
that:
- result is not changed
- name: Apply ConfigMap adding new manager
k8s:
namespace: "{{ test_namespace }}"
definition:
apiVersion: v1
kind: ConfigMap
metadata:
name: server-side-cm
data:
key: value-0
apply: yes
server_side_apply:
field_manager: "manager-01"
register: result
- name: Assert that number of manager has increased
assert:
that:
- result is changed
- result.result.metadata.managedFields | length == 2
- name: Apply changes to Configmap using new field_manager
k8s:
namespace: "{{ test_namespace }}"
definition:
apiVersion: v1
kind: ConfigMap
metadata:
name: server-side-cm
data:
key: value-1
apply: yes
server_side_apply:
field_manager: "manager-02"
register: result
ignore_errors: true
- name: assert that operation failed with conflicts
assert:
that:
- result is failed
- result.reason == 'Conflict'
- name: Apply changes to Configmap using new field_manager and force_conflicts
k8s:
namespace: "{{ test_namespace }}"
definition:
apiVersion: v1
kind: ConfigMap
metadata:
name: server-side-cm
data:
key: value-1
apply: yes
server_side_apply:
field_manager: "manager-02"
force_conflicts: true
register: result
- name: assert that operation failed with conflicts
assert:
that:
- result is changed
- result.result.metadata.managedFields | length == 1
- result.result.metadata.managedFields[0].manager == 'manager-02'
- result.result.data.key == 'value-1'
always: always:
- name: Remove namespace - name: Remove namespace
k8s: k8s:
kind: Namespace kind: Namespace
name: "{{ test_namespace }}" name: "{{ apply_namespace }}"
state: absent state: absent

View File

@@ -1,8 +1,13 @@
--- ---
- block: - block:
- name: Create a namespace
k8s:
name: crd
kind: Namespace
- name: Install custom resource definitions - name: Install custom resource definitions
k8s: k8s:
definition: "{{ lookup('file', 'setup-crd.yml') }}" definition: "{{ lookup('file', kubernetes_role_path + '/files/setup-crd.yml') }}"
- name: Pause 5 seconds to avoid race condition - name: Pause 5 seconds to avoid race condition
pause: pause:
@@ -10,15 +15,15 @@
- name: Create custom resource definition - name: Create custom resource definition
k8s: k8s:
definition: "{{ lookup('file', 'crd-resource.yml') }}" definition: "{{ lookup('file', kubernetes_role_path + '/files/crd-resource.yml') }}"
namespace: "{{ test_namespace }}" namespace: crd
apply: "{{ create_crd_with_apply | default(omit) }}" apply: "{{ create_crd_with_apply | default(omit) }}"
register: create_crd register: create_crd
- name: Patch custom resource definition - name: Patch custom resource definition
k8s: k8s:
definition: "{{ lookup('file', 'crd-resource.yml') }}" definition: "{{ lookup('file', kubernetes_role_path + '/files/crd-resource.yml') }}"
namespace: "{{ test_namespace }}" namespace: crd
register: recreate_crd register: recreate_crd
ignore_errors: yes ignore_errors: yes
@@ -30,32 +35,33 @@
- block: - block:
- name: Recreate custom resource definition with merge_type - name: Recreate custom resource definition with merge_type
k8s: k8s:
definition: "{{ lookup('file', 'crd-resource.yml') }}" definition: "{{ lookup('file', kubernetes_role_path + '/files/crd-resource.yml') }}"
merge_type: merge_type:
- merge - merge
namespace: "{{ test_namespace }}" namespace: crd
register: recreate_crd_with_merge register: recreate_crd_with_merge
- name: Recreate custom resource definition with merge_type list - name: Recreate custom resource definition with merge_type list
k8s: k8s:
definition: "{{ lookup('file', 'crd-resource.yml') }}" definition: "{{ lookup('file', kubernetes_role_path + '/files/crd-resource.yml') }}"
merge_type: merge_type:
- strategic-merge - strategic-merge
- merge - merge
namespace: "{{ test_namespace }}" namespace: crd
register: recreate_crd_with_merge_list register: recreate_crd_with_merge_list
when: recreate_crd is successful when: recreate_crd is successful
- name: Remove crd - name: Remove crd
k8s: k8s:
definition: "{{ lookup('file', 'crd-resource.yml') }}" definition: "{{ lookup('file', kubernetes_role_path + '/files/crd-resource.yml') }}"
namespace: "{{ test_namespace }}" namespace: crd
state: absent state: absent
always: always:
- name: Remove crd namespace - name: Remove crd namespace
k8s: k8s:
kind: Namespace kind: Namespace
name: "{{ test_namespace }}" name: crd
state: absent state: absent
ignore_errors: yes

View File

@@ -1,5 +1,16 @@
--- ---
- block: - block:
- set_fact:
delete_namespace: delete
- name: Ensure namespace exists
k8s:
definition:
apiVersion: v1
kind: Namespace
metadata:
name: "{{ delete_namespace }}"
- name: Add a daemonset - name: Add a daemonset
k8s: k8s:
definition: definition:
@@ -7,14 +18,14 @@
kind: DaemonSet kind: DaemonSet
metadata: metadata:
name: delete-daemonset name: delete-daemonset
namespace: "{{ test_namespace }}" namespace: "{{ delete_namespace }}"
spec: spec:
selector: selector:
matchLabels: matchLabels:
app: "{{ k8s_pod_name }}" app: "{{ k8s_pod_name }}"
template: "{{ k8s_pod_template }}" template: "{{ k8s_pod_template }}"
wait: yes wait: yes
wait_timeout: 400 wait_timeout: 180
vars: vars:
k8s_pod_name: delete-ds k8s_pod_name: delete-ds
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:1 k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:1
@@ -27,7 +38,7 @@
- name: Check if pods exist - name: Check if pods exist
k8s_info: k8s_info:
namespace: "{{ test_namespace }}" namespace: "{{ delete_namespace }}"
kind: Pod kind: Pod
label_selectors: label_selectors:
- "app={{ k8s_pod_name }}" - "app={{ k8s_pod_name }}"
@@ -44,13 +55,13 @@
k8s: k8s:
kind: DaemonSet kind: DaemonSet
name: delete-daemonset name: delete-daemonset
namespace: "{{ test_namespace }}" namespace: "{{ delete_namespace }}"
state: absent state: absent
wait: yes wait: yes
- name: Show status of pods - name: Show status of pods
k8s_info: k8s_info:
namespace: "{{ test_namespace }}" namespace: "{{ delete_namespace }}"
kind: Pod kind: Pod
label_selectors: label_selectors:
- "app={{ k8s_pod_name }}" - "app={{ k8s_pod_name }}"
@@ -63,7 +74,7 @@
- name: Check if pods still exist - name: Check if pods still exist
k8s_info: k8s_info:
namespace: "{{ test_namespace }}" namespace: "{{ delete_namespace }}"
kind: Pod kind: Pod
label_selectors: label_selectors:
- "app={{ k8s_pod_name }}" - "app={{ k8s_pod_name }}"
@@ -80,5 +91,5 @@
- name: Remove namespace - name: Remove namespace
k8s: k8s:
kind: Namespace kind: Namespace
name: "{{ test_namespace }}" name: "{{ delete_namespace }}"
state: absent state: absent

View File

@@ -1,14 +1,20 @@
--- ---
- set_fact:
diff_namespace: "diff"
diff_configmap: "diff-configmap"
- block: - block:
- set_fact: - name: Ensure namespace
diff_namespace: "{{ test_namespace }}" k8s:
kind: Namespace
name: '{{ diff_namespace }}'
# Using option 'apply' set to 'yes' # Using option 'apply' set to 'yes'
- name: Create Pod using apply and diff set to yes - name: Create Pod using apply and diff set to yes
k8s: k8s:
namespace: '{{ diff_namespace }}' namespace: '{{ diff_namespace }}'
apply: yes apply: yes
template: "pod.j2" template: "pod_diff.j2"
diff: yes diff: yes
vars: vars:
pod_name: "pod-apply" pod_name: "pod-apply"
@@ -25,7 +31,7 @@
k8s: k8s:
namespace: '{{ diff_namespace }}' namespace: '{{ diff_namespace }}'
apply: yes apply: yes
template: "pod.j2" template: "pod_diff.j2"
diff: no diff: no
vars: vars:
pod_name: "pod-apply" pod_name: "pod-apply"
@@ -43,7 +49,7 @@
k8s: k8s:
namespace: '{{ diff_namespace }}' namespace: '{{ diff_namespace }}'
state: present state: present
template: "pod.j2" template: "pod_diff.j2"
vars: vars:
pod_name: "pod-patch" pod_name: "pod-patch"
pod_image: "busybox:1.32.0" pod_image: "busybox:1.32.0"
@@ -53,7 +59,7 @@
k8s: k8s:
namespace: '{{ diff_namespace }}' namespace: '{{ diff_namespace }}'
state: patched state: patched
template: "pod.j2" template: "pod_diff.j2"
diff: no diff: no
vars: vars:
pod_name: "pod-patch" pod_name: "pod-patch"
@@ -71,7 +77,7 @@
k8s: k8s:
namespace: '{{ diff_namespace }}' namespace: '{{ diff_namespace }}'
state: patched state: patched
template: "pod.j2" template: "pod_diff.j2"
diff: yes diff: yes
vars: vars:
pod_name: "pod-patch" pod_name: "pod-patch"
@@ -145,4 +151,3 @@
state: absent state: absent
kind: Namespace kind: Namespace
name: '{{ diff_namespace }}' name: '{{ diff_namespace }}'
ignore_errors: true

View File

@@ -2,9 +2,14 @@
- block: - block:
- name: Set common facts - name: Set common facts
set_fact: set_fact:
drain_namespace: "drain"
drain_daemonset_name: "promotheus-dset" drain_daemonset_name: "promotheus-dset"
drain_pod_name: "pod-drain" drain_pod_name: "pod-drain"
drain_deployment_emptydir_name: "deployment-emptydir-drain"
- name: Create {{ drain_namespace }} namespace
k8s:
kind: Namespace
name: '{{ drain_namespace }}'
# It seems that the default ServiceAccount can take a bit to be created # It seems that the default ServiceAccount can take a bit to be created
# right after a cluster is brought up. This can lead to the ServiceAccount # right after a cluster is brought up. This can lead to the ServiceAccount
@@ -14,7 +19,7 @@
k8s_info: k8s_info:
kind: ServiceAccount kind: ServiceAccount
name: default name: default
namespace: "{{ test_namespace }}" namespace: "{{ drain_namespace }}"
wait: yes wait: yes
- name: list cluster nodes - name: list cluster nodes
@@ -37,7 +42,7 @@
- name: Deploy daemonset on cluster - name: Deploy daemonset on cluster
k8s: k8s:
namespace: '{{ test_namespace }}' namespace: '{{ drain_namespace }}'
definition: definition:
apiVersion: apps/v1 apiVersion: apps/v1
kind: DaemonSet kind: DaemonSet
@@ -69,9 +74,8 @@
- name: Create Pods not managed by ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet. - name: Create Pods not managed by ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet.
k8s: k8s:
namespace: '{{ test_namespace }}' namespace: '{{ drain_namespace }}'
wait: yes wait: yes
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
definition: definition:
apiVersion: v1 apiVersion: v1
kind: Pod kind: Pod
@@ -95,62 +99,6 @@
- -c - -c
- while true;do date;sleep 5; done - while true;do date;sleep 5; done
- name: Create Deployment with an emptyDir volume.
k8s:
namespace: '{{ test_namespace }}'
wait: yes
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
definition:
apiVersion: apps/v1
kind: Deployment
metadata:
name: '{{ drain_deployment_emptydir_name }}'
spec:
replicas: 1
selector:
matchLabels:
drain: emptyDir
template:
metadata:
labels:
drain: emptyDir
spec:
metadata:
labels:
drain: emptyDir
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchFields:
- key: metadata.name
operator: In
values:
- '{{ node_to_drain }}'
containers:
- name: c0
image: busybox
command:
- /bin/sh
- -c
- while true;do date;sleep 5; done
volumeMounts:
- mountPath: /emptydir
name: emptydir
volumes:
- name: emptydir
emptyDir: {}
- name: Register emptyDir Pod name
k8s_info:
namespace: '{{ test_namespace }}'
kind: Pod
label_selectors:
- "drain = emptyDir"
register: emptydir_pod_result
failed_when:
- emptydir_pod_result.resources | length != 1
- name: Cordon node - name: Cordon node
k8s_drain: k8s_drain:
state: cordon state: cordon
@@ -176,7 +124,7 @@
- name: Get pods - name: Get pods
k8s_info: k8s_info:
kind: Pod kind: Pod
namespace: '{{ test_namespace }}' namespace: '{{ drain_namespace }}'
register: Pod register: Pod
- name: assert that pods are running on cordoned node - name: assert that pods are running on cordoned node
@@ -219,16 +167,14 @@
- drain_result is failed - drain_result is failed
- '"cannot delete DaemonSet-managed Pods" in drain_result.msg' - '"cannot delete DaemonSet-managed Pods" in drain_result.msg'
- '"cannot delete Pods not managed by ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet" in drain_result.msg' - '"cannot delete Pods not managed by ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet" in drain_result.msg'
- '"cannot delete Pods with local storage" in drain_result.msg'
- name: Drain node using ignore_daemonsets, force, and delete_emptydir_data options - name: Drain node using ignore_daemonsets and force options
k8s_drain: k8s_drain:
state: drain state: drain
name: '{{ node_to_drain }}' name: '{{ node_to_drain }}'
delete_options: delete_options:
force: true force: true
ignore_daemonsets: true ignore_daemonsets: true
delete_emptydir_data: true
wait_timeout: 0 wait_timeout: 0
register: drain_result register: drain_result
@@ -240,20 +186,12 @@
- name: assert that unmanaged pod were deleted - name: assert that unmanaged pod were deleted
k8s_info: k8s_info:
namespace: '{{ test_namespace }}' namespace: '{{ drain_namespace }}'
kind: Pod kind: Pod
name: '{{ drain_pod_name }}' name: '{{ drain_pod_name }}'
register: _result register: _result
failed_when: _result.resources failed_when: _result.resources
- name: assert that emptyDir pod was deleted
k8s_info:
namespace: '{{ test_namespace }}'
kind: Pod
name: "{{ emptydir_pod_result.resources[0].metadata.name }}"
register: _result
failed_when: _result.resources | length != 0
- name: Test drain idempotency - name: Test drain idempotency
k8s_drain: k8s_drain:
state: drain state: drain
@@ -261,7 +199,6 @@
delete_options: delete_options:
force: true force: true
ignore_daemonsets: true ignore_daemonsets: true
delete_emptydir_data: true
register: drain_result register: drain_result
- name: Check idempotency - name: Check idempotency
@@ -272,7 +209,7 @@
- name: Get DaemonSet - name: Get DaemonSet
k8s_info: k8s_info:
kind: DaemonSet kind: DaemonSet
namespace: '{{ test_namespace }}' namespace: '{{ drain_namespace }}'
name: '{{ drain_daemonset_name }}' name: '{{ drain_daemonset_name }}'
register: dset_result register: dset_result
@@ -298,4 +235,4 @@
k8s: k8s:
state: absent state: absent
kind: namespace kind: namespace
name: '{{ test_namespace }}' name: '{{ drain_namespace }}'

View File

@@ -0,0 +1,65 @@
---
- vars:
exec_namespace: k8s-exec
pod: sleep-pod
exec_pod_definition:
apiVersion: v1
kind: Pod
metadata:
name: "{{ pod }}"
namespace: "{{ exec_namespace }}"
spec:
containers:
- name: sleeper
image: busybox
command: ["sleep", "infinity"]
block:
- name: "Ensure that {{ exec_namespace }} namespace exists"
k8s:
kind: Namespace
name: "{{ exec_namespace }}"
- name: "Create a pod"
k8s:
definition: "{{ exec_pod_definition }}"
wait: yes
wait_sleep: 1
wait_timeout: 30
- name: "Execute a command"
k8s_exec:
pod: "{{ pod }}"
namespace: "{{ exec_namespace }}"
command: cat /etc/resolv.conf
register: output
- name: "Show k8s_exec output"
debug:
var: output
- name: "Assert k8s_exec output is correct"
assert:
that:
- "'nameserver' in output.stdout"
- name: Check if rc is returned for the given command
k8s_exec:
namespace: "{{ exec_namespace }}"
pod: "{{ pod }}"
command: 'false'
register: command_status
ignore_errors: True
- name: Check last command status
assert:
that:
- command_status.rc != 0
- command_status.return_code != 0
always:
- name: "Cleanup namespace"
k8s:
kind: Namespace
name: "{{ exec_namespace }}"
state: absent

View File

@@ -60,16 +60,11 @@
environment: environment:
K8S_AUTH_KUBECONFIG: ~/.kube/customconfig K8S_AUTH_KUBECONFIG: ~/.kube/customconfig
- name: Get currently installed version of kubernetes
ansible.builtin.command: python -c "import kubernetes; print(kubernetes.__version__)"
register: kubernetes_version
- name: Using in-memory kubeconfig should succeed - name: Using in-memory kubeconfig should succeed
kubernetes.core.k8s: kubernetes.core.k8s:
name: testing name: testing
kind: Namespace kind: Namespace
kubeconfig: "{{ lookup('file', '~/.kube/customconfig') | from_yaml }}" kubeconfig: "{{ lookup('file', '~/.kube/customconfig') | from_yaml }}"
when: kubernetes_version.stdout is version("17.17.0", ">=")
always: always:
- name: Return kubeconfig - name: Return kubeconfig
@@ -426,49 +421,6 @@
that: that:
- result.resources[0].data.testkey == "{{ cmap_data.stdout | b64encode }}" - result.resources[0].data.testkey == "{{ cmap_data.stdout | b64encode }}"
# test setting module defaults for kubernetes.core.k8s_info
- block:
- name: Create a namespace
kubernetes.core.k8s:
name: test-namespace-module-defaults
kind: Namespace
register: output
- name: Create a ConfigMap
kubernetes.core.k8s:
kind: ConfigMap
name: test-configmap-1
definition:
data:
key1: value1
- name: Create another ConfigMap
kubernetes.core.k8s:
kind: ConfigMap
name: test-configmap-2
definition:
data:
key2: value2
- name: Get list of all ConfigMaps in namespace specified in module_defaults
kubernetes.core.k8s_info:
kind: ConfigMap
register: configmap_info
- name: assert that the ConfigMaps are created in and info is retrieved for namespace specified in module_defaults
assert:
that:
- configmap_info.resources[1].metadata.name == "test-configmap-1"
- configmap_info.resources[1].metadata.namespace == "test-namespace-module-defaults"
- configmap_info.resources[2].metadata.name == "test-configmap-2"
- configmap_info.resources[2].metadata.namespace == "test-namespace-module-defaults"
module_defaults:
group/kubernetes.core.k8s:
namespace: test-namespace-module-defaults
when: ansible_version.full is version("2.12", ">=")
always: always:
- name: Delete all namespaces - name: Delete all namespaces
k8s: k8s:
@@ -502,8 +454,4 @@
apiVersion: v1 apiVersion: v1
metadata: metadata:
name: testing6 name: testing6
- kind: Namespace
apiVersion: v1
metadata:
name: test-namespace-module-defaults
ignore_errors: yes ignore_errors: yes

View File

@@ -1,6 +1,6 @@
--- ---
- vars: - vars:
gc_namespace: "{{ test_namespace }}" gc_namespace: garbage
gc_name: garbage-job gc_name: garbage-job
# This is a job definition that runs for 10 minutes and won't gracefully # This is a job definition that runs for 10 minutes and won't gracefully
# shutdown. It allows us to test foreground vs background deletion. # shutdown. It allows us to test foreground vs background deletion.
@@ -25,6 +25,14 @@
restartPolicy: Never restartPolicy: Never
block: block:
- name: Ensure namespace exists
k8s:
definition:
apiVersion: v1
kind: Namespace
metadata:
name: "{{ gc_namespace }}"
- name: Add a job - name: Add a job
k8s: k8s:
definition: "{{ job_definition }}" definition: "{{ job_definition }}"
@@ -46,7 +54,6 @@
namespace: "{{ gc_namespace }}" namespace: "{{ gc_namespace }}"
name: "{{ wait_job.resources[0].metadata.name }}" name: "{{ wait_job.resources[0].metadata.name }}"
wait: yes wait: yes
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
register: job register: job
- name: Assert job's pod is running - name: Assert job's pod is running
@@ -60,7 +67,7 @@
namespace: "{{ gc_namespace }}" namespace: "{{ gc_namespace }}"
state: absent state: absent
wait: yes wait: yes
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" wait_timeout: 100
delete_options: delete_options:
propagationPolicy: Foreground propagationPolicy: Foreground
@@ -97,7 +104,6 @@
namespace: "{{ gc_namespace }}" namespace: "{{ gc_namespace }}"
name: "{{ wait_job.resources[0].metadata.name }}" name: "{{ wait_job.resources[0].metadata.name }}"
wait: yes wait: yes
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
register: job register: job
- name: Assert job's pod is running - name: Assert job's pod is running
@@ -111,7 +117,7 @@
namespace: "{{ gc_namespace }}" namespace: "{{ gc_namespace }}"
state: absent state: absent
wait: yes wait: yes
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" wait_timeout: 100
delete_options: delete_options:
propagationPolicy: "Background" propagationPolicy: "Background"
@@ -149,7 +155,6 @@
namespace: "{{ gc_namespace }}" namespace: "{{ gc_namespace }}"
name: "{{ wait_job.resources[0].metadata.name }}" name: "{{ wait_job.resources[0].metadata.name }}"
wait: yes wait: yes
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
register: job register: job
- name: Assert job's pod is running - name: Assert job's pod is running
@@ -163,7 +168,7 @@
namespace: "{{ gc_namespace }}" namespace: "{{ gc_namespace }}"
state: absent state: absent
wait: yes wait: yes
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" wait_timeout: 100
delete_options: delete_options:
propagationPolicy: "Orphan" propagationPolicy: "Orphan"
@@ -214,7 +219,7 @@
preconditions: preconditions:
uid: "{{ job.result.metadata.uid }}" uid: "{{ job.result.metadata.uid }}"
wait: yes wait: yes
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" wait_timeout: 100
- name: Check that job is deleted - name: Check that job is deleted
k8s_info: k8s_info:
@@ -233,4 +238,3 @@
kind: Namespace kind: Namespace
name: "{{ gc_namespace }}" name: "{{ gc_namespace }}"
state: absent state: absent
ignore_errors: true

View File

@@ -1,10 +1,18 @@
--- ---
- block: - block:
- set_fact: - set_fact:
wait_namespace: "{{ test_namespace }}" wait_namespace: wait
multi_pod_one: multi-pod-1 multi_pod_one: multi-pod-1
multi_pod_two: multi-pod-2 multi_pod_two: multi-pod-2
- name: Ensure namespace exists
k8s:
definition:
apiVersion: v1
kind: Namespace
metadata:
name: "{{ wait_namespace }}"
- name: Add a simple pod with initContainer - name: Add a simple pod with initContainer
k8s: k8s:
definition: definition:
@@ -30,7 +38,7 @@
namespace: "{{ wait_namespace }}" namespace: "{{ wait_namespace }}"
wait: yes wait: yes
wait_sleep: 5 wait_sleep: 5
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" wait_timeout: 400
register: wait_info register: wait_info
- name: Assert that pod creation succeeded - name: Assert that pod creation succeeded
@@ -48,7 +56,6 @@
namespace: "{{ wait_namespace }}" namespace: "{{ wait_namespace }}"
state: absent state: absent
wait: yes wait: yes
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
ignore_errors: yes ignore_errors: yes
register: short_wait_remove_pod register: short_wait_remove_pod
@@ -104,7 +111,7 @@
namespace: "{{ wait_namespace }}" namespace: "{{ wait_namespace }}"
wait: yes wait: yes
wait_sleep: 5 wait_sleep: 5
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" wait_timeout: 400
label_selectors: label_selectors:
- run == multi-box - run == multi-box
register: wait_info register: wait_info
@@ -125,7 +132,6 @@
namespace: "{{ wait_namespace }}" namespace: "{{ wait_namespace }}"
state: absent state: absent
wait: yes wait: yes
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
ignore_errors: yes ignore_errors: yes
register: multi_pod_one_remove register: multi_pod_one_remove
@@ -143,7 +149,6 @@
namespace: "{{ wait_namespace }}" namespace: "{{ wait_namespace }}"
state: absent state: absent
wait: yes wait: yes
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
ignore_errors: yes ignore_errors: yes
register: multi_pod_two_remove register: multi_pod_two_remove
@@ -186,7 +191,7 @@
name: does-not-exist name: does-not-exist
namespace: "{{ wait_namespace }}" namespace: "{{ wait_namespace }}"
wait: yes wait: yes
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" wait_timeout: 45
register: result register: result
- name: Check that module waited - name: Check that module waited
@@ -194,38 +199,6 @@
that: that:
- "{{ lookup('pipe', 'date +%s') }} - {{ start }} > 30" - "{{ lookup('pipe', 'date +%s') }} - {{ start }} > 30"
- name: Create simple pod
k8s:
definition:
apiVersion: v1
kind: Pod
metadata:
name: wait-pod-1
namespace: "{{ wait_namespace }}"
spec:
containers:
- image: busybox
name: busybox
command:
- /bin/sh
- -c
- while true; do sleep 5; done
- name: Wait for multiple non-existent pods to be created
k8s_info:
kind: Pod
namespace: "{{ wait_namespace }}"
label_selectors:
- thislabel=doesnotexist
wait: yes
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
register: result
- name: Assert no pods were found
assert:
that:
- not result.resources
vars: vars:
k8s_pod_name: pod-info-1 k8s_pod_name: pod-info-1
@@ -235,4 +208,3 @@
kind: Namespace kind: Namespace
name: "{{ wait_namespace }}" name: "{{ wait_namespace }}"
state: absent state: absent
ignore_errors: true

View File

@@ -1,16 +1,21 @@
- vars: - vars:
namespace: json-patch
pod: json-patch pod: json-patch
deployment: json-patch deployment: json-patch
k8s_wait_timeout: 400
block: block:
- name: Ensure namespace exists
kubernetes.core.k8s:
kind: namespace
name: "{{ namespace }}"
- name: Create a simple pod - name: Create a simple pod
kubernetes.core.k8s: kubernetes.core.k8s:
definition: definition:
apiVersion: v1 apiVersion: v1
kind: Pod kind: Pod
metadata: metadata:
namespace: "{{ test_namespace }}" namespace: "{{ namespace }}"
name: "{{ pod }}" name: "{{ pod }}"
labels: labels:
label1: foo label1: foo
@@ -23,12 +28,11 @@
- -c - -c
- while true; do echo $(date); sleep 10; done - while true; do echo $(date); sleep 10; done
wait: yes wait: yes
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
- name: Add a label and replace the image in checkmode - name: Add a label and replace the image in checkmode
kubernetes.core.k8s_json_patch: kubernetes.core.k8s_json_patch:
kind: Pod kind: Pod
namespace: "{{ test_namespace }}" namespace: "{{ namespace }}"
name: "{{ pod }}" name: "{{ pod }}"
patch: patch:
- op: add - op: add
@@ -53,7 +57,7 @@
kubernetes.core.k8s_info: kubernetes.core.k8s_info:
kind: Pod kind: Pod
name: "{{ pod }}" name: "{{ pod }}"
namespace: "{{ test_namespace }}" namespace: "{{ namespace }}"
register: result register: result
- name: Assert pod has not changed - name: Assert pod has not changed
@@ -65,7 +69,7 @@
- name: Add a label and replace the image - name: Add a label and replace the image
kubernetes.core.k8s_json_patch: kubernetes.core.k8s_json_patch:
kind: Pod kind: Pod
namespace: "{{ test_namespace }}" namespace: "{{ namespace }}"
name: "{{ pod }}" name: "{{ pod }}"
patch: patch:
- op: add - op: add
@@ -75,7 +79,6 @@
path: /spec/containers/0/image path: /spec/containers/0/image
value: busybox:glibc value: busybox:glibc
register: result register: result
diff: no
- name: Assert patch was made - name: Assert patch was made
assert: assert:
@@ -87,7 +90,7 @@
kubernetes.core.k8s_info: kubernetes.core.k8s_info:
kind: Pod kind: Pod
name: "{{ pod }}" name: "{{ pod }}"
namespace: "{{ test_namespace }}" namespace: "{{ namespace }}"
register: result register: result
- name: Assert that both patch operations have been applied - name: Assert that both patch operations have been applied
@@ -99,7 +102,7 @@
- name: Apply the same patch to the pod - name: Apply the same patch to the pod
kubernetes.core.k8s_json_patch: kubernetes.core.k8s_json_patch:
kind: Pod kind: Pod
namespace: "{{ test_namespace }}" namespace: "{{ namespace }}"
name: "{{ pod }}" name: "{{ pod }}"
patch: patch:
- op: add - op: add
@@ -117,13 +120,12 @@
- name: Create a simple deployment - name: Create a simple deployment
kubernetes.core.k8s: kubernetes.core.k8s:
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
wait: yes wait: yes
definition: definition:
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
namespace: "{{ test_namespace }}" namespace: "{{ namespace }}"
name: "{{ deployment }}" name: "{{ deployment }}"
labels: labels:
name: "{{ deployment }}" name: "{{ deployment }}"
@@ -148,14 +150,13 @@
- name: Apply patch and wait for deployment to be ready - name: Apply patch and wait for deployment to be ready
kubernetes.core.k8s_json_patch: kubernetes.core.k8s_json_patch:
kind: Deployment kind: Deployment
namespace: "{{ test_namespace }}" namespace: "{{ namespace }}"
name: "{{ deployment }}" name: "{{ deployment }}"
patch: patch:
- op: replace - op: replace
path: /spec/replicas path: /spec/replicas
value: 3 value: 3
wait: yes wait: yes
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
register: result register: result
- name: Assert all replicas are available - name: Assert all replicas are available
@@ -167,6 +168,6 @@
- name: Ensure namespace has been deleted - name: Ensure namespace has been deleted
kubernetes.core.k8s: kubernetes.core.k8s:
kind: Namespace kind: Namespace
name: "{{ test_namespace }}" name: "{{ namespace }}"
state: absent state: absent
ignore_errors: yes ignore_errors: yes

View File

@@ -1,7 +1,7 @@
--- ---
- block: - block:
- set_fact: - set_fact:
selector_namespace: "{{ test_namespace }}" selector_namespace: "selector"
selector_pod_delete: "pod-selector-delete" selector_pod_delete: "pod-selector-delete"
selector_pod_apply: "pod-selector-apply" selector_pod_apply: "pod-selector-apply"
selector_pod_create: selector_pod_create:
@@ -10,6 +10,11 @@
- "pod-selector-apply-02" - "pod-selector-apply-02"
- "pod-selector-apply-03" - "pod-selector-apply-03"
- name: Ensure namespace selector
k8s:
kind: namespace
name: '{{ selector_namespace }}'
# Resource deletion using label selector (equality-based requirement) # Resource deletion using label selector (equality-based requirement)
- name: Create simple pod - name: Create simple pod
k8s: k8s:
@@ -40,7 +45,7 @@
label_selectors: label_selectors:
- ansible.dev/team=cloud - ansible.dev/team=cloud
wait: yes wait: yes
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" wait_timeout: 180
- name: Ensure resources have been deleted - name: Ensure resources have been deleted
k8s_info: k8s_info:
@@ -82,7 +87,7 @@
label_selectors: label_selectors:
- environment in (test, qa) - environment in (test, qa)
wait: yes wait: yes
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" wait_timeout: 180
register: result register: result
- name: check that no resources were deleted - name: check that no resources were deleted
@@ -110,7 +115,7 @@
label_selectors: label_selectors:
- environment in (production) - environment in (production)
wait: yes wait: yes
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" wait_timeout: 180
register: result register: result
- name: check result is changed - name: check result is changed

View File

@@ -1,9 +1,15 @@
--- ---
- block: - block:
- name: Ensure testing1 namespace exists
k8s:
api_version: v1
kind: Namespace
name: testing1
- block: - block:
- name: Create configmaps - name: Create configmaps
k8s: k8s:
namespace: "{{ test_namespace }}" namespace: testing1
definition: definition:
apiVersion: v1 apiVersion: v1
kind: ConfigMapList kind: ConfigMapList
@@ -13,7 +19,7 @@
k8s_info: k8s_info:
api_version: v1 api_version: v1
kind: ConfigMap kind: ConfigMap
namespace: "{{ test_namespace }}" namespace: testing1
label_selectors: label_selectors:
- app=test - app=test
register: cms register: cms
@@ -26,7 +32,7 @@
- name: Delete configmaps - name: Delete configmaps
k8s: k8s:
state: absent state: absent
namespace: "{{ test_namespace }}" namespace: testing1
definition: definition:
apiVersion: v1 apiVersion: v1
kind: ConfigMapList kind: ConfigMapList
@@ -36,7 +42,7 @@
k8s_info: k8s_info:
api_version: v1 api_version: v1
kind: ConfigMap kind: ConfigMap
namespace: "{{ test_namespace }}" namespace: testing1
label_selectors: label_selectors:
- app=test - app=test
register: cms register: cms
@@ -68,18 +74,18 @@
- block: - block:
- name: Create list of arbitrary resources - name: Create list of arbitrary resources
k8s: k8s:
namespace: "{{ test_namespace }}" namespace: testing1
definition: definition:
apiVersion: v1 apiVersion: v1
kind: List kind: List
namespace: "{{ test_namespace }}" namespace: testing1
items: '{{ resources }}' items: '{{ resources }}'
- name: Get the created resources - name: Get the created resources
k8s_info: k8s_info:
api_version: '{{ item.apiVersion }}' api_version: '{{ item.apiVersion }}'
kind: '{{ item.kind }}' kind: '{{ item.kind }}'
namespace: "{{ test_namespace }}" namespace: testing1
name: '{{ item.metadata.name }}' name: '{{ item.metadata.name }}'
register: list_resources register: list_resources
with_items: '{{ resources }}' with_items: '{{ resources }}'
@@ -91,18 +97,18 @@
- name: Delete list of arbitrary resources - name: Delete list of arbitrary resources
k8s: k8s:
state: absent state: absent
namespace: "{{ test_namespace }}" namespace: testing1
definition: definition:
apiVersion: v1 apiVersion: v1
kind: List kind: List
namespace: "{{ test_namespace }}" namespace: testing1
items: '{{ resources }}' items: '{{ resources }}'
- name: Get the resources - name: Get the resources
k8s_info: k8s_info:
api_version: '{{ item.apiVersion }}' api_version: '{{ item.apiVersion }}'
kind: '{{ item.kind }}' kind: '{{ item.kind }}'
namespace: "{{ test_namespace }}" namespace: testing1
name: '{{ item.metadata.name }}' name: '{{ item.metadata.name }}'
register: list_resources register: list_resources
with_items: '{{ resources }}' with_items: '{{ resources }}'
@@ -133,9 +139,9 @@
name: port-8000-tcp name: port-8000-tcp
port: 8000 port: 8000
always: always:
- name: Remove "{{ test_namespace }}" namespace - name: Remove testing1 namespace
k8s: k8s:
kind: Namespace kind: Namespace
name: "{{ test_namespace }}" name: testing1
state: absent state: absent
ignore_errors: yes ignore_errors: yes

View File

@@ -1,15 +1,19 @@
--- ---
- block: - block:
- name: ensure that k8s-log namespace exists
k8s:
kind: Namespace
name: k8s-log
- name: create hello-world deployment - name: create hello-world deployment
k8s: k8s:
wait: yes wait: yes
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
definition: definition:
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: hello-world name: hello-world
namespace: "{{ test_namespace }}" namespace: k8s-log
spec: spec:
selector: selector:
matchLabels: matchLabels:
@@ -30,7 +34,7 @@
k8s_log: k8s_log:
api_version: apps/v1 api_version: apps/v1
kind: Deployment kind: Deployment
namespace: "{{ test_namespace }}" namespace: k8s-log
name: hello-world name: hello-world
register: deployment_log register: deployment_log
@@ -43,7 +47,7 @@
- name: retrieve the log with a label selector - name: retrieve the log with a label selector
k8s_log: k8s_log:
namespace: "{{ test_namespace }}" namespace: k8s-log
label_selectors: label_selectors:
- 'app=hello-world' - 'app=hello-world'
register: label_selector_log register: label_selector_log
@@ -58,14 +62,14 @@
- name: get the hello-world pod - name: get the hello-world pod
k8s_info: k8s_info:
kind: Pod kind: Pod
namespace: "{{ test_namespace }}" namespace: k8s-log
label_selectors: label_selectors:
- 'app=hello-world' - 'app=hello-world'
register: k8s_log_pods register: k8s_log_pods
- name: retrieve the log directly with the pod name - name: retrieve the log directly with the pod name
k8s_log: k8s_log:
namespace: "{{ test_namespace }}" namespace: k8s-log
name: '{{ k8s_log_pods.resources.0.metadata.name }}' name: '{{ k8s_log_pods.resources.0.metadata.name }}'
register: pod_log register: pod_log
@@ -80,7 +84,7 @@
k8s: k8s:
state: present state: present
wait: yes wait: yes
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" wait_timeout: 120
wait_condition: wait_condition:
type: Complete type: Complete
status: 'True' status: 'True'
@@ -89,7 +93,7 @@
kind: Job kind: Job
metadata: metadata:
name: int-log name: int-log
namespace: "{{ test_namespace }}" namespace: k8s-log
spec: spec:
template: template:
spec: spec:
@@ -104,7 +108,7 @@
k8s_log: k8s_log:
api_version: batch/v1 api_version: batch/v1
kind: Job kind: Job
namespace: "{{ test_namespace }}" namespace: k8s-log
name: int-log name: int-log
register: job_logs register: job_logs
@@ -116,6 +120,5 @@
- name: ensure that namespace is removed - name: ensure that namespace is removed
k8s: k8s:
kind: Namespace kind: Namespace
name: "{{ test_namespace }}" name: k8s-log
state: absent state: absent
ignore_errors: true

View File

@@ -2,9 +2,9 @@
- block: - block:
- set_fact: - set_fact:
pre_test1: "{{ lookup('kubernetes.core.k8s', kind='Namespace', label_selector='namespace_label=app_development') }}" pre_test1: "{{ lookup('kubernetes.core.k8s', kind='Namespace', label_selector='namespace_label=app_development') }}"
pre_test2: "{{ lookup('kubernetes.core.k8s', kind='Namespace', resource_name=test_namespace[0]) }}" pre_test2: "{{ lookup('kubernetes.core.k8s', kind='Namespace', resource_name='app-development-one') }}"
pre_test3: "{{ query('kubernetes.core.k8s', kind='Namespace', label_selector='namespace_label=app_development') }}" pre_test3: "{{ query('kubernetes.core.k8s', kind='Namespace', label_selector='namespace_label=app_development') }}"
pre_test4: "{{ query('kubernetes.core.k8s', kind='Namespace', resource_name=test_namespace[0]) }}" pre_test4: "{{ query('kubernetes.core.k8s', kind='Namespace', resource_name='app-development-one') }}"
# https://github.com/ansible-collections/kubernetes.core/issues/147 # https://github.com/ansible-collections/kubernetes.core/issues/147
- name: Create a namespace with label - name: Create a namespace with label
@@ -13,17 +13,17 @@
apiVersion: v1 apiVersion: v1
kind: Namespace kind: Namespace
metadata: metadata:
name: "{{ test_namespace[0] }}" name: "app-development-one"
labels: labels:
namespace_label: "app_development" namespace_label: "app_development"
- set_fact: - set_fact:
test1: "{{ lookup('kubernetes.core.k8s', kind='Namespace', label_selector='namespace_label=app_development', wantlist=True) }}" test1: "{{ lookup('kubernetes.core.k8s', kind='Namespace', label_selector='namespace_label=app_development', wantlist=True) }}"
test2: "{{ query('kubernetes.core.k8s', kind='Namespace', label_selector='namespace_label=app_development') }}" test2: "{{ query('kubernetes.core.k8s', kind='Namespace', label_selector='namespace_label=app_development') }}"
test3: "{{ lookup('kubernetes.core.k8s', kind='Namespace', resource_name=test_namespace[0], wantlist=True) }}" test3: "{{ lookup('kubernetes.core.k8s', kind='Namespace', resource_name='app-development-one', wantlist=True) }}"
test4: "{{ query('kubernetes.core.k8s', kind='Namespace', resource_name=test_namespace[0]) }}" test4: "{{ query('kubernetes.core.k8s', kind='Namespace', resource_name='app-development-one') }}"
test5: "{{ lookup('kubernetes.core.k8s', kind='Namespace', label_selector='namespace_label=app_development') }}" test5: "{{ lookup('kubernetes.core.k8s', kind='Namespace', label_selector='namespace_label=app_development') }}"
test6: "{{ lookup('kubernetes.core.k8s', kind='Namespace', resource_name=test_namespace[0]) }}" test6: "{{ lookup('kubernetes.core.k8s', kind='Namespace', resource_name='app-development-one') }}"
test7: "{{ lookup('kubernetes.core.k8s', kind='Ingress', api_version='networking.k8s.io/vINVALID', errors='ignore') }}" test7: "{{ lookup('kubernetes.core.k8s', kind='Ingress', api_version='networking.k8s.io/vINVALID', errors='ignore') }}"
- set_fact: - set_fact:
@@ -64,20 +64,20 @@
apiVersion: v1 apiVersion: v1
kind: Namespace kind: Namespace
metadata: metadata:
name: "{{ test_namespace[1] }}" name: "app-development-two"
labels: labels:
namespace_label: "app_development" namespace_label: "app_development"
- set_fact: - set_fact:
test1: "{{ lookup('kubernetes.core.k8s', kind='Namespace', label_selector='namespace_label=app_development', wantlist=True) }}" test1: "{{ lookup('kubernetes.core.k8s', kind='Namespace', label_selector='namespace_label=app_development', wantlist=True) }}"
test2: "{{ query('kubernetes.core.k8s', kind='Namespace', label_selector='namespace_label=app_development') }}" test2: "{{ query('kubernetes.core.k8s', kind='Namespace', label_selector='namespace_label=app_development') }}"
test3: "{{ lookup('kubernetes.core.k8s', kind='Namespace', resource_name=test_namespace[0], wantlist=True) }}" test3: "{{ lookup('kubernetes.core.k8s', kind='Namespace', resource_name='app-development-one', wantlist=True) }}"
test4: "{{ query('kubernetes.core.k8s', kind='Namespace', resource_name=test_namespace[0]) }}" test4: "{{ query('kubernetes.core.k8s', kind='Namespace', resource_name='app-development-one') }}"
test5: "{{ lookup('kubernetes.core.k8s', kind='Namespace', resource_name=test_namespace[1], wantlist=True) }}" test5: "{{ lookup('kubernetes.core.k8s', kind='Namespace', resource_name='app-development-two', wantlist=True) }}"
test6: "{{ query('kubernetes.core.k8s', kind='Namespace', resource_name=test_namespace[1]) }}" test6: "{{ query('kubernetes.core.k8s', kind='Namespace', resource_name='app-development-two') }}"
test7: "{{ lookup('kubernetes.core.k8s', kind='Namespace', label_selector='namespace_label=app_development') }}" test7: "{{ lookup('kubernetes.core.k8s', kind='Namespace', label_selector='namespace_label=app_development') }}"
test8: "{{ lookup('kubernetes.core.k8s', kind='Namespace', resource_name=test_namespace[0]) }}" test8: "{{ lookup('kubernetes.core.k8s', kind='Namespace', resource_name='app-development-one') }}"
test9: "{{ lookup('kubernetes.core.k8s', kind='Namespace', resource_name=test_namespace[1]) }}" test9: "{{ lookup('kubernetes.core.k8s', kind='Namespace', resource_name='app-development-two') }}"
- name: Assert that every test is passed after creating second object - name: Assert that every test is passed after creating second object
assert: assert:
@@ -110,4 +110,3 @@
with_items: with_items:
- one - one
- two - two
ignore_errors: true

View File

@@ -1,10 +1,14 @@
--- ---
- block: - block:
- set_fact: - set_fact:
kustomize_ns: "{{ test_namespace }}" kustomize_ns: "kustomize"
- name: create environment for test - name: create environment for test
block: block:
- name: Ensure namespace
k8s:
kind: Namespace
name: "{{ kustomize_ns }}"
- name: Create temp directory - name: Create temp directory
tempfile: tempfile:
@@ -55,26 +59,17 @@
- set_fact: - set_fact:
kustomize_binary: "{{ _install.stdout | regex_search('kustomize installed to (.*)', '\\1') | list | join('') }}" kustomize_binary: "{{ _install.stdout | regex_search('kustomize installed to (.*)', '\\1') | list | join('') }}"
kubectl_release: "v1.22.0"
kubectl_binary: "{{ tmp_dir_path }}/kubectl" kubectl_binary: "{{ tmp_dir_path }}/kubectl"
- name: Install Kubectl - name: Download kubeclt executable used to compare results
ansible.builtin.get_url: get_url:
url: "https://dl.k8s.io/release/{{ kubectl_release }}/bin/linux/amd64/kubectl" url: https://dl.k8s.io/release/v1.21.3/bin/linux/amd64/kubectl
dest: "{{ kubectl_binary }}" dest: "{{ kubectl_binary }}"
register: result
until: result is not failed
retries: 3
delay: 60
become: true
- name: Make kubectl as executable - name: make kubectl executable
ansible.builtin.file: ansible.builtin.file:
path: '{{ item }}' path: "{{ kubectl_binary }}"
mode: '0755' mode: "+x"
become: true
with_items:
- "{{ kubectl_binary }}"
- name: Run lookup using kustomize binary - name: Run lookup using kustomize binary
set_fact: set_fact:

View File

@@ -1,11 +1,17 @@
- block: - block:
- name: Define common facts - name: Define common facts
set_fact: set_fact:
k8s_patch_namespace: "{{ test_namespace }}" k8s_patch_namespace: "patch"
k8s_strategic_merge: "strategic-merge" k8s_strategic_merge: "strategic-merge"
k8s_merge: "json-merge" k8s_merge: "json-merge"
k8s_json: "json-patch" k8s_json: "json-patch"
- name: Ensure the namespace exist
kubernetes.core.k8s:
kind: namespace
name: "{{ k8s_patch_namespace }}"
# Strategic merge # Strategic merge
- name: create a simple nginx deployment - name: create a simple nginx deployment
kubernetes.core.k8s: kubernetes.core.k8s:

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