mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-11 20:12:18 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6dadd06252 | ||
|
|
69dc7d5c5d | ||
|
|
2fa1c2c6e5 | ||
|
|
f2623dd3cf | ||
|
|
8772d8c997 | ||
|
|
a32108f64f | ||
|
|
365e5e9159 | ||
|
|
448a68da3d | ||
|
|
46acab9c4c | ||
|
|
fdb77182c8 |
1
.github/workflows/integration-tests.yaml
vendored
1
.github/workflows/integration-tests.yaml
vendored
@@ -26,6 +26,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
path: ${{ env.source_dir }}
|
path: ${{ env.source_dir }}
|
||||||
fetch-depth: "0"
|
fetch-depth: "0"
|
||||||
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
|
||||||
- name: list changes for pull request
|
- name: list changes for pull request
|
||||||
id: splitter
|
id: splitter
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -21,3 +21,6 @@ tests/integration/*-chart-*.tgz
|
|||||||
# ansible-test generated file
|
# ansible-test generated file
|
||||||
tests/integration/inventory
|
tests/integration/inventory
|
||||||
tests/integration/*-*.yml
|
tests/integration/*-*.yml
|
||||||
|
|
||||||
|
# VS Code settings
|
||||||
|
.vscode/
|
||||||
|
|||||||
@@ -4,6 +4,25 @@ Kubernetes Collection Release Notes
|
|||||||
|
|
||||||
.. contents:: Topics
|
.. contents:: Topics
|
||||||
|
|
||||||
|
v6.2.0
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
This release adds minor changes and bugfixes, including support of skip-schema-validation in ``helm`` module and removing deprecated ``ansible.module_utils.six`` imports.
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- Add support of skip-schema-validation in ``helm`` module (https://github.com/ansible-collections/kubernetes.core/pull/995)
|
||||||
|
- kustomize - Add support of local environ (https://github.com/ansible-collections/kubernetes.core/pull/786).
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
--------
|
||||||
|
|
||||||
|
- Remove ``ansible.module_utils.six`` imports to avoid warnings (https://github.com/ansible-collections/kubernetes.core/pull/998).
|
||||||
|
- Update the ``k8s_cp`` module to also work for init containers (https://github.com/ansible-collections/kubernetes.core/pull/971).
|
||||||
|
|
||||||
v6.1.0
|
v6.1.0
|
||||||
======
|
======
|
||||||
@@ -11,7 +30,7 @@ v6.1.0
|
|||||||
Release Summary
|
Release Summary
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
This release includes a fix for kubeconfig output, added ``plain_http`` and ``take_ownership`` parameters for helm modules, support for ``hidden_fields`` in ``k8s_json_patch``, documented lack of idempotency support in ``helm_registry_auth`` with ``helm ≥ 3.18.0``, and improved ``k8s_rollback`` test coverage.
|
This release adds ``plain_http`` and ``take_ownership`` parameters for helm modules, support for ``hidden_fields`` in ``k8s_json_patch``, documented lack of idempotency support in ``helm_registry_auth`` with ``helm ≥ 3.18.0``, and improved ``k8s_rollback`` test coverage.
|
||||||
|
|
||||||
Minor Changes
|
Minor Changes
|
||||||
-------------
|
-------------
|
||||||
@@ -37,26 +56,54 @@ Breaking Changes / Porting Guide
|
|||||||
- Remove deprecated ``k8s`` invetory plugin (https://github.com/ansible-collections/kubernetes.core/pull/867).
|
- Remove deprecated ``k8s`` invetory plugin (https://github.com/ansible-collections/kubernetes.core/pull/867).
|
||||||
- Remove support for ``ansible-core<2.16`` (https://github.com/ansible-collections/kubernetes.core/pull/867).
|
- Remove support for ``ansible-core<2.16`` (https://github.com/ansible-collections/kubernetes.core/pull/867).
|
||||||
|
|
||||||
|
v5.4.1
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
This release includes bugfixes for k8s service field handling, k8s_cp init containers support, and removes deprecated ansible.module_utils.six imports.
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
--------
|
||||||
|
|
||||||
|
- Remove ``ansible.module_utils.six`` imports to avoid warnings (https://github.com/ansible-collections/kubernetes.core/pull/998).
|
||||||
|
- Update the `k8s_cp` module to also work for init containers (https://github.com/ansible-collections/kubernetes.core/pull/971).
|
||||||
|
- module_utils/k8s/service - hide fields first before creating diffs (https://github.com/ansible-collections/kubernetes.core/pull/915).
|
||||||
|
|
||||||
|
v5.4.0
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
This release updates the ``helm_registry_auth`` module to match the behavior of ``helm >= 3.18.0`` which reports a successful logout regardless of the current state (i.e., no idempotency).
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- Module ``helm_registry_auth`` does not support idempotency with ``helm >= 3.18.0`` (https://github.com/ansible-collections/kubernetes.core/pull/946)
|
||||||
|
|
||||||
v5.3.0
|
v5.3.0
|
||||||
======
|
======
|
||||||
|
|
||||||
Release Summary
|
Release Summary
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
This release includes minor changes, bug fixes and also bumps ansible-lint version to ``25.1.2``.
|
This release includes minor changes, bug fixes and also bumps ``ansible-lint`` version to ``25.1.2``.
|
||||||
|
|
||||||
Minor Changes
|
Minor Changes
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
- Bump version of ansible-lint to 25.1.2 (https://github.com/ansible-collections/kubernetes.core/pull/919).
|
- Bump version of ``ansible-lint`` to 25.1.2 (https://github.com/ansible-collections/kubernetes.core/pull/919).
|
||||||
- action/k8s_info - update templating mechanism with changes from ``ansible-core 2.19`` (https://github.com/ansible-collections/kubernetes.core/pull/888).
|
- action/k8s_info - update templating mechanism with changes from ``ansible-core 2.19`` (https://github.com/ansible-collections/kubernetes.core/pull/888).
|
||||||
- helm - add reset_then_reuse_values support to helm module (https://github.com/ansible-collections/kubernetes.core/issues/803).
|
- helm - add ``reset_then_reuse_values`` support to helm module (https://github.com/ansible-collections/kubernetes.core/issues/803).
|
||||||
- helm - add support for ``insecure_skip_tls_verify`` option to helm and helm_repository(https://github.com/ansible-collections/kubernetes.core/issues/694).
|
- helm - add support for ``insecure_skip_tls_verify`` option to helm and helm_repository(https://github.com/ansible-collections/kubernetes.core/issues/694).
|
||||||
|
|
||||||
Bugfixes
|
Bugfixes
|
||||||
--------
|
--------
|
||||||
|
|
||||||
- module_utils/k8s/service - fix issue when trying to delete resource using `delete_options` and `check_mode=true` (https://github.com/ansible-collections/kubernetes.core/issues/892).
|
- module_utils/k8s/service - fix issue when trying to delete resource using ``delete_options`` and ``check_mode=true`` (https://github.com/ansible-collections/kubernetes.core/issues/892).
|
||||||
|
|
||||||
v5.2.0
|
v5.2.0
|
||||||
======
|
======
|
||||||
@@ -84,7 +131,7 @@ This release came with new module ``helm_registry_auth``, improvements to the er
|
|||||||
Minor Changes
|
Minor Changes
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
- Bump version of ansible-lint to minimum 24.7.0 (https://github.com/ansible-collections/kubernetes.core/pull/765).
|
- Bump version of ``ansible-lint`` to minimum 24.7.0 (https://github.com/ansible-collections/kubernetes.core/pull/765).
|
||||||
- Parameter insecure_registry added to helm_template as equivalent of insecure-skip-tls-verify (https://github.com/ansible-collections/kubernetes.core/pull/805).
|
- Parameter insecure_registry added to helm_template as equivalent of insecure-skip-tls-verify (https://github.com/ansible-collections/kubernetes.core/pull/805).
|
||||||
- k8s_drain - Improve error message for pod disruption budget when draining a node (https://github.com/ansible-collections/kubernetes.core/issues/797).
|
- k8s_drain - Improve error message for pod disruption budget when draining a node (https://github.com/ansible-collections/kubernetes.core/issues/797).
|
||||||
|
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -1,5 +1,5 @@
|
|||||||
# Also needs to be updated in galaxy.yml
|
# Also needs to be updated in galaxy.yml
|
||||||
VERSION = 6.1.0
|
VERSION = 6.2.0
|
||||||
|
|
||||||
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]))'`
|
||||||
|
|||||||
@@ -99,7 +99,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: 6.1.0
|
version: 6.2.0
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installing the Kubernetes Python Library
|
### Installing the Kubernetes Python Library
|
||||||
|
|||||||
@@ -977,7 +977,7 @@ releases:
|
|||||||
- kustomize - kustomize plugin fails with deprecation warnings (https://github.com/ansible-collections/kubernetes.core/issues/639).
|
- kustomize - kustomize plugin fails with deprecation warnings (https://github.com/ansible-collections/kubernetes.core/issues/639).
|
||||||
- waiter - Fix waiting for daemonset when desired number of pods is 0. (https://github.com/ansible-collections/kubernetes.core/pull/756).
|
- waiter - Fix waiting for daemonset when desired number of pods is 0. (https://github.com/ansible-collections/kubernetes.core/pull/756).
|
||||||
minor_changes:
|
minor_changes:
|
||||||
- Bump version of ansible-lint to minimum 24.7.0 (https://github.com/ansible-collections/kubernetes.core/pull/765).
|
- Bump version of ``ansible-lint`` to minimum 24.7.0 (https://github.com/ansible-collections/kubernetes.core/pull/765).
|
||||||
- Parameter insecure_registry added to helm_template as equivalent of insecure-skip-tls-verify
|
- Parameter insecure_registry added to helm_template as equivalent of insecure-skip-tls-verify
|
||||||
(https://github.com/ansible-collections/kubernetes.core/pull/805).
|
(https://github.com/ansible-collections/kubernetes.core/pull/805).
|
||||||
- k8s_drain - Improve error message for pod disruption budget when draining
|
- k8s_drain - Improve error message for pod disruption budget when draining
|
||||||
@@ -1044,6 +1044,33 @@ releases:
|
|||||||
- 898-k8s-dont-delete-in-check-mode.yaml
|
- 898-k8s-dont-delete-in-check-mode.yaml
|
||||||
- 919-update-ansible-lint-version.yaml
|
- 919-update-ansible-lint-version.yaml
|
||||||
release_date: '2025-05-16'
|
release_date: '2025-05-16'
|
||||||
|
5.4.0:
|
||||||
|
changes:
|
||||||
|
minor_changes:
|
||||||
|
- Module ``helm_registry_auth`` does not support idempotency with ``helm >= 3.18.0``
|
||||||
|
(https://github.com/ansible-collections/kubernetes.core/pull/946).
|
||||||
|
release_summary: This release updates the ``helm_registry_auth`` module to match the behavior of ``helm >= 3.18.0`` which reports a successful logout regardless of the current state (i.e., no idempotency).
|
||||||
|
fragments:
|
||||||
|
- 20250411-kubeconfig-no_log-revert.yaml
|
||||||
|
- 20250503-fix-unit-tests.yml
|
||||||
|
- 20250605-fix-helm_registry_auth-integration_test.yaml
|
||||||
|
- 5.4.0.yml
|
||||||
|
release_date: '2025-08-12'
|
||||||
|
5.4.1:
|
||||||
|
changes:
|
||||||
|
bugfixes:
|
||||||
|
- Remove ``ansible.module_utils.six`` imports to avoid warnings (https://github.com/ansible-collections/kubernetes.core/pull/998).
|
||||||
|
- Update the `k8s_cp` module to also work for init containers (https://github.com/ansible-collections/kubernetes.core/pull/971).
|
||||||
|
- module_utils/k8s/service - hide fields first before creating diffs (https://github.com/ansible-collections/kubernetes.core/pull/915).
|
||||||
|
release_summary: This release includes bugfixes for k8s service field handling,
|
||||||
|
k8s_cp init containers support, and removes deprecated ansible.module_utils.six
|
||||||
|
imports.
|
||||||
|
fragments:
|
||||||
|
- 20250428-k8s-service-hide-fields-first.yaml
|
||||||
|
- 20250731-fix-k8s_cp-initcontainers.yaml
|
||||||
|
- 20250922-remove-ansible-six-imports.yaml
|
||||||
|
- 5.4.1.yml
|
||||||
|
release_date: '2025-10-07'
|
||||||
6.0.0:
|
6.0.0:
|
||||||
changes:
|
changes:
|
||||||
breaking_changes:
|
breaking_changes:
|
||||||
@@ -1067,10 +1094,10 @@ releases:
|
|||||||
(https://github.com/ansible-collections/kubernetes.core/pull/934).
|
(https://github.com/ansible-collections/kubernetes.core/pull/934).
|
||||||
- helm_template - Parameter plain_http added for working with insecure OCI registries
|
- helm_template - Parameter plain_http added for working with insecure OCI registries
|
||||||
(https://github.com/ansible-collections/kubernetes.core/pull/934).
|
(https://github.com/ansible-collections/kubernetes.core/pull/934).
|
||||||
release_summary: "This release includes a fix for kubeconfig output, added ``plain_http``
|
release_summary: "This release adds ``plain_http`` and ``take_ownership`` parameters
|
||||||
and ``take_ownership`` parameters for helm modules, support for ``hidden_fields``
|
for helm modules, support for ``hidden_fields`` in ``k8s_json_patch``, documented
|
||||||
in ``k8s_json_patch``, documented lack of idempotency support in ``helm_registry_auth``
|
lack of idempotency support in ``helm_registry_auth`` with ``helm \u2265 3.18.0``,
|
||||||
with ``helm \u2265 3.18.0``, and improved ``k8s_rollback`` test coverage."
|
and improved ``k8s_rollback`` test coverage."
|
||||||
fragments:
|
fragments:
|
||||||
- 20250411-kubeconfig-no_log-revert.yaml
|
- 20250411-kubeconfig-no_log-revert.yaml
|
||||||
- 20250428-k8s-service-hide-fields-first.yaml
|
- 20250428-k8s-service-hide-fields-first.yaml
|
||||||
@@ -1081,3 +1108,22 @@ releases:
|
|||||||
- 20250911-add-support-helm-take-ownership.yaml
|
- 20250911-add-support-helm-take-ownership.yaml
|
||||||
- release_summary.yml
|
- release_summary.yml
|
||||||
release_date: '2025-08-12'
|
release_date: '2025-08-12'
|
||||||
|
6.2.0:
|
||||||
|
changes:
|
||||||
|
bugfixes:
|
||||||
|
- Remove ``ansible.module_utils.six`` imports to avoid warnings (https://github.com/ansible-collections/kubernetes.core/pull/998).
|
||||||
|
- Update the `k8s_cp` module to also work for init containers (https://github.com/ansible-collections/kubernetes.core/pull/971).
|
||||||
|
minor_changes:
|
||||||
|
- Add support of skip-schema-validation in ``helm`` module (https://github.com/ansible-collections/kubernetes.core/pull/995)
|
||||||
|
- kustomize - Add support of local environ (https://github.com/ansible-collections/kubernetes.core/pull/786).
|
||||||
|
release_summary: This release adds minor changes and bugfixes, including support
|
||||||
|
of skip-schema-validation in ``helm`` module and removing deprecated
|
||||||
|
``ansible.module_utils.six`` imports.
|
||||||
|
|
||||||
|
fragments:
|
||||||
|
- 20241030-support-of-evrion-for-kustomize-lookup-plugin.yaml
|
||||||
|
- 20250731-fix-k8s_cp-initcontainers.yaml
|
||||||
|
- 20250916-skip-schema-validation.yaml
|
||||||
|
- 20250922-remove-ansible-six-imports.yaml
|
||||||
|
- 6_2_0.yml
|
||||||
|
release_date: '2025-10-07'
|
||||||
|
|||||||
@@ -622,6 +622,27 @@ 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="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>skip_schema_validation</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 6.2.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
||||||
|
<li><div style="color: blue"><b>no</b> ←</div></li>
|
||||||
|
<li>yes</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Disables JSON schema validation for Chart and values.</div>
|
||||||
|
<div>This feature requires helm >= 3.16.0</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
|||||||
@@ -512,6 +512,7 @@ Notes
|
|||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
- the tar binary is required on the container when copying from local filesystem to pod.
|
- the tar binary is required on the container when copying from local filesystem to pod.
|
||||||
|
- the (init) container has to be started before you copy files or directories to it.
|
||||||
- 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.
|
- 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.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -95,6 +95,26 @@ Parameters
|
|||||||
<div>Enable the helm chart inflation generator</div>
|
<div>Enable the helm chart inflation generator</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>environment</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">raw</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 6.2.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<b>Default:</b><br/><div style="color: blue">{}</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>The environment variables to pass to the kustomize or kubectl command.</div>
|
||||||
|
<div>This can be a dictionary or a string in the format key=value, multiple pairs separated by space.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="1">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -145,6 +165,14 @@ Examples
|
|||||||
kubernetes.core.k8s:
|
kubernetes.core.k8s:
|
||||||
definition: "{{ lookup('kubernetes.core.kustomize', dir='/path/to/kustomization', enable_helm=True) }}"
|
definition: "{{ lookup('kubernetes.core.kustomize', dir='/path/to/kustomization', enable_helm=True) }}"
|
||||||
|
|
||||||
|
- name: Create kubernetes resources for lookup output with environment variables in string format
|
||||||
|
kubernetes.core.k8s:
|
||||||
|
definition: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kubectl', environment='HTTP_PROXY=http://proxy.example.com:3128') }}"
|
||||||
|
|
||||||
|
- name: Create kubernetes resources for lookup output with environment variables in dict format
|
||||||
|
kubernetes.core.k8s:
|
||||||
|
definition: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kubectl', environment={'HTTP_PROXY': 'http://proxy.example.com:3128'}) }}"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Return Values
|
Return Values
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ tags:
|
|||||||
- openshift
|
- openshift
|
||||||
- okd
|
- okd
|
||||||
- cluster
|
- cluster
|
||||||
version: 6.1.0
|
version: 6.2.0
|
||||||
build_ignore:
|
build_ignore:
|
||||||
- .DS_Store
|
- .DS_Store
|
||||||
- "*.tar.gz"
|
- "*.tar.gz"
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ from ansible.errors import (
|
|||||||
)
|
)
|
||||||
from ansible.module_utils._text import to_bytes, to_native, to_text
|
from ansible.module_utils._text import to_bytes, to_native, to_text
|
||||||
from ansible.module_utils.parsing.convert_bool import boolean
|
from ansible.module_utils.parsing.convert_bool import boolean
|
||||||
from ansible.module_utils.six import iteritems, string_types
|
|
||||||
from ansible.plugins.action import ActionBase
|
from ansible.plugins.action import ActionBase
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -100,7 +99,7 @@ class ActionModule(ActionBase):
|
|||||||
"trim_blocks": True,
|
"trim_blocks": True,
|
||||||
"lstrip_blocks": False,
|
"lstrip_blocks": False,
|
||||||
}
|
}
|
||||||
if isinstance(template, string_types):
|
if isinstance(template, str):
|
||||||
# treat this as raw_params
|
# treat this as raw_params
|
||||||
template_param["path"] = template
|
template_param["path"] = template
|
||||||
elif isinstance(template, dict):
|
elif isinstance(template, dict):
|
||||||
@@ -120,7 +119,7 @@ class ActionModule(ActionBase):
|
|||||||
):
|
):
|
||||||
if s_type in template_args:
|
if s_type in template_args:
|
||||||
value = ensure_type(template_args[s_type], "string")
|
value = ensure_type(template_args[s_type], "string")
|
||||||
if value is not None and not isinstance(value, string_types):
|
if value is not None and not isinstance(value, str):
|
||||||
raise AnsibleActionFail(
|
raise AnsibleActionFail(
|
||||||
"%s is expected to be a string, but got %s instead"
|
"%s is expected to be a string, but got %s instead"
|
||||||
% (s_type, type(value))
|
% (s_type, type(value))
|
||||||
@@ -196,7 +195,7 @@ class ActionModule(ActionBase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
template_params = []
|
template_params = []
|
||||||
if isinstance(template, string_types) or isinstance(template, dict):
|
if isinstance(template, str) or isinstance(template, dict):
|
||||||
template_params.append(self.get_template_args(template))
|
template_params.append(self.get_template_args(template))
|
||||||
elif isinstance(template, list):
|
elif isinstance(template, list):
|
||||||
for element in template:
|
for element in template:
|
||||||
@@ -246,7 +245,7 @@ class ActionModule(ActionBase):
|
|||||||
# add ansible 'template' vars
|
# add ansible 'template' vars
|
||||||
temp_vars = copy.deepcopy(task_vars)
|
temp_vars = copy.deepcopy(task_vars)
|
||||||
overrides = {}
|
overrides = {}
|
||||||
for key, value in iteritems(template_item):
|
for key, value in template_item.items():
|
||||||
if hasattr(self._templar.environment, key):
|
if hasattr(self._templar.environment, key):
|
||||||
if value is not None:
|
if value is not None:
|
||||||
overrides[key] = value
|
overrides[key] = value
|
||||||
@@ -303,7 +302,7 @@ class ActionModule(ActionBase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def get_kubeconfig(self, kubeconfig, remote_transport, new_module_args):
|
def get_kubeconfig(self, kubeconfig, remote_transport, new_module_args):
|
||||||
if isinstance(kubeconfig, string_types):
|
if isinstance(kubeconfig, str):
|
||||||
# find the kubeconfig in the expected search path
|
# find the kubeconfig in the expected search path
|
||||||
if not remote_transport:
|
if not remote_transport:
|
||||||
# kubeconfig is local
|
# kubeconfig is local
|
||||||
|
|||||||
@@ -34,6 +34,13 @@ DOCUMENTATION = """
|
|||||||
description:
|
description:
|
||||||
- Enable the helm chart inflation generator
|
- Enable the helm chart inflation generator
|
||||||
default: "False"
|
default: "False"
|
||||||
|
environment:
|
||||||
|
description:
|
||||||
|
- The environment variables to pass to the kustomize or kubectl command.
|
||||||
|
- This can be a dictionary or a string in the format key=value, multiple pairs separated by space.
|
||||||
|
type: raw
|
||||||
|
default: {}
|
||||||
|
version_added: 6.2.0
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "python >= 3.6"
|
- "python >= 3.6"
|
||||||
@@ -55,6 +62,14 @@ EXAMPLES = """
|
|||||||
- name: Create kubernetes resources for lookup output with `--enable-helm` set
|
- name: Create kubernetes resources for lookup output with `--enable-helm` set
|
||||||
kubernetes.core.k8s:
|
kubernetes.core.k8s:
|
||||||
definition: "{{ lookup('kubernetes.core.kustomize', dir='/path/to/kustomization', enable_helm=True) }}"
|
definition: "{{ lookup('kubernetes.core.kustomize', dir='/path/to/kustomization', enable_helm=True) }}"
|
||||||
|
|
||||||
|
- name: Create kubernetes resources for lookup output with environment variables in string format
|
||||||
|
kubernetes.core.k8s:
|
||||||
|
definition: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kubectl', environment='HTTP_PROXY=http://proxy.example.com:3128') }}"
|
||||||
|
|
||||||
|
- name: Create kubernetes resources for lookup output with environment variables in dict format
|
||||||
|
kubernetes.core.k8s:
|
||||||
|
definition: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kubectl', environment={'HTTP_PROXY': 'http://proxy.example.com:3128'}) }}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
@@ -72,6 +87,7 @@ RETURN = """
|
|||||||
key1: val1
|
key1: val1
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from ansible.errors import AnsibleLookupError
|
from ansible.errors import AnsibleLookupError
|
||||||
@@ -92,8 +108,10 @@ def get_binary_from_path(name, opt_dirs=None):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def run_command(command):
|
def run_command(command, environ=None):
|
||||||
cmd = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
cmd = subprocess.Popen(
|
||||||
|
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=environ
|
||||||
|
)
|
||||||
stdout, stderr = cmd.communicate()
|
stdout, stderr = cmd.communicate()
|
||||||
return cmd.returncode, stdout, stderr
|
return cmd.returncode, stdout, stderr
|
||||||
|
|
||||||
@@ -107,6 +125,7 @@ class LookupModule(LookupBase):
|
|||||||
binary_path=None,
|
binary_path=None,
|
||||||
opt_dirs=None,
|
opt_dirs=None,
|
||||||
enable_helm=False,
|
enable_helm=False,
|
||||||
|
environment=None,
|
||||||
**kwargs
|
**kwargs
|
||||||
):
|
):
|
||||||
executable_path = binary_path
|
executable_path = binary_path
|
||||||
@@ -141,7 +160,21 @@ class LookupModule(LookupBase):
|
|||||||
if enable_helm:
|
if enable_helm:
|
||||||
command += ["--enable-helm"]
|
command += ["--enable-helm"]
|
||||||
|
|
||||||
(ret, out, err) = run_command(command)
|
environ = None
|
||||||
|
if environment:
|
||||||
|
environ = os.environ.copy()
|
||||||
|
if isinstance(environment, str):
|
||||||
|
if not all(env.count("=") == 1 for env in environment.split(" ")):
|
||||||
|
raise AnsibleLookupError(
|
||||||
|
"environment should be dict or string in the format key=value, multiple pairs separated by space"
|
||||||
|
)
|
||||||
|
for env in environment.split(" "):
|
||||||
|
key, value = env.split("=")
|
||||||
|
environ[key] = value
|
||||||
|
if isinstance(environment, dict):
|
||||||
|
environ.update(environment)
|
||||||
|
|
||||||
|
(ret, out, err) = run_command(command, environ=environ)
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
if err:
|
if err:
|
||||||
raise AnsibleLookupError(
|
raise AnsibleLookupError(
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
from ansible.module_utils.six import string_types
|
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
def list_dict_str(value):
|
def list_dict_str(value):
|
||||||
if isinstance(value, (list, dict, string_types)):
|
if isinstance(value, (list, dict, str)):
|
||||||
return value
|
return value
|
||||||
raise TypeError
|
raise TypeError
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ class K8SCopy(metaclass=ABCMeta):
|
|||||||
return error, stdout, stderr
|
return error, stdout, stderr
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.module.fail_json(
|
self.module.fail_json(
|
||||||
msg="Error while running/parsing from pod {1}/{2} command='{0}' : {3}".format(
|
msg="Error while running/parsing from pod {0}/{1} command='{2}' : {3}".format(
|
||||||
self.namespace, self.name, cmd, to_native(e)
|
self.namespace, self.name, cmd, to_native(e)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -435,11 +435,21 @@ def check_pod(svc):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
result = svc.client.get(resource, name=name, namespace=namespace)
|
result = svc.client.get(resource, name=name, namespace=namespace)
|
||||||
containers = [
|
containers = dict(
|
||||||
c["name"] for c in result.to_dict()["status"]["containerStatuses"]
|
{
|
||||||
]
|
c["name"]: c
|
||||||
if container and container not in containers:
|
for cl in ["initContainerStatuses", "containerStatuses"]
|
||||||
|
for c in result.to_dict()["status"].get(cl, [])
|
||||||
|
}
|
||||||
|
)
|
||||||
|
if container and container not in containers.keys():
|
||||||
module.fail_json(msg="Pod has no container {0}".format(container))
|
module.fail_json(msg="Pod has no container {0}".format(container))
|
||||||
return containers
|
if (
|
||||||
|
container
|
||||||
|
and container in containers
|
||||||
|
and not bool(containers[container].get("started", False))
|
||||||
|
):
|
||||||
|
module.fail_json(msg="Pod container {0} is not started".format(container))
|
||||||
|
return containers.keys()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
_fail(exc)
|
_fail(exc)
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import tempfile
|
|||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||||
from ansible.module_utils.six import string_types
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.version import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.version import (
|
||||||
LooseVersion,
|
LooseVersion,
|
||||||
)
|
)
|
||||||
@@ -113,7 +112,7 @@ class AnsibleHelmModule(object):
|
|||||||
kubeconfig_content = None
|
kubeconfig_content = None
|
||||||
kubeconfig = self.params.get("kubeconfig")
|
kubeconfig = self.params.get("kubeconfig")
|
||||||
if kubeconfig:
|
if kubeconfig:
|
||||||
if isinstance(kubeconfig, string_types):
|
if isinstance(kubeconfig, str):
|
||||||
with open(os.path.expanduser(kubeconfig)) as fd:
|
with open(os.path.expanduser(kubeconfig)) as fd:
|
||||||
kubeconfig_content = yaml.safe_load(fd)
|
kubeconfig_content = yaml.safe_load(fd)
|
||||||
elif isinstance(kubeconfig, dict):
|
elif isinstance(kubeconfig, dict):
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import hashlib
|
|||||||
import os
|
import os
|
||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
from ansible.module_utils.six import iteritems, string_types
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
|
||||||
AUTH_ARG_MAP,
|
AUTH_ARG_MAP,
|
||||||
AUTH_ARG_SPEC,
|
AUTH_ARG_SPEC,
|
||||||
@@ -115,7 +114,7 @@ def _load_config(auth: Dict) -> None:
|
|||||||
"persist_config": auth.get("persist_config"),
|
"persist_config": auth.get("persist_config"),
|
||||||
}
|
}
|
||||||
if kubeconfig:
|
if kubeconfig:
|
||||||
if isinstance(kubeconfig, string_types):
|
if isinstance(kubeconfig, str):
|
||||||
kubernetes.config.load_kube_config(config_file=kubeconfig, **optional_arg)
|
kubernetes.config.load_kube_config(config_file=kubeconfig, **optional_arg)
|
||||||
elif isinstance(kubeconfig, dict):
|
elif isinstance(kubeconfig, dict):
|
||||||
kubernetes.config.load_kube_config_from_dict(
|
kubernetes.config.load_kube_config_from_dict(
|
||||||
@@ -163,7 +162,7 @@ def _create_configuration(auth: Dict):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
configuration = kubernetes.client.Configuration()
|
configuration = kubernetes.client.Configuration()
|
||||||
|
|
||||||
for key, value in iteritems(auth):
|
for key, value in auth.items():
|
||||||
if key in AUTH_ARG_MAP.keys() and value is not None:
|
if key in AUTH_ARG_MAP.keys() and value is not None:
|
||||||
if key == "api_key":
|
if key == "api_key":
|
||||||
setattr(
|
setattr(
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
import os
|
import os
|
||||||
from typing import Dict, Iterable, List, Optional, Union, cast
|
from typing import Dict, Iterable, List, Optional, Union, cast
|
||||||
|
|
||||||
from ansible.module_utils.six import string_types
|
|
||||||
from ansible.module_utils.urls import Request
|
from ansible.module_utils.urls import Request
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -78,11 +77,11 @@ def create_definitions(params: Dict) -> List[ResourceDefinition]:
|
|||||||
def from_yaml(definition: Union[str, List, Dict]) -> Iterable[Dict]:
|
def from_yaml(definition: Union[str, List, Dict]) -> Iterable[Dict]:
|
||||||
"""Load resource definitions from a yaml definition."""
|
"""Load resource definitions from a yaml definition."""
|
||||||
definitions: List[Dict] = []
|
definitions: List[Dict] = []
|
||||||
if isinstance(definition, string_types):
|
if isinstance(definition, str):
|
||||||
definitions += yaml.safe_load_all(definition)
|
definitions += yaml.safe_load_all(definition)
|
||||||
elif isinstance(definition, list):
|
elif isinstance(definition, list):
|
||||||
for item in definition:
|
for item in definition:
|
||||||
if isinstance(item, string_types):
|
if isinstance(item, str):
|
||||||
definitions += yaml.safe_load_all(item)
|
definitions += yaml.safe_load_all(item)
|
||||||
else:
|
else:
|
||||||
definitions.append(item)
|
definitions.append(item)
|
||||||
|
|||||||
@@ -251,6 +251,13 @@ options:
|
|||||||
type: bool
|
type: bool
|
||||||
default: False
|
default: False
|
||||||
version_added: 6.1.0
|
version_added: 6.1.0
|
||||||
|
skip_schema_validation:
|
||||||
|
description:
|
||||||
|
- Disables JSON schema validation for Chart and values.
|
||||||
|
- This feature requires helm >= 3.16.0
|
||||||
|
type: bool
|
||||||
|
default: False
|
||||||
|
version_added: 6.2.0
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- kubernetes.core.helm_common_options
|
- kubernetes.core.helm_common_options
|
||||||
"""
|
"""
|
||||||
@@ -568,6 +575,7 @@ def deploy(
|
|||||||
insecure_skip_tls_verify=False,
|
insecure_skip_tls_verify=False,
|
||||||
plain_http=False,
|
plain_http=False,
|
||||||
take_ownership=False,
|
take_ownership=False,
|
||||||
|
skip_schema_validation=False,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Install/upgrade/rollback release chart
|
Install/upgrade/rollback release chart
|
||||||
@@ -658,6 +666,17 @@ def deploy(
|
|||||||
if set_value_args:
|
if set_value_args:
|
||||||
deploy_command += " " + set_value_args
|
deploy_command += " " + set_value_args
|
||||||
|
|
||||||
|
if skip_schema_validation:
|
||||||
|
helm_version = module.get_helm_version()
|
||||||
|
if LooseVersion(helm_version) < LooseVersion("3.16.0"):
|
||||||
|
module.fail_json(
|
||||||
|
msg="skip_schema_validation requires helm >= 3.16.0, current version is {0}".format(
|
||||||
|
helm_version
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
deploy_command += " --skip-schema-validation"
|
||||||
|
|
||||||
deploy_command += " " + release_name + f" '{chart_name}'"
|
deploy_command += " " + release_name + f" '{chart_name}'"
|
||||||
return deploy_command
|
return deploy_command
|
||||||
|
|
||||||
@@ -731,6 +750,7 @@ def helmdiff_check(
|
|||||||
reset_then_reuse_values=False,
|
reset_then_reuse_values=False,
|
||||||
insecure_skip_tls_verify=False,
|
insecure_skip_tls_verify=False,
|
||||||
plain_http=False,
|
plain_http=False,
|
||||||
|
skip_schema_validation=False,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Use helm diff to determine if a release would change by upgrading a chart.
|
Use helm diff to determine if a release would change by upgrading a chart.
|
||||||
@@ -786,6 +806,17 @@ def helmdiff_check(
|
|||||||
if insecure_skip_tls_verify:
|
if insecure_skip_tls_verify:
|
||||||
cmd += " --insecure-skip-tls-verify"
|
cmd += " --insecure-skip-tls-verify"
|
||||||
|
|
||||||
|
if skip_schema_validation:
|
||||||
|
helm_version = module.get_helm_version()
|
||||||
|
if LooseVersion(helm_version) < LooseVersion("3.16.0"):
|
||||||
|
module.fail_json(
|
||||||
|
msg="skip_schema_validation requires helm >= 3.16.0, current version is {0}".format(
|
||||||
|
helm_version
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
cmd += " --skip-schema-validation"
|
||||||
|
|
||||||
if plain_http:
|
if plain_http:
|
||||||
helm_version = module.get_helm_version()
|
helm_version = module.get_helm_version()
|
||||||
if LooseVersion(helm_version) < LooseVersion("3.13.0"):
|
if LooseVersion(helm_version) < LooseVersion("3.13.0"):
|
||||||
@@ -862,6 +893,7 @@ def argument_spec():
|
|||||||
),
|
),
|
||||||
plain_http=dict(type="bool", default=False),
|
plain_http=dict(type="bool", default=False),
|
||||||
take_ownership=dict(type="bool", default=False),
|
take_ownership=dict(type="bool", default=False),
|
||||||
|
skip_schema_validation=dict(type="bool", default=False),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return arg_spec
|
return arg_spec
|
||||||
@@ -918,6 +950,7 @@ def main():
|
|||||||
insecure_skip_tls_verify = module.params.get("insecure_skip_tls_verify")
|
insecure_skip_tls_verify = module.params.get("insecure_skip_tls_verify")
|
||||||
plain_http = module.params.get("plain_http")
|
plain_http = module.params.get("plain_http")
|
||||||
take_ownership = module.params.get("take_ownership")
|
take_ownership = module.params.get("take_ownership")
|
||||||
|
skip_schema_validation = module.params.get("skip_schema_validation")
|
||||||
|
|
||||||
if update_repo_cache:
|
if update_repo_cache:
|
||||||
run_repo_update(module)
|
run_repo_update(module)
|
||||||
@@ -945,6 +978,15 @@ def main():
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if skip_schema_validation:
|
||||||
|
helm_version = module.get_helm_version()
|
||||||
|
if LooseVersion(helm_version) < LooseVersion("3.16.0"):
|
||||||
|
module.fail_json(
|
||||||
|
msg="skip_schema_validation requires helm >= 3.16.0, current version is {0}".format(
|
||||||
|
helm_version
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
opt_result = {}
|
opt_result = {}
|
||||||
if release_state == "absent" and release_status is not None:
|
if release_state == "absent" and release_status is not None:
|
||||||
# skip release statuses 'uninstalled' and 'uninstalling'
|
# skip release statuses 'uninstalled' and 'uninstalling'
|
||||||
@@ -1037,6 +1079,7 @@ def main():
|
|||||||
reset_then_reuse_values=reset_then_reuse_values,
|
reset_then_reuse_values=reset_then_reuse_values,
|
||||||
insecure_skip_tls_verify=insecure_skip_tls_verify,
|
insecure_skip_tls_verify=insecure_skip_tls_verify,
|
||||||
plain_http=plain_http,
|
plain_http=plain_http,
|
||||||
|
skip_schema_validation=skip_schema_validation,
|
||||||
)
|
)
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
@@ -1065,6 +1108,7 @@ def main():
|
|||||||
reset_then_reuse_values=reset_then_reuse_values,
|
reset_then_reuse_values=reset_then_reuse_values,
|
||||||
insecure_skip_tls_verify=insecure_skip_tls_verify,
|
insecure_skip_tls_verify=insecure_skip_tls_verify,
|
||||||
plain_http=plain_http,
|
plain_http=plain_http,
|
||||||
|
skip_schema_validation=skip_schema_validation,
|
||||||
)
|
)
|
||||||
if would_change and module._diff:
|
if would_change and module._diff:
|
||||||
opt_result["diff"] = {"prepared": prepared}
|
opt_result["diff"] = {"prepared": prepared}
|
||||||
@@ -1104,6 +1148,7 @@ def main():
|
|||||||
insecure_skip_tls_verify=insecure_skip_tls_verify,
|
insecure_skip_tls_verify=insecure_skip_tls_verify,
|
||||||
plain_http=plain_http,
|
plain_http=plain_http,
|
||||||
take_ownership=take_ownership,
|
take_ownership=take_ownership,
|
||||||
|
skip_schema_validation=skip_schema_validation,
|
||||||
)
|
)
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ options:
|
|||||||
|
|
||||||
notes:
|
notes:
|
||||||
- the tar binary is required on the container when copying from local filesystem to pod.
|
- the tar binary is required on the container when copying from local filesystem to pod.
|
||||||
|
- the (init) container has to be started before you copy files or directories to it.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = r"""
|
EXAMPLES = r"""
|
||||||
|
|||||||
@@ -30,3 +30,4 @@ test_namespace:
|
|||||||
- "helm-reset-then-reuse-values"
|
- "helm-reset-then-reuse-values"
|
||||||
- "helm-insecure"
|
- "helm-insecure"
|
||||||
- "helm-test-take-ownership"
|
- "helm-test-take-ownership"
|
||||||
|
- "helm-skip-schema-validation"
|
||||||
|
|||||||
@@ -50,6 +50,9 @@
|
|||||||
- name: Test take ownership flag feature
|
- name: Test take ownership flag feature
|
||||||
include_tasks: test_helm_take_ownership.yml
|
include_tasks: test_helm_take_ownership.yml
|
||||||
|
|
||||||
|
- name: Test helm skip_schema_validation
|
||||||
|
include_tasks: test_skip_schema_validation.yml
|
||||||
|
|
||||||
- name: Clean helm install
|
- name: Clean helm install
|
||||||
file:
|
file:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
---
|
||||||
|
- name: Test helm skip_schema_validation
|
||||||
|
vars:
|
||||||
|
helm_namespace: "{{ test_namespace[14] }}"
|
||||||
|
chart_release_values:
|
||||||
|
replica:
|
||||||
|
replicaCount: 3
|
||||||
|
master:
|
||||||
|
count: 1
|
||||||
|
kind: Deployment
|
||||||
|
block:
|
||||||
|
- name: Chart installation
|
||||||
|
helm:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
|
chart_ref: oci://registry-1.docker.io/bitnamicharts/redis
|
||||||
|
release_name: test-redis
|
||||||
|
release_namespace: "{{ helm_namespace }}"
|
||||||
|
create_namespace: true
|
||||||
|
release_values: "{{ chart_release_values }}"
|
||||||
|
skip_schema_validation: true
|
||||||
|
register: install
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Debug install result
|
||||||
|
debug:
|
||||||
|
var: install
|
||||||
|
|
||||||
|
- name: Validate skip_schema_validation with helm >= 3.16.0 works
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- install is changed
|
||||||
|
- "'--skip-schema-validation' in install.command"
|
||||||
|
when: "helm_version is ansible.builtin.version('v3.16.0', '>=')"
|
||||||
|
|
||||||
|
- name: Validate skip_schema_validation with helm < 3.16.0 fails
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- install is failed
|
||||||
|
- "'skip_schema_validation requires helm >= 3.16.0' in install.msg"
|
||||||
|
when: "helm_version is ansible.builtin.version('v3.16.0', '<')"
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: Remove helm namespace
|
||||||
|
k8s:
|
||||||
|
api_version: v1
|
||||||
|
kind: Namespace
|
||||||
|
name: "{{ helm_namespace }}"
|
||||||
|
state: absent
|
||||||
@@ -14,3 +14,9 @@ pod_with_two_container:
|
|||||||
|
|
||||||
pod_without_executable_find:
|
pod_without_executable_find:
|
||||||
name: openjdk-pod
|
name: openjdk-pod
|
||||||
|
|
||||||
|
pod_with_initcontainer_and_container:
|
||||||
|
name: pod-copy-2
|
||||||
|
container:
|
||||||
|
- container-20
|
||||||
|
- container-21
|
||||||
|
|||||||
@@ -18,6 +18,23 @@
|
|||||||
wait: yes
|
wait: yes
|
||||||
template: pods_definition.j2
|
template: pods_definition.j2
|
||||||
|
|
||||||
|
- name: Create Init Pod
|
||||||
|
k8s:
|
||||||
|
namespace: '{{ copy_namespace }}'
|
||||||
|
template: pods_definition_init.j2
|
||||||
|
|
||||||
|
- kubernetes.core.k8s_info:
|
||||||
|
api_version: v1
|
||||||
|
kind: Pod
|
||||||
|
name: '{{ pod_with_initcontainer_and_container.name }}'
|
||||||
|
namespace: '{{ copy_namespace }}'
|
||||||
|
register: init_pod_status
|
||||||
|
until: >-
|
||||||
|
init_pod_status.resources|length > 0
|
||||||
|
and 'initContainerStatuses' in init_pod_status.resources.0.status
|
||||||
|
and init_pod_status.resources.0.status.initContainerStatuses|length > 0
|
||||||
|
and init_pod_status.resources.0.status.initContainerStatuses.0.started|bool
|
||||||
|
|
||||||
- include_tasks: test_copy_errors.yml
|
- include_tasks: test_copy_errors.yml
|
||||||
- include_tasks: test_check_mode.yml
|
- include_tasks: test_check_mode.yml
|
||||||
- include_tasks: test_copy_file.yml
|
- include_tasks: test_copy_file.yml
|
||||||
@@ -25,6 +42,7 @@
|
|||||||
- include_tasks: test_copy_directory.yml
|
- include_tasks: test_copy_directory.yml
|
||||||
- include_tasks: test_copy_large_file.yml
|
- include_tasks: test_copy_large_file.yml
|
||||||
- include_tasks: test_copy_item_with_space_in_its_name.yml
|
- include_tasks: test_copy_item_with_space_in_its_name.yml
|
||||||
|
- include_tasks: test_init_container_pod.yml
|
||||||
|
|
||||||
always:
|
always:
|
||||||
|
|
||||||
|
|||||||
@@ -67,3 +67,21 @@
|
|||||||
that:
|
that:
|
||||||
- copy_fake_container is failed
|
- copy_fake_container is failed
|
||||||
- copy_fake_container.msg == "Pod has no container this_is_a_fake_container"
|
- copy_fake_container.msg == "Pod has no container this_is_a_fake_container"
|
||||||
|
|
||||||
|
# copy file to not started container in pod should fail
|
||||||
|
- name: copy file to not started container in pod should fail
|
||||||
|
k8s_cp:
|
||||||
|
namespace: '{{ copy_namespace }}'
|
||||||
|
pod: '{{ pod_with_initcontainer_and_container.name }}'
|
||||||
|
remote_path: /tmp
|
||||||
|
local_path: files/simple_file.txt
|
||||||
|
state: to_pod
|
||||||
|
container: '{{ pod_with_initcontainer_and_container.container[1] }}'
|
||||||
|
ignore_errors: true
|
||||||
|
register: copy_not_started_container
|
||||||
|
|
||||||
|
- name: check that error message is as expected
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- copy_not_started_container is failed
|
||||||
|
- copy_not_started_container.msg == "Pod container {{ pod_with_initcontainer_and_container.container[1] }} is not started"
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
- set_fact:
|
||||||
|
random_content: "{{ lookup('password', '/dev/null chars=ascii_lowercase,digits,punctuation length=128') }}"
|
||||||
|
|
||||||
|
- name: Copy content into init container
|
||||||
|
k8s_cp:
|
||||||
|
namespace: '{{ copy_namespace }}'
|
||||||
|
pod: '{{ pod_with_initcontainer_and_container.name }}'
|
||||||
|
remote_path: /file_from_localhost.txt
|
||||||
|
content: '{{ random_content }}'
|
||||||
|
container: '{{ pod_with_initcontainer_and_container.container[0] }}'
|
||||||
|
state: to_pod
|
||||||
|
|
||||||
|
- name: Get the content from copied file
|
||||||
|
kubernetes.core.k8s_exec:
|
||||||
|
namespace: '{{ copy_namespace }}'
|
||||||
|
pod: '{{ pod_with_initcontainer_and_container.name }}'
|
||||||
|
container: '{{ pod_with_initcontainer_and_container.container[0] }}'
|
||||||
|
command: cat /file_from_localhost.txt
|
||||||
|
register: exec_out
|
||||||
|
|
||||||
|
- name: check that content is found and the same as generated earlier
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- exec_out.stdout == random_content
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
name: '{{ pod_with_initcontainer_and_container.name }}'
|
||||||
|
spec:
|
||||||
|
initContainers:
|
||||||
|
- name: '{{ pod_with_initcontainer_and_container.container[0] }}'
|
||||||
|
image: busybox
|
||||||
|
command:
|
||||||
|
- /bin/sh
|
||||||
|
- -c
|
||||||
|
- while true;do date;sleep 5; done
|
||||||
|
containers:
|
||||||
|
- name: '{{ pod_with_initcontainer_and_container.container[1] }}'
|
||||||
|
image: busybox
|
||||||
|
command:
|
||||||
|
- /bin/sh
|
||||||
|
- -c
|
||||||
|
- while true;do date;sleep 5; done
|
||||||
@@ -94,6 +94,52 @@
|
|||||||
namespace: "{{ kustomize_ns }}"
|
namespace: "{{ kustomize_ns }}"
|
||||||
definition: "{{ lookup('kubernetes.core.kustomize', dir=kustomize_dir, opt_dirs=tmp_dir_path) }}"
|
definition: "{{ lookup('kubernetes.core.kustomize', dir=kustomize_dir, opt_dirs=tmp_dir_path) }}"
|
||||||
|
|
||||||
|
- name: Create temporarly directory for test
|
||||||
|
ansible.builtin.tempfile:
|
||||||
|
state: directory
|
||||||
|
suffix: .testkustomize
|
||||||
|
register: _tmp_dir_kustomize
|
||||||
|
|
||||||
|
- name: Download helloWorld example
|
||||||
|
ansible.builtin.get_url:
|
||||||
|
url: "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/refs/heads/master/examples/loadHttp/kustomization.yaml"
|
||||||
|
dest: "{{ _tmp_dir_kustomize.path }}"
|
||||||
|
|
||||||
|
- name: Run tinyproxy in docker
|
||||||
|
# Replace the 'app: hello' with 'app: ${TEST_APP}'
|
||||||
|
ansible.builtin.command: "docker run --rm -d -p 8888:8888 --name=tinyproxy dannydirect/tinyproxy ANY"
|
||||||
|
|
||||||
|
- name: Ensure that tinyproxy is running
|
||||||
|
ansible.builtin.wait_for:
|
||||||
|
host: localhost
|
||||||
|
port: 8888
|
||||||
|
state: started
|
||||||
|
|
||||||
|
- name: Test kustomize lookup plugin with environment variables in the string format
|
||||||
|
set_fact:
|
||||||
|
resource_kustomize: "{{ lookup('kubernetes.core.kustomize', dir=_tmp_dir_kustomize.path, environment='HTTPS_PROXY=http://localhost:8888 VAR2=Flase') }}"
|
||||||
|
|
||||||
|
- name: Test kustomize lookup plugin with environment variables in the dict format
|
||||||
|
set_fact:
|
||||||
|
resource_kustomize: "{{ lookup('kubernetes.core.kustomize', dir=_tmp_dir_kustomize.path, environment={'HTTPS_PROXY': 'http://localhost:8888', 'VAR2': 'Flase'}) }}"
|
||||||
|
|
||||||
|
|
||||||
|
- name: Stop tinyproxy
|
||||||
|
ansible.builtin.command: "docker stop tinyproxy"
|
||||||
|
|
||||||
|
- name: Ensure kustomize lookup plugin fail with proxy down
|
||||||
|
set_fact:
|
||||||
|
resource_kustomize: "{{ lookup('kubernetes.core.kustomize', dir=_tmp_dir_kustomize.path, environment='HTTPS_PROXY=http://localhost:8888 VAR2=Flase') }}"
|
||||||
|
register: result
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Assert that kustomize lookup plugin failed
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- result.failed
|
||||||
|
- "'proxyconnect tcp: dial' in result.msg"
|
||||||
|
- "'connection refused' in result.msg"
|
||||||
|
|
||||||
always:
|
always:
|
||||||
- name: Delete namespace
|
- name: Delete namespace
|
||||||
k8s:
|
k8s:
|
||||||
@@ -105,4 +151,11 @@
|
|||||||
- name: Delete temporary directory
|
- name: Delete temporary directory
|
||||||
file:
|
file:
|
||||||
state: absent
|
state: absent
|
||||||
path: "{{ tmp_dir_path }}"
|
path: "{{ item }}"
|
||||||
|
with_items:
|
||||||
|
- "{{ tmp_dir_path }}"
|
||||||
|
- "{{ _tmp_dir_kustomize.path }}"
|
||||||
|
|
||||||
|
- name: Stop tinyproxy
|
||||||
|
ansible.builtin.command: "docker stop tinyproxy"
|
||||||
|
ignore_errors: true
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import ansible.module_utils.basic
|
|||||||
import pytest
|
import pytest
|
||||||
from ansible.module_utils._text import to_bytes
|
from ansible.module_utils._text import to_bytes
|
||||||
from ansible.module_utils.common._collections_compat import MutableMapping
|
from ansible.module_utils.common._collections_compat import MutableMapping
|
||||||
from ansible.module_utils.six import string_types
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@@ -20,7 +19,7 @@ def stdin(mocker, request):
|
|||||||
old_argv = sys.argv
|
old_argv = sys.argv
|
||||||
sys.argv = ["ansible_unittest"]
|
sys.argv = ["ansible_unittest"]
|
||||||
|
|
||||||
if isinstance(request.param, string_types):
|
if isinstance(request.param, str):
|
||||||
args = request.param
|
args = request.param
|
||||||
elif isinstance(request.param, MutableMapping):
|
elif isinstance(request.param, MutableMapping):
|
||||||
if "ANSIBLE_MODULE_ARGS" not in request.param:
|
if "ANSIBLE_MODULE_ARGS" not in request.param:
|
||||||
|
|||||||
Reference in New Issue
Block a user