Compare commits

..
107 Commits
Author SHA1 Message Date
Yuriy NovostavskiyandGitHub 11b861f77e fix(k8s): emit warnings via AnsibleModule.warn instead of exit_json (#1267)
SUMMARY
runner.py put warnings into the result dict that run_module() and k8s_service unpack into exit_json()/fail_json(). Passing warnings that way is deprecated since ansible-core 2.19 and goes away in 2.23, so every k8s or k8s_service run that produced a warning also emitted a deprecation warning. All five sites now use AnsibleModule.warn.
This also fixes a quieter bug in the same code. For a multi-document manifest run_module() returns {"changed": ..., "result": {"results": results}}, so warnings ended up nested at result.results[*].warnings, where ansible-core never looked. They were silently dropped whenever a task handled more than one resource, and are now shown.
#1033 fixed this class of bug in k8s_drain, k8s_rollback and k8s_scale for #1031, but never touched runner.py.
Fixes #1264
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
k8s
k8s_service
ADDITIONAL INFORMATION
Verified on kind (Kubernetes v1.37.0) with ansible-core 2.21.4
AI Assistance Disclosure
Generated: unit test is AI-generated,
Human Verified: test on the kind cluster performed by a human

Reviewed-by: Don Naro <dnaro@redhat.com>
Reviewed-by: Bikouo Aubin
2026-11-16 17:23:04 +00:00
Romi AsadandGitHub 536eded7d0 chore: address partner engineering feedback (ACA-7227) (#1284)
* chore: address partner engineering feedback

Assisted-by: Codex GPT-6

* Updating CHANGELOG link
2026-11-16 10:11:15 -06:00
408802cb67 k8s: clarify that state=present creates or patches the object (#1278)
Assisted-by: Claude Opus 5.5

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 15:10:13 +01:00
782672d2fd CI - Update workflow to run helm test against multiple versions (#1232)
* add matrix to test run helm tests with multiple version

* fix(ci): resolve SonarCloud security findings in helm integration workflow

Enforce HTTPS/TLS for the ansible-core download and pin and wheel-lock the
selinux_please_lie_to_me install. Suppress the two remaining findings
(ansible-core source install and shared test-requirements.txt pins) that
cannot be fixed here without breaking CI, following the existing
sonar.issue.ignore.multicriteria pattern.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(ci): fix remaining sanity and SonarCloud quality gate failures

Remove stale import-3.9!skip entries from tests/sanity/ignore-2.23.txt;
ansible-core devel dropped the import-3.9 sanity test target entirely, so
referencing it now fails the "ignores" sanity test itself.

Switch the e4/e5 sonar.issue.ignore.multicriteria resourceKey patterns in
sonar-project.properties from a bare literal filename to a **/ glob, matching
the working e1-e3 patterns. The literal path was not matching during
analysis, so the two intended suppressions (githubactions:S8541/S8544 on
integration-tests-helm.yaml) never took effect and kept failing the new
code security rating gate.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(helm): add regression coverage for plain_http/helm-diff fix, enable helm_uninstall target

helm_diff: replace the unreachable "< 3.13.0" OCI-chart block (plain_http is
only ever true for >= 3.13.0, so the two conditions could never both hold)
with a ">= 3.13.0" case that installs helm-diff and runs a plain_http diff
upgrade, exercising the exact path the plain_http/--plain-http fix touches.

helm_plain_http: replace the HTTPS Bitnami-backed test with one that pushes
a local chart to the plain-HTTP registry from setup_helm_registry and
exercises helm/helm_pull/helm_template against it, so success assertions
verify plain HTTP actually works rather than only that the flag was passed.
Also drop the now-stale redis* .gitignore entry.

helm_uninstall: add the missing aliases file (every sibling helm target has
one; without it the target is not picked up by CI target selection) and
replace a dead assertion gated on helm < 3.7.0 with one that matches the
versions this target actually runs against (>= 3.8.0).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(ci): make the S8541/S8544 SonarCloud suppressions actually take effect

The three flagged lines (ansible-core source install, shared
requirements.txt install) have been open since before the suppression
rules were added, and two prior attempts at the e4/e5 resourceKey pattern
(literal filename, then a **/filename glob) left them unresolved across
multiple fresh analyses - already-raised issues on unchanged lines do not
appear to get re-evaluated against newly added ignore rules.

Broaden e4/e5 to the same .github/workflows/**/*.yaml pattern already
proven to work for e3 (confirmed: githubactions:S7637 has 20 open issues
org-wide but 0 here, despite this repo having @main references e3 is meant
to suppress). This is also a more honest scope: all_green_check.yaml has
the identical ansible-core-from-source and shared-requirements.txt
patterns, not just integration-tests-helm.yaml.

Also make a no-op edit to the two flagged lines (reorder the pip flag and
the two -r files; verified zero package overlap between requirements.txt
and test-requirements.txt) so SonarCloud treats them as changed and
re-evaluates them against the fixed suppression rule, rather than carrying
forward the stale pre-suppression issue state.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Fix tests and the possibility to run helm tests locally
Fix linters errors

---------

Co-authored-by: GomathiS <gosriniv@redhat.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-20 16:16:03 +02:00
Yuriy NovostavskiyandGitHub ebb0d7f087 fix(sanity): drop stale import-3.9 ignores for ansible-core 2.23 (#1276)
ansible-core devel dropped Python 3.9 support (ansible/ansible#87582),
which removed the import-3.9 sanity test. The ignores sanity test now
fails on entries for a test that does not exist.

Fixes #1275
2026-10-13 16:44:15 +02:00
Don NaroandGitHub b7e1ed5661 fix: add default to k8s_copy init-pod until conditional (#1233) 2026-09-22 09:01:39 -04:00
f650940f0a Release v5.5.0 (#1260) (#1265)
* Prep `5.5.0` release (#1260)

* Prep `5.5.0` release

Bump galaxy.yml to 5.5.0, generate the changelog from the eight pending
fragments, and regenerate module documentation.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* Bump Makefile VERSION to 5.5.0

The Makefile pins VERSION independently of galaxy.yml and feeds the
clean, release and install targets. Left at 5.4.4 it would publish
kubernetes-core-5.4.4.tar.gz for a 5.5.0 build.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* Bump README requirements.yml example to 5.5.0

The install example pins the collection version and is updated at every
release; it sits outside the collection_prep managed block, so
`tox -e add_docs` does not refresh it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
(cherry picked from commit 747964cefe)

* docs: restore changelog fragments

---------

Co-authored-by: Mandar Kulkarni <mandkulk@redhat.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 11:05:11 +01:00
Don NaroandGitHub 4314ad6091 Release v6.6.0 (#1261) (#1266)
This change syncs the release prep v6.6.0 commit to the main branch.
#1261

Reviewed-by: Alina Buzachis
Reviewed-by: Bikouo Aubin
2026-09-22 09:53:20 +00:00
Don NaroandGitHub 177297fdae fix(sanity): resolve ansible-test devel validation errors (#1268) 2026-09-22 09:06:05 +02:00
10584acdbb fix(helm): validate reuse_values against reset_values and replace (#1230)
* fix(helm): validate reuse_values against reset_values and replace

reset_values defaults to true and helm ignores --reuse-values whenever
--reset-values is passed, so the documented reuse_values example was a
no-op. Warn rather than flip the default, which would silently change
what existing playbooks deploy.

helm install accepts neither --reuse-values nor --reset-then-reuse-values,
so pairing either with replace could only ever make helm report an unknown
flag. Fail up front instead, and keep both flags inside the upgrade branch.

Fixes #1229

* fix(docstring): neither nor replacing

Co-authored-by: Don Naro <dnaro@redhat.com>

* fix(helm): warn instead of failing on replace + reuse_values

reuse_values has been accepted since 3.0.0, and a converged release never
reaches deploy(), so these combinations pass in playbooks today. Failing
in main() would turn them red on upgrade. The flags are already dropped
from the install path, so warning leaves a valid command behind.

Splits the changelog fragment per user-visible change, and covers the
helm diff path, whose 'not replace' guards the hard failure had made
unreachable.

Changes based on the @abikouo's feedback

---------

Co-authored-by: Don Naro <dnaro@redhat.com>
2026-09-16 11:25:48 +01:00
Yuriy NovostavskiyandGitHub 094240ab77 :fix(helm_repository): normalize both sides of the repo URL comparison (#1236)
helm stores repository URLs verbatim, so a repository registered with a
trailing slash keeps it in repositories.yaml. Only the URL coming from the
task was normalized, so a repository that already matched was reported as a
name conflict.

Fixes #1235
2026-09-15 10:26:49 -07:00
Don NaroandGitHub f42c78ce83 Add deprecation warnings for the status.values return value (#1241)
* chore: add deprecation warning for status.values

* docs: add changelog entries for status.values deprecation
2026-09-15 08:28:20 -07:00
c46180bb6f Add ansible-core version check to k8s lookup turbo mode (#1253)
* feat(lookup): add ansible-core version check for turbo mode in k8s lookup

Add ansible-core version checking to the k8s lookup plugin to match the
behavior already implemented in module_utils/ansiblemodule.py.

When ENABLE_TURBO_MODE is set and ansible-core >= 2.19.0:
- Emit deprecation warning for ENABLE_TURBO_MODE
- Emit version warning explaining turbo mode is unsupported
- Disable turbo mode and fall back to standard LookupBase

This prevents confusing tracebacks when cloud.common (which declares
requires_ansible '>=2.15.0,<2.19') is used on newer ansible-core versions
where it is not fully compatible.

Changes:
- Import ansible_version and LooseVersion
- Add TURBO_UNSUPPORTED_CORE = "2.19.0" constant
- Check version before enabling turbo mode
- Disable turbo mode and warn if version >= 2.19.0

Addresses reviewer feedback on PR #1251 to add version testing to the
lookup plugin matching the module implementation.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* test(lookup): add unit tests for k8s turbo mode version check

Add comprehensive unit tests for the ansible-core version checking logic
in the k8s lookup plugin's turbo mode handling.

Tests validate that when ENABLE_TURBO_MODE is set:
- Turbo mode is disabled on ansible-core >= 2.19.0 (tests 2.19.0 and 2.21.4)
- Turbo mode is enabled on ansible-core < 2.19.0 (tests 2.18.0)
- Appropriate deprecation and version warnings are shown
- Standard LookupBase is used when turbo mode is disabled

Tests also verify that when ENABLE_TURBO_MODE is not set:
- No deprecation or warning messages are shown
- Turbo mode remains disabled
- Standard LookupBase is used

Implementation follows pytest best practices:
- Autouse fixture for module cleanup between tests
- Parametrized tests to avoid duplication (2.19.0 and 2.21.4 share logic)
- Mock assertion methods (assert_called, assert_not_called)
- Module-level import of StandardLookupBase to avoid repetition

Simplified and maintainable: 71 lines vs initial 139-line implementation
(49% reduction through deduplication and better abstractions).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* style: format with black

* fixup! test(lookup): add unit tests for k8s turbo mode version check

* docs: add changelog fragment for k8s lookup turbo version check

Add changelog entry documenting that the k8s lookup plugin now ignores
ENABLE_TURBO_MODE on ansible-core >= 2.19.0 and falls back to standard
LookupBase instead of failing with a traceback.

This complements the existing deprecate-enable-turbo-mode.yml fragment
which covers the module implementation, by documenting the lookup plugin
fix specifically.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* fixup! fixup! test(lookup): add unit tests for k8s turbo mode version check

* fixup! fixup! fixup! test(lookup): add unit tests for k8s turbo mode version check

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-09-15 15:35:31 +01:00
8a9dd54fe7 k8s_cp - wait for remote tar to finish before closing the stream (#1217)
* fix(k8s_cp): wait for remote tar to finish before closing the stream

The module closed the exec connection right after writing the last chunk,
killing tar mid-extract, and never checked its exit status, so a partial
or failed copy was reported as success (#776).

The v4 exec protocol cannot half-close stdin, and busybox tar blocks for
EOF rather than stopping at the end-of-archive marker, so bound the stream
with `head -c N | tar ...`. tar then gets a clean EOF, exits on its own,
and its status is read from the error channel. Containers without /bin/sh
and head keep the previous behaviour and get a warning.

Also add copy_timeout (default 300s, #621) and stream the archive from the
temp file instead of buffering every chunk in memory.

* test(k8s_cp): split combined assert into separate statements

Addresses review feedback on #1217.

* chore(changelog): link the PR and use single-line fragment entries

* fix(linter): reformat with black

* fix(linter): sort imports in test_copy.py

isort --profile black puts ansible_collections in the same third-party
section as pytest, so the blank line between them is a failure.

* fix(k8s_cp): report what tar said when the copy fails early

An early close or a stall is the symptom; tar has usually already
written the cause (a read-only mount, a missing directory) to stderr,
and drain() has it. Discarding it left only the generic truncation or
timeout message.

* refactor(k8s_cp): move the stderr suffix into _fail

The nested fail() helper added a branch inside a closure, which counts
double for nesting and took _stream_tar_to_pod over Sonar's cognitive
complexity limit (14 -> 16). _fail already had the response; give it
the stderr too.

* test(k8s_cp): tempfile for the repeated-copy test directory

Co-authored-by: Bikouo Aubin <79859644+abikouo@users.noreply.github.com>

---------

Co-authored-by: Bikouo Aubin <79859644+abikouo@users.noreply.github.com>
2026-09-15 09:20:10 +01:00
031bc475fa Add a deprecation notice for ENABLE_TURBO_MODE (#1242)
* Add a deprecation notice for ENABLE_TURBO_MODE

* minor fix

* fix(turbo): ensure deprecation warning reaches user and skip turbo on unsupported ansible-core

Move the ENABLE_TURBO_MODE deprecation warning to module import time,
since AnsibleTurboModule.__init__() exits the process before returning,
making the previous per-instance deprecate() call unreachable. Also
skip turbo mode on ansible-core >= 2.19.0, where cloud.common is not
supported and the import succeeding could otherwise fail later with
an unrelated traceback, and warn instead of silently falling back
when cloud.common is not installed.

Assisted-by: Claude Sonnet 5

* docs(turbo): clarify that turbo mode is ignored on ansible-core 2.19+

Turbo mode is now bypassed with a warning rather than failing on
unsupported ansible-core, so drop the "may lead to fails" wording from
the README note and the matching statement in the turbo mode guide.

Assisted-by: Claude Opus 5
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 11:24:26 -07:00
Yuriy NovostavskiyandGitHub c098ecc8c8 fix(helm): skip Helm's OCI registry progress messages on stdout (#1223)
* fix(helm): skip OCI registry progress messages on stdout

Helm 4.2.1 moved the registry client's progress messages from stderr to
stdout (helm/helm#32056), so on an OCI reference they now precede the real
output. helm parses the stdout of `helm show chart` and helm_template
returns the stdout of `helm template`, and neither can detect this from the
return code because both commands exit 0.

Helm rewrites '+' to '_' in OCI tags, which makes it also print a free-text
explanation. That is not valid YAML, so a chart version carrying semver
build metadata failed outright. Without the '+' the messages parse as a
mapping instead, silently adding Pulled/Digest keys to the chart info.

Match helm's message verbatim rather than seeking the start of the real
output: the payload has three shapes and can be empty, whereas the messages
are always at the front and byte-identical. A reworded message then fails
loudly instead of consuming a line of real output.

Fixes: #1222

* test(helm): cover OCI charts whose version has build metadata

Pushes a chart versioned 1.0.0+build.1 to the local registry and asserts
that helm installs it idempotently with the version reported verbatim, and
that helm_template returns only rendered manifests. A second version without
build metadata covers the case where the registry messages parse as YAML.

Pinned to Helm 4.2.4: the target is only meaningful on >= 4.2.1, which is
where the messages moved to stdout. The rest of the helm matrix tops out at
v4.0.0, which is why this went unnoticed.

Verified to fail on the parent commit and pass on the fix.

* test(helm): drop Go template from chart fixture

The yamllint sanity test parses chart templates with libyaml, where
`{{ default "test" .Values.myValue }}` is an unhashable mapping key. The
existing chart fixtures carry a yamllint!skip entry in every
tests/sanity/ignore-*.txt for exactly this, but the target never renders
the chart with values, so the template served no purpose. Making the
fixture plain YAML keeps the ignore lists from growing.

* test(ci): empty commit to re-trigger CI
2026-09-14 13:51:18 +01:00
Don NaroandGitHub 732925b986 ci: add the PE certification checker workflow (#1231)
* ci: add the PE certification checker workflow

* ci: add stable branches to certification workflow
2026-09-14 13:33:11 +01:00
Don NaroandGitHub cb00cf3c9e Address stale deprecations (#1240)
* chore: update deprecation for wait_timeout

* chore: update deprecation for return_code

* docs(changelogs): add stale deprecations to changelogs

* docs: ignore pylint deprecation warnings

* chore: update deprecation for merge_type

* docs: update changelogs for merge_type

* docs: ignore more pylint deprecation warnings
2026-09-14 13:29:16 +01:00
Yuriy NovostavskiyandGitHub 7df5e01974 chore(test): add ansible 2.21 to integration tests matrix (#1234)
* chore(test): add ansible 2.21 to integration tests matrix

current version of Ansible (as the time of this commit) is
2.21 that is included in the Ansible 14 release.

To ensure testing coverage for actual version if ansible,
version 2.21 should be included in the integration tests matrix.

Updated matrix includes:
- stable-2.18 as the latest version support turbo mode
- stable-2.21 as the actual version
- milestone as the development version

* chore(test): exclude 2.18/turbo off from integration tests matrix

stable-2.18 is used mostly as the last version with turbo mode,
so no reason to test it with turbo mode disabled as it tested with
the later version of ansible.

Excluding to decrease CI time/cost
2026-09-14 05:49:16 -04:00
a7922e498c Fix ansible-lint no-changed-when and execution-environment schema warnings (#1196)
* Fix ansible-lint no-changed-when and execution-environment schema warnings

Add `changed_when: false` to example command tasks in the kubectl
connection plugin to resolve no-changed-when warnings from ansible-lint.

Add `version: 3` to meta/execution-environment.yml to satisfy the
schema[execution-environment] rule requiring the version property.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Add changelog fragment for ansible-lint warning fixes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Fix changelog fragment YAML formatting

Quote strings to avoid YAML parsing ambiguity in the trivial section.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-09-10 14:36:47 +01:00
Yuriy NovostavskiyandGitHub d9e0218dba test(sanity): align python_requires with documented 3.9+ support (#1226)
tests/config.yml declared ">=3.6", so ansible-test ran the module import
test on target Python versions this collection never supported, while
README states 3.9+. Narrow the declaration and add ignore entries for the
supported target versions that were missing.
2026-08-26 09:39:16 -04:00
0bc99117af fix(meta): add missing modules to helm and k8s action groups, document them (#1216)
* fix(meta): add missing modules to helm and k8s action groups

`helm_plugin` and `helm_plugin_info` both build their argument spec from
`HELM_AUTH_ARG_SPEC`, and `k8s_taint` builds its own from `AUTH_ARG_SPEC`,
but none of the three were listed in the action groups. Anyone setting
`module_defaults` on `group/kubernetes.core.helm` or
`group/kubernetes.core.k8s` silently got no defaults for them.

Deliberately left out of the groups, since they do not accept the shared
authentication options and would make `module_defaults` fail for every
user of the group:

  - `helm_pull` and `helm_template` take only `binary_path`
  - `helm_registry_auth` takes `binary_path` plus its own required `host`,
    which is an OCI registry URL rather than a Kubernetes API server
  - `kubeconfig` writes a kubeconfig file locally and takes no cluster
    connection options

Also documents both action groups in the scenario guide, including the
exclusions above and the distinction from the legacy `k8s` group that
ansible-core defines, which is a different group and does not cover this
collection's modules.

Closes #577

* test(meta): guard action group membership against argspec drift

The action groups in `meta/runtime.yml` were maintained by hand, so
`helm_plugin`, `helm_plugin_info` and `k8s_taint` were able to inherit the
shared authentication arg specs without anyone adding them to a group.
Nothing failed, users just silently got no `module_defaults`.

Asserts the invariant in both directions: a module belongs to a group if
and only if it builds its argument spec from that group's shared constant.
The reverse direction matters too, since a member that does not accept the
shared options makes `module_defaults` fail with "Unsupported parameters"
for every user of the group.

Membership is read statically with `ast`, so the test needs no imports and
runs without a cluster or the `kubernetes` package.

The four modules that are deliberately excluded are listed with their
reasons, so restoring one has to be a decision rather than an oversight.

* fix(tests): satisfy pylint disallowed-name and set an explicit license

ansible-test's pylint profile rejects `_` as a name, which the sanity job
flagged three times. Rather than renaming the throwaways, give the entries
in SHARED_ARG_SPECS named keys so there is nothing to discard when reading
them back.

The header was copied from a sibling test that carries Apache-2.0 because
it derives from kubernetes/kubernetes, so it named the wrong copyright
holder. It now names the author, and keeps Apache-2.0 deliberately: the
collection requirements allow code outside plugins/ that imports no
GPL-3.0-or-later code to use any GPL-3.0-compatible license, and this file
imports only ast, os, pytest and yaml, since it reads group membership
statically rather than importing the modules. A comment records that
reasoning so the constraint is visible if an import is ever added.

* fix(doc): update changelog fragment with the manintainer suggestion

* fix(doc): show helm group defaults in the action group example

abikouo asked for the module_defaults example to cover the helm action
group as well, with tasks that actually consume those defaults. Set
binary_path, kubeconfig and context on group/kubernetes.core.helm and
add helm_repository, helm and helm_info tasks that rely on them; the
namespace in the k8s tasks now matches the release namespace so the
playbook reads as one flow.

Co-Authored-By: Bikouo Aubin <79859644+abikouo@users.noreply.github.com>

---------

Co-authored-by: Bikouo Aubin <79859644+abikouo@users.noreply.github.com>
2026-08-14 15:36:02 -04:00
c643719085 Use collections.abc (#1057)
* use collections.abc

ansible.module_utils.common._collections_compat shall be deprecated in
ansible-core 2.24

Use collections.abc

Link: https://forum.ansible.com/t/deprecation-warnings-in-ansible-core-2-20/44741
Signed-off-by: Plamerdi Makela <plamerdi447@gmail.com>

* Apply suggestion from @abikouo

* Fix linter errors

---------

Signed-off-by: Plamerdi Makela <plamerdi447@gmail.com>
Co-authored-by: Bikouo Aubin <79859644+abikouo@users.noreply.github.com>
Co-authored-by: Bianca Henderson <bianca@redhat.com>
2026-08-14 15:34:44 -04:00
e475d06403 Support wait_for_jobs flag for helm release upgrade/install (#1140)
* Support wait_for_jobs flag for helm release upgrade/install

* Update plugins/modules/helm.py

Co-authored-by: Yuriy Novostavskiy <yuriy@novostavskiy.kyiv.ua>

* Apply suggestion from @abikouo

* fix(helm): correct wait_for_jobs implementation and add changelog

- Fix double-append of --wait-for-jobs flag
- Fix version check to run before appending the flag
- Fetch helm_version before use to avoid undefined variable
- Fix YAML indentation for version_added in docs
- Add changelog fragment

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: add integration tests for wait_for_jobs

- Test that --wait-for-jobs is appended when wait=true and wait_for_jobs=true
- Test that wait_for_jobs fails with appropriate message on helm < 3.5.0
- Test that wait_for_jobs is ignored when wait is not set
- Add test-chart-job helm chart containing a simple Job resource

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: harden test Job pod spec

Disable service account token automounting and add memory limit to
the test Job container.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: add resource requests and pin image version in test Job

Add CPU, memory, and ephemeral-storage requests. Pin busybox image
to version 1.37.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* style: apply linter formatting to helm argument_spec

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Update sanity ignore file

* fix: quote Helm template expression to pass yamllint sanity

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix linters errors

---------

Co-authored-by: Bikouo Aubin <79859644+abikouo@users.noreply.github.com>
Co-authored-by: Yuriy Novostavskiy <yuriy@novostavskiy.kyiv.ua>
Co-authored-by: aubin bikouo <abikouo@redhat.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-08-11 14:56:40 +02:00
Yuriy NovostavskiyandGitHub f31ecce59c ci: exclude test code from SonarCloud duplication detection (#1207)
Duplication is scored on new code only, so a PR adding cases to an already
repetitive test module inherits debt accrued across earlier PRs rather than
introducing it; tests/unit/modules/test_module_helm.py sits at 47.9% on main
before any change.

sonar.exclusions filters the source set, not the copy/paste detector, so test
code needs its own exclusion. Production code stays covered.
2026-08-10 17:08:37 +02:00
3e58e3a9ad feat(waiter): add native wait support for Job resources (#1202)
Add a `job_complete` predicate that waits for Job resources to reach
either `Complete` or `Failed` condition, removing the need for custom
wait_condition workarounds.

Also rename shadowed `match` variable to `match_condition` in
`custom_condition` to avoid masking the Python built-in.

Fixes ansible-collections/kubernetes.core#1201

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-08-10 16:30:44 +02:00
d4ef10fc80 feat(helm): add cleanup_on_fail option (#1206)
* feat(helm): add cleanup_on_fail option

atomic rolls back to the last successful revision but can leave behind
resources the failed upgrade created; helm accepts both flags together so
the rollback also drops those orphans.

Rejected with replace=true, since that deploys via helm install, which has
no --cleanup-on-fail. No version gate: the flag exists in helm 3.0.0, the
module's minimum, and was not renamed in v4.

* refactor(tests): share helm command-building test helpers

The new cleanup_on_fail tests copied setUp and _run_with_version verbatim
from the atomic tests, which SonarQube flagged as duplication on new code.
Extract both to module level so the two classes share them.

Scoped to the classes involved in that duplication; the other test classes
in this file keep their own fixtures.

* test(helm): align cleanup_on_fail assertions with review feedback

Adjust the Helm unit tests to assert the expected flags for
cleanup_on_fail on Helm v3 and v4, matching the behavior clarified
in review feedback.

Co-authored-by: abikouo <abikouo@users.noreply.github.com>

---------

Co-authored-by: abikouo <abikouo@users.noreply.github.com>
2026-08-10 10:23:38 -04:00
ec8942dd90 Handle empty template output gracefully (#1044)
* Handle empty template output gracefully

* Add changelog fragment for empty template output fix

* refactor: reduce cognitive complexity of ActionModule.run

Extract compound boolean condition to a variable to reduce the
cognitive complexity from 16 to the allowed maximum of 15.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* refactor: extract duplicated error handling into _fail_with_error

Replace two identical error-handling blocks in ActionModule.run() with
a shared _fail_with_error static method to address SonarQube code
duplication finding.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* refactor: reduce code duplication in action plugin and tests

Revert _fail_with_error extraction that increased duplication on new
code. Consolidate duplicate integration test tasks for conditional
template into a single looped task.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: aubin bikouo <abikouo@redhat.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-08-07 11:14:22 +02:00
08a761fc17 Support for metadata-only fetches in k8s_info module (#1030)
* Support for metadata-only fetches in k8s_info module

* Fix integration test assert

* Add missing changelog fragment

* Fix linters and sanity checks

* Fix linters

* Apply suggestion from @abikouo

* fix: resolve linter errors after rebase

Fix import sorting and apply black formatting to k8s_info.py and
args_common.py to pass tox -e linters.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Bikouo Aubin <79859644+abikouo@users.noreply.github.com>
Co-authored-by: aubin bikouo <abikouo@redhat.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-08-06 14:25:35 -04:00
dd4ca7a8b0 Remove remaining ansible.module_utils.six import from kubectl connection plugin (#1197)
* Replace ansible.module_utils.six with Python stdlib equivalents

ansible.module_utils.six is deprecated in ansible-core 2.21 and is
scheduled for removal in 2.24. Every use of it in this collection has a
direct Python 3 standard library equivalent, so switch to those.

* Update changelogs/fragments/20260723-remove-module-utils-six.yaml

Co-authored-by: Bikouo Aubin <79859644+abikouo@users.noreply.github.com>

---------

Co-authored-by: Bikouo Aubin <79859644+abikouo@users.noreply.github.com>
2026-07-31 14:09:54 +02:00
Bianca HendersonandGitHub b1d809d9f3 Prep 5.4.4 release (#1193) (#1194)
* Fix ansible version for 5.4.3 release

* Prep release 5.4.4

(cherry picked from commit 44fbb83be4b2ea9d3ee4479f7aa131cf72b3b0e3)
(cherry picked from commit 1a0914352a)
2026-07-13 11:58:02 -04:00
18f8894a22 Prepare release 6.5.0 (#1188) (#1192)
* Prepare k8s collection release 6.5.0

* update release date for the version 6.5.0

* Update changelog.yaml and changelog.rst mismatch

---------


(cherry picked from commit 0f472b53e2)

Co-authored-by: Yuriy Novostavskiy <yuriy@novostavskiy.kyiv.ua>
2026-07-09 10:47:16 -04:00
Bianca HendersonandGitHub 3876bc1a21 Prep release 5.4.3 (#1187) (#1191)
* Prep k8s collection release 5.4.3

* Update release date for 5.4.3

* Update changelog.yaml and changelog.rst mismatches

(cherry picked from commit efe2d1aa69)
2026-07-08 14:09:07 -04:00
Bianca HendersonandGitHub 470c042690 Update RST documentation files (#1189) 2026-07-07 16:59:05 -04:00
Bianca HendersonandGitHub 75a5560aec Add lint ignore entry (#1184) 2026-07-06 16:08:33 -04:00
a80e2d067c Add meta/execution-environment.yml to fix EE builds on UBI images (#1142)
ansible-builder builds fail with "No package matches 'openshift-clients'"
on UBI images because the openshift-clients RPM in bindep.txt requires
repos not available in standard UBI. This adds collection-level EE
metadata pointing to a minimal bindep file without openshift-clients,
while preserving the original bindep.txt for direct bindep usage.

Fixes #1141

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-07-06 15:23:53 -04:00
6bb9cce51b feat(ci): add security check to block .claude/ and .vscode/ directories (#1173)
* feat(ci): add security check to block .claude/ and .vscode/ directories

Add workflow that calls the security_check_directories action from
cloud-content-ci-automation to fail PRs containing files under .claude/
or .vscode/ directories.

Integrates with all_green_check.yaml as a required job for PRs.

Ref: ACA-6411

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(ci): suppress SonarCloud S7637 for reusable actions using @main

Internal reusable actions from ansible-network/github_actions and
ansible-collections/cloud-content-ci-automation use @main refs for
simpler maintenance. Suppress the 'use full commit SHA' rule for
workflow files.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(ci): use correct org and pin action to commit SHA

Address review feedback:
- Change org from ansible-collections to ansible
- Pin to commit SHA 74b5fe87 instead of @main

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: add changelog fragment for security check workflow

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Update changelogs/fragments/1173-security-check-workflow.yml

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Bianca Henderson <beeankha@gmail.com>
2026-07-02 16:48:56 -04:00
4b3e24bf02 feat: add plugin --keyring option (#1150)
* feat: add plugin --keyring option

* docs: add changelog fragment

* Update changelogs/fragments/20260620-add-plugin-keyring-option.yaml

Co-authored-by: Yuriy Novostavskiy <yuriy@novostavskiy.kyiv.ua>

* feat: restrict helm_plugin keyring to install subcommand (#1)

Restrict the keyring option to state=present (helm plugin install),
the only implemented subcommand that supports --keyring, and fail
explicitly when it is used with other states.

Co-authored-by: Kenji Gaillac <48765390+Nhqml@users.noreply.github.com>

* refactor(helm_plugin): warn instead of fail

* Resolve linter error

* Update plugins/modules/helm_plugin.py

---------

Co-authored-by: Yuriy Novostavskiy <yuriy@novostavskiy.kyiv.ua>
Co-authored-by: Bianca Henderson <bianca@redhat.com>
Co-authored-by: Bianca Henderson <beeankha@gmail.com>
2026-07-01 18:32:09 -04:00
Yuriy NovostavskiyandGitHub bc17b33d44 helm: use --rollback-on-failure for atomic on Helm v4 (#1144)
* helm: use --rollback-on-failure for atomic on Helm v4

Helm v4 renamed the `--atomic` flag to `--rollback-on-failure`. The old
flag is deprecated on `helm upgrade` and removed entirely from `helm
install`, so `atomic: true` failed against Helm v4 (issue #1143).

Emit the version-appropriate flag from deploy() using the existing
is_helm_v4() helper, covering both the upgrade and the replace/install
code paths. The public `atomic` option is unchanged.

Fixes: https://github.com/ansible-collections/kubernetes.core/issues/1143

Co-Authored-By: Claude Opus 4.8

* fix wrong link in the changelog fragment

Signed-off-by: Yuriy Novostavskiy <yuriy@novostavskiy.kyiv.ua>

---------

Signed-off-by: Yuriy Novostavskiy <yuriy@novostavskiy.kyiv.ua>
2026-07-01 14:30:52 -04:00
Yuriy NovostavskiyandGitHub 3634105366 fix(helm): support Helm v4 force/server-side apply flags (#1164)
* fix(helm): support Helm v4 force/server-side apply flags

Helm v4 deprecated --force and enables server-side apply by default, so
playbooks relying on force=true broke with "Flag --force has been
deprecated" and "cannot use server-side apply and force replace together".
Because force always meant a client-side delete/recreate replacement, the
module now reproduces that behaviour on v4 (--server-side=false
--force-replace) so existing playbooks keep working unchanged across both
Helm versions.

To let users opt into Helm v4's server-side world explicitly, add
server_side and force_conflicts options. These are mutually exclusive with
force (a client-side replacement cannot coexist with a server-side mode),
keeping the surface unambiguous and surfacing bad combinations up front
instead of as cryptic Helm errors.

AI-assisted commit with Claude Opus

* fix(linter) reformat tests/unit/modules/test_module_helm.py with black
2026-07-01 12:24:55 -04:00
Bianca HendersonandGitHub ceeafa8c6d Point to Python 3.13 for ansible-core devel (#1174) 2026-07-01 09:29:22 -04:00
Bikouo AubinandGitHub a4fc40732a CI - configure precommit hook to block commit when files from .claude… (#1149)
* CI - configure precommit hook to block commit when files from .claude/ and/or .vscode/ directories are staged

* fix sanity issue - shebang

* Remove local hook and update documentation
2026-06-30 10:32:14 +02:00
Yuriy NovostavskiyandGitHub 0836e96c2d ci: suppress SonarCloud python:S5443 for test code (#1165)
Unit tests pass hardcoded '/tmp/...' strings as fake module arguments (for
example chart_ref) into fully mocked helm commands, so no file is ever
created and there is no real exposure. SonarCloud's python:S5443 still
raises a security hotspot on each literal and, because it only scores new
code, drops a PR's security rating even though the same pattern already
pervades the existing test suite.

Scope the suppression to tests/** only. Production code creates temporary
files via tempfile.mkstemp / NamedTemporaryFile and remains covered by the
rule, where it carries real value.

AI-assisted commit with Claude Opus
2026-06-29 15:43:10 -04:00
Bianca HendersonandGitHub d211f316ad Fix CI Test Collision (#1162)
* Fix CI concurrency issue

* More CI fixes

* Fix coverage job install

* Install correct test dependencies
2026-06-29 14:10:38 -04:00
Bianca HendersonandGitHub bb80dde66d Fix workflow concurrency issue (#1159) 2026-06-26 11:41:08 -04:00
Bianca HendersonandGitHub 8bf31513f5 Fix all-green CI workflow (#1153) 2026-06-26 10:34:56 -04:00
Yuriy NovostavskiyandGitHub ae90b60fd6 helm_registry_auth: document/test stdout for registry success messages (Helm 4.2.1) (#1147)
* helm: document/test stdout for registry success messages (Helm 4.2.1)

Helm < 4.2.1 prints registry success messages (Login Succeeded, Pushed,
Pulled, Digest) to stderr (helm/helm#13464); Helm >= 4.2.1 moves them to
stdout (helm/helm#32056). The modules key on the return code, so logic is
unaffected, but the RETURN docs and integration assertions assumed stderr.

- helm_registry_auth: note the version-dependent output stream in
  the RETURN documentation.
- helm_registry_auth integration tests: assert success messages against the
  stdout+stderr union so they pass on both old and new Helm.

Fixes: #1146

Co-Authored-By: Claude Opus 4.8

* ci: empty commit to re-trigger ci
2026-06-25 14:19:14 -04:00
Yuriy NovostavskiyandGitHub 1c20b53bdc ci: suppress SonarCloud python:S7498 for argument_spec dict() convention (#1152)
Ansible module argument_spec is conventionally defined with the dict(...)
constructor rather than {...} literals, for readability and consistency
across the collection. SonarCloud's python:S7498 ("Literal syntax should
be preferred...") flags this as a false positive and re-fires on every
new module argument. Ignore the rule project-wide via sonar-project.properties.

Fixes #1151
2026-06-25 14:00:33 -04:00
Bianca HendersonandGitHub f69761f37c Fix unit test failures in CI (#1133) 2026-05-25 10:57:26 -04:00
Bianca HendersonandGitHub cb7a932951 [ACA-5027] Add SonarQube Cloud Test Coverage Info (#1124)
* Adding SonarQube coverage-related info

* README updates

* Fix all_green_check workflow

* Quality Gate fix

* Update sonarcloud workflow, update docs

* Add sonarcloud job to all_green_check and update docs accordingly
2026-05-21 13:46:18 -04:00
Yuriy NovostavskiyandGitHub 248e0d7db9 docs: clarify ansible turbo mode with version compatibility notice (#1120)
The docs/ansible_turbo_mode.rst file was accidentally removed in PR#988,
breaking the link referenced in README.md. Restore it so users following
that link get the full Turbo mode documentation rather than a 404.

Additionally, document the ansible-core version compatibility issue for
cloud.common (see ansible-collections/cloud.common@5e3430d and
kubernetes.core PR #1109): Turbo mode is incompatible with ansible-core
>= 2.19 because cloud.common no longer supports it. Without this
clarification users on newer ansible-core versions encounter silent or
confusing failures when ENABLE_TURBO_MODE=1 is set.

Update README.md with the same warning so the incompatibility is visible
before users follow the link to the full docs.

Addresses: #927
2026-05-21 12:47:42 -04:00
53c6c0ee80 Kubeconfig module improvement (#1123)
* Add kubeconfig module for managing Kubernetes config files

* Remove unnecessary requirement & Change version

* Move functions to module_utils

* Add unit tests

* Add kubeconfig module for managing Kubernetes config files

* Remove unnecessary requirement & Change version

* Move functions to module_utils

* Add unit tests

* Avoid linter errors

* Improve documentation clarity

* Redact sensitive kubeconfig information

* Imprvoe verbosity

* Move import statement for to_native to avoid linters check failure

* Fix linting error

* Add remove behavior

* Add tests for remove behavior

* Imporve documentation

* Add changelog

---------

Co-authored-by: Bianca Henderson <bianca@redhat.com>
2026-05-19 10:10:19 -04:00
b58b2ca70e Update pod deletion conditions for local storage used in a daemon set pod (#1095)
* Update pod deletion conditions for local storage used in a daemon set pod

Refactor pod deletion logic to handle local storage in daemon set pods correctly.

* Add bugfix for k8s_drain handling local storage pods

Fix logic for handling pods with local storage in k8s_drain.

* Refactor filter_pods function for clarity and efficiency

* Fix sanity and linter errors

---------

Co-authored-by: Bianca Henderson <bianca@redhat.com>
2026-05-15 14:55:55 -04:00
Yuriy NovostavskiyandGitHub 8a58d3b6de fix(helm_repository): strip trailing slashes from repo_url (#1121)
Helm normalizes repository URLs internally, so a URL supplied with a
trailing slash and the same URL without one are treated as different
entries. This causes the module to fail every run when the user
provides a trailing slash, even though the repository is already
correctly registered.

Strip the trailing slash from repo_url before comparing against the
existing repository list so repeated runs with the same input are
idempotent.

Fixes #480
2026-05-13 20:44:39 -04:00
e79ed52a4d Add kubeconfig module for managing Kubernetes config files (#1104)
* Add kubeconfig module for managing Kubernetes config files

* Remove unnecessary requirement & Change version

* Move functions to module_utils

* Add unit tests

* Add kubeconfig module for managing Kubernetes config files

* Remove unnecessary requirement & Change version

* Move functions to module_utils

* Add unit tests

* Avoid linter errors

* Improve documentation clarity

* Redact sensitive kubeconfig information

* Imprvoe verbosity

* Move import statement for to_native to avoid linters check failure

* Fix linting error

---------

Co-authored-by: Bianca Henderson <bianca@redhat.com>
2026-05-06 07:56:22 -04:00
Birger Johan NordølumandGitHub 4d7dc2a7d1 docs: add until example to k8s_info (#885)
I would liked to have an example like this when I was using the
documentation.
2026-05-05 15:47:19 -04:00
Bianca HendersonandGitHub c2cfa51655 [ACA-5027] Configure SonarQube Cloud (#1116)
* Configure SonarQube Cloud

* Update workflow file and add info to README

* Resolve sanity errors

* Add pinned version details to sonarcloud.yml
2026-05-05 13:09:24 -04:00
Bianca HendersonandGitHub fb10b41918 Release prep for 6.4.0 (#1101) (#1115)
Merging changes from stable-6 back into main.

Reviewed-by: Matthew Johnson
Reviewed-by: Hannah DeFazio <h2defazio@gmail.com>
2026-04-24 18:46:37 +00:00
Bianca HendersonandGitHub 210467b26d Update URL reference in integration-test CI file (#1112) 2026-04-22 11:59:04 -04:00
Yuriy NovostavskiyandGitHub 11f619b69e ci: conditionally test turbo mode and cloud.common (#1109)
The cloud.common collection is incompatible with ansible-core >= 2.19.0.
With the current testing matrix using Python 3.12 and the ansible
milestone (currently 2.22), this incompatibility causes integration
tests to fail.

Instead of completely removing turbo mode from the testing matrix, this
commit adds ansible-core 2.18 to the matrix and excludes the combination
of the ansible milestone and turbo mode. The checkout and installation
of the cloud.common collection are now conditionally executed only when
turbo mode is enabled.
2026-04-21 14:20:06 -04:00
Yuriy NovostavskiyandGitHub 16e92a20e8 trivial(doc): post #1090 cosmetic update (#1097)
SUMMARY
Name of the Helm plays in the integration test framework test updated to reflect the actual version of Helm (addressed comments #1090 (review))
Updated documentation for the modules updated in the PR with the https://github.com/ansible-network/collection_prep, as per CONTRIBUTING.md
ISSUE TYPE

Docs Pull Request

COMPONENT NAME

tests/integration/targets/helm_v3_*/play.yaml
docs/kubernetes.core.helm*.rst

ADDITIONAL INFORMATION
Only cosmetic changes in this PR, so the label skip-changelog is suggested

Reviewed-by: Bianca Henderson <beeankha@gmail.com>
2026-04-20 21:33:42 +00:00
Yuriy NovostavskiyandGitHub 58f8f2e6e9 Add sanity test ignores for ansible-core 2.22 (#1102)
The `devel` and `milestone` branches for ansible-core have been bumped to
`2.22.0.dev0` as the `stable-2.21` branch was created. Testing against `devel`
and `milestone` now uses 2.22, which requires creation of the
`tests/sanity/ignore-2.22.txt` file in all maintained collection branches.

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch ignore-2.22
# Changes to be committed:
#	new file:   tests/sanity/ignore-2.22.txt
#
2026-04-20 17:00:09 -04:00
Matthew JohnsonandGitHub 52f9a5b54b ACA-2437: added a CI.md file (#1094)
SUMMARY
Added a CI file to outline the testing strategy in more detail
ISSUE TYPE

Docs Pull Request

Reviewed-by: Bianca Henderson <beeankha@gmail.com>
Reviewed-by: Yuriy Novostavskiy <yuriy@novostavskiy.kyiv.ua>
Reviewed-by: Matthew Johnson
2026-03-18 15:42:30 +00:00
Bikouo AubinandGitHub e6076e5568 Ensure compatibility with Helm v4 for the collection (#1090)
SUMMARY

Ensure compatibility with Helm v4 for modules helm_plugin and helm_plugin_info
Partially addresses #1038

ISSUE TYPE


Feature Pull Request

COMPONENT NAME

helm_plugin
helm_plugin_info
helm_info
helm_pull
helm_registry_auth
helm
helm_template

Reviewed-by: Bianca Henderson <beeankha@gmail.com>
Reviewed-by: Yuriy Novostavskiy <yuriy@novostavskiy.kyiv.ua>
Reviewed-by: Alina Buzachis
2026-03-06 14:50:14 +00:00
42acb4f52b Support take_ownership parameter in helm installation (#1034)
* Support take_ownership parameter in helm installation

SUMMARY
Adds support for the take_ownership for initial release installation operations.

ISSUE TYPE
Feature Pull Request

COMPONENT NAME
plugins/modules/helm.py

* Update changelogs/fragments/20251224-take-ownership-helm-initialization.yaml

Co-authored-by: Bikouo Aubin <79859644+abikouo@users.noreply.github.com>

---------

Co-authored-by: Mathis Raemy <mathis.raemy@swissdotnet.ch>
Co-authored-by: Bikouo Aubin <79859644+abikouo@users.noreply.github.com>
2026-02-19 14:59:23 +01:00
Bikouo AubinandGitHub d239adbbbc Add check_mode support for k8s_drain module (#1086)
SUMMARY

Closes #1037

added support for check_mode
Converted warnings into informational display when user has explicitly requested to delete daemontset-managed pods, unmanaged pods or pods with local storage


ISSUE TYPE


Feature Pull Request

COMPONENT NAME

k8s_drain

Reviewed-by: Bianca Henderson <beeankha@gmail.com>
2026-02-16 13:10:38 +00:00
Bianca HendersonandGitHub 6d942f5e45 Prep 6.3.0 release (#1084) (#1088)
Merging changes from stable-6 back into main.

Reviewed-by: GomathiselviS <gomathiselvi@gmail.com>
Reviewed-by: Matthew Johnson
2026-02-04 20:39:45 +00:00
Bianca HendersonandGitHub bc0406cf02 Prep 5.4.2 release (#1083) (#1087)
Merging changes from stable-5 back into main.

Reviewed-by: Hannah DeFazio <h2defazio@gmail.com>
Reviewed-by: Bikouo Aubin
2026-02-04 15:23:34 +00:00
Bianca HendersonandGitHub 23b6cec173 Fix incorrect assertion in helm_pull integration test (#1077)
SUMMARY

The error message emitted for incorrect helm version has changed since the merge of #1039. This PR updates the related assertion in the helm_pull integration test

Reviewed-by: Chyna Sanders
Reviewed-by: Mike Graves <mgraves@redhat.com>
2026-01-29 16:49:49 +00:00
Yuriy NovostavskiyandGitHub 34beacf32b Add idempotency to helm_pull module (#1055)
SUMMARY
This PR implements idempotency for the helm_pull module, addressing issue #889.

New force parameter with defaults to False.
implemented chart_exists() function
checks chart existence before downloading, returns changed=False when chart exists

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
helm_pull
ADDITIONAL INFORMATION
Force parameter added for backward compatibility and edge cases.
Implemented with the partial support of GitHub Copilot with Claude Sonnet 4.5 model

Reviewed-by: Bikouo Aubin
Reviewed-by: Yuriy Novostavskiy <yuriy@novostavskiy.kyiv.ua>
Reviewed-by: Bianca Henderson <beeankha@gmail.com>
Reviewed-by: Alina Buzachis
2026-01-29 14:03:56 +00:00
Yuriy NovostavskiyandGitHub 3e32c12c40 Replace passing `warnings to exit_json with AnsibleModule.warn` for the few modules (#1033)
SUMMARY
Using exit_json or fail_json for warnings is deprecated in ansible-core>=2.19.0 and will be removed in ansible-core>=2.23.0
Tested with ansible-core 2.19.3 as the latest released version at the time of the start of this PR and with 2.16.0 as the lowest version supported by kubernetes.core 6.x
Resolves: #1031
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
k8s_drain
k8s_rollback
k8s_scale
ADDITIONAL INFORMATION
The initial version of this PR covers only the module k8s_drain, with the following commits extended to k8s_rollback
k8s_scale

Reviewed-by: Bianca Henderson <beeankha@gmail.com>
Reviewed-by: Mike Graves <mgraves@redhat.com>
Reviewed-by: Alina Buzachis
2026-01-26 19:52:15 +00:00
Yuriy NovostavskiyandGitHub 13791ec7bf Limit compatibility to Helm =>v3.0.0,<4.0.0 (#1039)
SUMMARY
Helm v4 is a major version with backward-incompatible changes, including to the flags and output of the Helm CLI and to the SDK. This version is currently not supported in the kubernetes.core. This PR is related to #1038 and is a short-term solution to mark compatibility explicitly
ISSUE TYPE

Bugfix Pull Request
Docs Pull Request

COMPONENT NAME

helm
helm_template
helm_info
helm_repository
helm_pull
helm_registry_auth
helm_plugin
helm_plugin_info

ADDITIONAL INFORMATION
Added `validate_helm_version()`` method to AnsibleHelmModule that enforces version constraint >=3.0.0,<4.0.0.
Fails fast with clear error message: "Helm version must be >=3.0.0,<4.0.0, current version is {version}"
Some modules (i.e. helm_registry_auth) technically is compatible with Helm v4, but validation was added to all helm modules.
Partially coauthored by GitHub Copilot with Claude Sonnet 4 model.
Addresses issue #1038

Reviewed-by: GomathiselviS <gomathiselvi@gmail.com>
Reviewed-by: Yuriy Novostavskiy <yuriy@novostavskiy.kyiv.ua>
Reviewed-by: Mike Graves <mgraves@redhat.com>
Reviewed-by: Alina Buzachis
Reviewed-by: Bianca Henderson <beeankha@gmail.com>
2026-01-26 18:39:07 +00:00
Yuriy NovostavskiyandGitHub 452fb3d7cb Replace deprecated ansible.module_utils._text imports (#1053)
SUMMARY
Importing from ansible.module_utils._text is deprecated in ansible-core 2.20 and removed in 2.24. All imports of to_bytes, to_native, and to_text now use ansible.module_utils.common.text.converters.
Before:
from ansible.module_utils._text import to_bytes, to_native, to_text

After:
from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
plugins/module_utils/common.py
plugins/action/k8s_info.py
plugins/connection/kubectl.py
plugins/module_utils/{copy.py, k8s/runner.py}
plugins/modules/{k8s_cp.py, k8s_drain.py, k8s_exec.py, k8s_json_patch.py, k8s_scale.py, k8s_taint.py}
ADDITIONAL INFORMATION
It's not an actual Bugfix, more a lifecycle management to ensure compatibility with future Ansible versions.
Tested with ansible-core 2.20 to ensure no deprecation warnings are raised and with ansible-core 2.16 to ensure backward compatibility.
Patrially coauthored-by: GitHub Copilot with Claude Code 4.5 model.
Addresses issue #1052.

Reviewed-by: Bikouo Aubin
Reviewed-by: Alina Buzachis
Reviewed-by: Bianca Henderson <beeankha@gmail.com>
2026-01-24 01:28:15 +00:00
Yuriy NovostavskiyandGitHub 12abc9bda9 Fix K8S_AUTH_VERIFY_SSL environment value handling in kubectl connection plugin (#1049)
SUMMARY
Fixed a bug where setting K8S_AUTH_VERIFY_SSL=true (or any string value) caused the value to be treated as a separate kubectl command argument instead of being properly converted to a boolean.
The option key name is validate_certs, which does NOT end with "verify_ssl", so the original condition key.endswith("verify_ssl") at line 327 failed. This caused the code to fall through to the else block which added the value as separate
arguments: ["--insecure-skip-tls-verify", "true"], making "true" appear as a kubectl command.
Fixes #1021
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
kubernetes.core.kubectl
ADDITIONAL INFORMATION
Changes Made

Changed condition from key.endswith("verify_ssl") to key == "validate_certs"
Added import of boolean function from ansible.module_utils.parsing.convert_bool
Added proper boolean conversion using boolean(self.get_option(key), strict=False)

Partially used LLM (GitHub Copilot with Claude Sonnet 4).
Before Fix
K8S_AUTH_VERIFY_SSL=true
Command: ['/usr/bin/kubectl', '--insecure-skip-tls-verify', 'true', 'exec', ...]

                                                            ^^^^^ treated as kubectl command (BUG!)

After Fix
K8S_AUTH_VERIFY_SSL=true
Command: ['/usr/bin/kubectl', '--insecure-skip-tls-verify=false', 'exec', ...]
                                                           ^^^^^ properly converted (FIXED!)

Reviewed-by: Bikouo Aubin
Reviewed-by: Alina Buzachis
Reviewed-by: Bianca Henderson <beeankha@gmail.com>
2026-01-23 15:30:28 +00:00
Yuriy NovostavskiyandGitHub 987c029c87 chore(CI): prevent patchback bot from labeling new PRs (#1062)
currently, the patchback bot creates PRs that get labeled
as "needs-triage". This change prevents labeling PR created by
the patchback bot.
2026-01-20 17:22:52 -06:00
Yuriy NovostavskiyandGitHub 6c00f7c7de chore(doc): update typos (#1059)
SUMMARY
This trivial documentation-only pull request correcting a few errors in README.md.

Documentation corrections:

Fixed a broken Markdown link for the GitHub repository in the support request section.
Corrected the reference from LICENCE to LICENSE to match the actual file name.



ISSUE TYPE

Docs Pull Request

COMPONENT NAME
README.md
ADDITIONAL INFORMATION
Trivial documentation-only change, no changelog is required.

Reviewed-by: Bianca Henderson <beeankha@gmail.com>
Reviewed-by: Alina Buzachis
2026-01-15 19:07:26 +00:00
Bikouo AubinandGitHub bd1cacc0cf address sanity issues (#1056)
SUMMARY


helm/helm_info - Deprecate some parameters and add new ones to resolve sanity issues.
k8s - the return block doc is not aligned with what the module returns


ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

helm, helm_info, k8s
Fixes: #1046

Reviewed-by: Yuriy Novostavskiy <yuriy@novostavskiy.kyiv.ua>
Reviewed-by: Bianca Henderson <beeankha@gmail.com>
2026-01-14 08:22:31 +00:00
Hannah DeFazioandGitHub 9cfa9038fc Add new workflow to label prs with needs_triage (#1045) 2025-12-18 10:21:05 +01:00
Bianca HendersonandGitHub 1c16a2d2b5 Add 2.21 ignore file for sanity tests (#1032)
SUMMARY

Resolves #1027

Reviewed-by: Yuriy Novostavskiy <yuriy@novostavskiy.kyiv.ua>
Reviewed-by: GomathiselviS <gomathiselvi@gmail.com>
2025-10-23 19:18:13 +00:00
Jan-Philipp LitzaandGitHub 798f5493f9 Extend k8s action group (#992)
SUMMARY


Add all k8s_* modules to the action group in order to esaily set kubeconfig parameter
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

meta
ADDITIONAL INFORMATION

Reviewed-by: Bikouo Aubin
Reviewed-by: Bianca Henderson <beeankha@gmail.com>
2025-10-13 17:57:04 +00:00
Bianca HendersonandGitHub 4fa36487ab Selectively redact sensitive kubeconfig data from logs (#1014)
SUMMARY

Resolves #782

ISSUE TYPE


Bugfix Pull Request

ADDITIONAL INFORMATION


The proper redaction of kubeconfig data can be seen by running this example playbook with verbosity of -vvv against the code in this PR.
Prior to these changes, all info was redacted (as shown in the example below):
ok: [local] => {
    "changed": false,
    "invocation": {
        "module_args": {
            "api_key": null,
            "binary_path": null,
            "ca_cert": null,
            "context": null,
            "get_all_values": false,
            "host": null,
            "kubeconfig": {
                "apiVersion": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "clusters": [
                    {
                        "cluster": {
                            "insecure-skip-tls-verify": true,
                            "server": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
                        },
                        "name": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
                    },
                    {
                        "cluster": {
                            "certificate-authority-data": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                            "server": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
                        },
                        "name": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
                    },
                    {
                        "cluster": {
                            "certificate-authority": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                            "extensions": [
                                {
                                    "extension": {
                                        "last-update": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                                        "provider": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                                        "version": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
                                    },
                                    "name": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
                                }
                            ],
                            "server": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
                        },
                        "name": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
                    }
                ],
                "contexts": [
                    {
                        "context": {
                            "cluster": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                            "user": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
                        },
                        "name": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
                    },
                    {
                        "context": {
                            "cluster": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                            "user": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
                        },
                        "name": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
                    },
[output shortened]

With the changes in this PR, only sensitive data is redacted:
ok: [local] => {
    "changed": false,
    "invocation": {
        "module_args": {
            "api_key": null,
            "binary_path": null,
            "ca_cert": null,
            "context": null,
            "get_all_values": false,
            "host": null,
            "kubeconfig": {
                "apiVersion": "v1",
                "clusters": [
                    {
                        "cluster": {
                            "insecure-skip-tls-verify": true,
                            "server": "<server address>"
                        },
                        "name": "exercise"
                    },
                    {
                        "cluster": {
                            "certificate-authority-data": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                            "server": "<server address>"
                        },
                        "name": "kind-drain-test"
                    },
                    {
                        "cluster": {
                            "certificate-authority": "<path to .crt>",
                            "extensions": [
                                {
                                    "extension": {
                                        "last-update": "Tue, 07 Oct 2025 11:25:54 EDT",
                                        "provider": "minikube.sigs.k8s.io",
                                        "version": "v1.35.0"
                                    },
                                    "name": "cluster_info"
                                }
                            ],
                            "server": "<server address>"
                        },
                        "name": "minikube"
                    }
                ],
                "contexts": [
                    {
                        "context": {
                            "cluster": "exercise-pod",
                            "user": "bianca"
                        },
                        "name": "exercise"
                    },
                    {
                        "context": {
                            "cluster": "kind-drain-test",
                            "user": "kind-drain-test"
                        },
                        "name": "kind-drain-test"
                    },
[output shortened]

Reviewed-by: Bikouo Aubin
Reviewed-by: GomathiselviS <gomathiselvi@gmail.com>
Reviewed-by: Yuriy Novostavskiy <yuriy@novostavskiy.kyiv.ua>
Reviewed-by: Alina Buzachis
2025-10-13 15:01:22 +00:00
Bianca HendersonandGitHub 34467d42b3 Update main after 6.2.0 release (#1016)
Reviewed-by: Bikouo Aubin
Reviewed-by: Bianca Henderson <beeankha@gmail.com>
Reviewed-by: GomathiselviS <gomathiselvi@gmail.com>
Reviewed-by: Alina Buzachis
2025-10-10 15:05:46 +00:00
Pablo FontanillaandGitHub ae624cfa44 775 document proxy configurations (#1018)
SUMMARY
Added documentation for no_proxy, proxy, and proxy_headers parameters that were missing from the k8s lookup plugin. These parameters are already implemented in the codebase but were not documented.
no_proxy: Comma separated list of hosts that shouldn't use proxy
proxy: HTTP proxy URL for connections
proxy_headers: Dictionary of proxy headers with suboptions for proxy_basic_auth, basic_auth, and user_agent
Fixes #775
ISSUE TYPE

Docs Pull Request

COMPONENT NAME
k8s lookup
Additional comment
This is a reissue of #993, which was lost during the latest release due to me PR incorrectly from my fork's main branch. Linter errors on the previous PR should already be resolved.
This had the backport-5, backport-6 and skip-changelog labels.

Reviewed-by: Bianca Henderson <beeankha@gmail.com>
2025-10-10 14:30:12 +00:00
Bianca HendersonandGitHub 05e5e0a5ac prepare release 5.4.1 (#1009) (#1013)
SUMMARY
Update main branch after kubernetes.core 5.4.0 release

Reviewed-by: Mandar Kulkarni <mandar242@gmail.com>
2025-10-07 17:32:21 +00:00
Yuriy NovostavskiyandGitHub 87344b93fc Add support of local environment variables in kustomize lookup plugin (#786)
SUMMARY
kustomize doesn't support an environment that makes it impossible to use HTTP_PROXY or provide some templatized parameters.
This PR is the result of the issue #783
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
kubernetes.core.kustomize lookup plugin

Reviewed-by: Bikouo Aubin
Reviewed-by: Yuriy Novostavskiy <yuriy@novostavskiy.kyiv.ua>
Reviewed-by: Bianca Henderson <beeankha@gmail.com>
2025-10-03 13:44:40 +00:00
Yuriy NovostavskiyandGitHub 200d64f5ea update doc following #971 (#1006)
SUMMARY
In the PR #971, support for copying files to initContainers, and this change includes a minor update for DOCUMENTATION for the k8s_cp module; however, docs/kubernetes.core.k8s_cp_module.rst wasn't updated, and it's a trivial change following the Updating documentation section of the CONTRIBUTING.md
ISSUE TYPE

Docs Pull Request

COMPONENT NAME
docs/kubernetes.core.k8s_cp_module.rst
ADDITIONAL INFORMATION
As it is a trivial change and related to #971, I didn't created a chnagelog fragment and suggest adding skip-changelog label.
To be backported to stable-5 and stable-6

Reviewed-by: Bianca Henderson <beeankha@gmail.com>
2025-10-02 19:14:18 +00:00
ec35c74e2e Add the PR head as reference to the checkout action of the splitter job. (#981)
* Add the pull request its head as reference to the repo-checkout of the splitter job.

* Delete changelogs/fragments/20250808-bugfix-workflow-splitter-ref.yaml

Remove changelog file as this is a CI-only change

---------

Co-authored-by: Bianca Henderson <bianca@redhat.com>
2025-10-01 15:41:34 -04:00
Yorick GruijthuijzenandGitHub 027700c3f4 Added support for copying files to init Containers. (#971)
SUMMARY
Was going trough the list with issues and found 958; which seemed a quick fix.
What I fixed with with this PR:

Added support for copying files to init containers.
Fixed the format message when an exec is failing for a pod (the order was wrong).
Added a check if the container that you try to run copy for is started.

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
copy.py module
ADDITIONAL INFORMATION
Some testing.
Verify that the pod does not exist:
kubectl -n default get pod/yorick
Output:
Error from server (NotFound): pods "yorick" not found

Run the playbook to create the file, create the deployment, wait for the init container to be ready, copy the created file to the init container, cat the copied file (using kubernetes.core.k8s_exec) that is now in the init container and try to copy the created file to the (not started) container (which fails - to see the new error message for it):
cat << EOF | ansible-playbook /dev/stdin
- hosts: localhost
  gather_facts: False
  tasks:

  - ansible.builtin.copy:
      content: |
        Hi there
      dest: /tmp/yorick.txt

  - name: Deploy pod with initContainer with an unlimited while loop
    kubernetes.core.k8s:
      kubeconfig: "~/.kube/config"
      definition:
        apiVersion: v1
        kind: Pod
        metadata:
          name: "yorick"
          namespace: "default"
        spec:
          initContainers:
            - name: "yorick-init"
              image: busybox:latest
              command: ["/bin/sh"]
              args:
                - "-c"
                - |
                  echo "Init container started, waiting for file..."
                  # Wait for the file to be copied
                  while :;do
                    echo "Waiting for file"
                    sleep 5
                  done
                  echo "File received! Init container completing..."
          containers:
            - name: "yorick-container"
              image: busybox:latest
              command: ["/bin/sh"]
              args:
                - "-c"
                - |
                  # Keep container running for testing
                  sleep 300

  - kubernetes.core.k8s_info:
      kubeconfig: "~/.kube/config"
      api_version: v1
      kind: Pod
      name: "yorick"
      namespace: "default"
    register: pod_status
    until: >-
      pod_status.resources|length > 0
      and 'initContainerStatuses' in pod_status.resources.0.status
      and pod_status.resources.0.status.initContainerStatuses|length > 0
      and pod_status.resources.0.status.initContainerStatuses.0.started|bool

  - name: Copy /tmp/yorick.txt to the yorick-init init container
    kubernetes.core.k8s_cp:
      kubeconfig: "~/.kube/config"
      namespace: default
      pod: yorick
      remote_path: /tmp/yorick.txt
      local_path: /tmp/yorick.txt
      container: yorick-init

  - name: Execute a command
    kubernetes.core.k8s_exec:
      kubeconfig: "~/.kube/config"
      namespace: default
      pod: yorick
      container: yorick-init
      command: cat /tmp/yorick.txt
    register: exec_out

  - ansible.builtin.debug:
      var: exec_out.stdout

  - name: Try to copy /tmp/yorick.txt to the yorick-container container
    kubernetes.core.k8s_cp:
      kubeconfig: "~/.kube/config"
      namespace: default
      pod: yorick
      remote_path: /tmp/yorick.txt
      local_path: /tmp/yorick.txt
      container: yorick-container
EOF
Output:
PLAY [localhost] ********************************************************************************************************************************************************************

TASK [ansible.builtin.copy] *********************************************************************************************************************************************************
Thursday 31 July 2025  02:01:21 +0200 (0:00:00.016)       0:00:00.016 *********
ok: [localhost]

TASK [Deploy pod with initContainer with an unlimited while loop] *******************************************************************************************************************
Thursday 31 July 2025  02:01:21 +0200 (0:00:00.788)       0:00:00.804 *********
changed: [localhost]

TASK [kubernetes.core.k8s_info] *****************************************************************************************************************************************************
Thursday 31 July 2025  02:01:25 +0200 (0:00:03.963)       0:00:04.768 *********
FAILED - RETRYING: [localhost]: kubernetes.core.k8s_info (3 retries left).
ok: [localhost]

TASK [Copy /tmp/yorick.txt to the yorick-init init container] ***********************************************************************************************************************
Thursday 31 July 2025  02:01:32 +0200 (0:00:06.598)       0:00:11.366 *********
changed: [localhost]

TASK [Execute a command] ************************************************************************************************************************************************************
Thursday 31 July 2025  02:01:39 +0200 (0:00:07.017)       0:00:18.383 *********
changed: [localhost]

TASK [ansible.builtin.debug] ********************************************************************************************************************************************************
Thursday 31 July 2025  02:01:40 +0200 (0:00:00.644)       0:00:19.028 *********
ok: [localhost] => {
    "exec_out.stdout": "Hi there\n"
}

TASK [Try to copy /tmp/yorick.txt to the yorick-container container] ****************************************************************************************************************
Thursday 31 July 2025  02:01:40 +0200 (0:00:00.021)       0:00:19.050 *********
fatal: [localhost]: FAILED! => {
    "changed": false
}

MSG:

Pod container yorick-container is not started

PLAY RECAP **************************************************************************************************************************************************************************
localhost                  : ok=6    changed=3    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

Playbook run took 0 days, 0 hours, 0 minutes, 21 seconds

Reviewed-by: spatterlight
Reviewed-by: Yorick Gruijthuijzen <yorick-1989@hotmail.com>
Reviewed-by: Bianca Henderson <beeankha@gmail.com>
Reviewed-by: Bikouo Aubin
2025-09-24 20:36:56 +00:00
Yuriy NovostavskiyandGitHub da93cce1fa Add support for skip-schema-validation in helm module (#995)
SUMMARY
This pull request adds support for a new skip_schema_validation option to the helm module, allowing users to disable JSON schema validation for Helm charts and values (requires helm >= 3.16.0).
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
helm
ADDITIONAL INFORMATION
Added the skip_schema_validation boolean parameter to the helm module, allowing users to disable JSON schema validation for charts and values. This option is only available with Helm versions >= 3.16.0, and an appropriate error is raised for older versions.
Added integration tests to verify the behavior of the skip_schema_validation option, including cases for both supported and unsupported Helm versions.
Closes #994

Reviewed-by: Bikouo Aubin
2025-09-24 15:47:46 +00:00
Bianca HendersonandGitHub 448d3fe156 [CI Fix] Remove ansible.module_utils.six imports (#998)
SUMMARY
This PR is essentially attempting Option B from issue #996 (Option A is implemented here); this code update accounts for the recent merge of sanity: warn on ansible.module_utils.six imports #85651.

Reviewed-by: Alina Buzachis
Reviewed-by: Yuriy Novostavskiy <yuriy@novostavskiy.kyiv.ua>
2025-09-22 16:08:18 +00:00
Alina BuzachisandGitHub 6158300062 Changelog fixes (#989)
SUMMARY

Changelog fixes

ISSUE TYPE


Docs Pull Request

Reviewed-by: Bianca Henderson <beeankha@gmail.com>
2025-08-14 13:50:55 +00:00
Alina BuzachisandGitHub 3160e4aad6 Update main branch docs after release 6.1.0 (#988)
SUMMARY

Update main branch docs after release 6.1.0

ISSUE TYPE


Docs Pull Request

Reviewed-by: Bikouo Aubin
Reviewed-by: Bianca Henderson <beeankha@gmail.com>
Reviewed-by: Alina Buzachis
2025-08-13 15:47:37 +00:00
Bianca HendersonandGitHub 93734fcefc Prep kubernetes.core 5.4.0 release (#970) (#986)
SUMMARY
Update main branch after kubernetes.core 5.4.0 release

Reviewed-by: Bianca Henderson <beeankha@gmail.com>
Reviewed-by: Yuriy Novostavskiy
Reviewed-by: Bikouo Aubin
Reviewed-by: Alina Buzachis
2025-08-13 08:36:33 +00:00
a861079dc1 CI fix for 976 (#982)
* exclude plugins/connection/kubectl.py from ansible-lint

documentation inside a python file have simplification

resolves #976

* Update to use .ansible-lint and ansible-lint@v25.5.0

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

* Update .github/workflows/linters.yaml

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>

---------

Signed-off-by: Alina Buzachis <abuzachis@redhat.com>
Co-authored-by: Alina Buzachis <abuzachis@redhat.com>
2025-08-12 17:30:11 +02:00
Bianca HendersonandGitHub 5148ee5f74 Reapply "Remove kubeconfig value from module invocation log (#826)" (#899) (#978)
This reverts commit 1705ced (i.e., reapplies the changes from #826); this is a temporary fix for #782 as it will re-introduce #870, which will need to be re-opened.

Reviewed-by: Alina Buzachis
Reviewed-by: GomathiselviS <gomathiselvi@gmail.com>
2025-08-11 16:46:40 +00:00
Frank Villaro-DixonandGitHub c48778d709 k8s_json_patch: support the hidden_fields param (#964)
SUMMARY
Add support for hidden_fields on k8s_json_patch

ISSUE TYPE

Feature Pull Request

COMPONENT NAME
k8s_json_patch
ADDITIONAL INFORMATION
Works exactly the same as k8s
Haven't pushed the doc yet, because of many changes. Will do it on a separate commit if the tests pass.
1st commit here, sorry if I forget some things.
Thanks!

Reviewed-by: Bianca Henderson <beeankha@gmail.com>
Reviewed-by: Alina Buzachis
Reviewed-by: Frank Villaro-Dixon <frank@villaro-dixon.eu>
2025-07-31 14:21:40 +00:00
Rémy JacquinandGitHub cf3c3a9dcc Add support for take-ownership Helm flag (#957)
SUMMARY
Add support for take-ownership Helm flag added in Helm 3.17.0
ISSUE TYPE

Feature Pull Request

COMPONENT NAME

kubernetes.core.helm

Reviewed-by: Yuriy Novostavskiy
Reviewed-by: Rémy Jacquin
Reviewed-by: Bikouo Aubin
Reviewed-by: Bianca Henderson <beeankha@gmail.com>
2025-07-28 15:18:46 +00:00
James MighionandGitHub 1705ced1b5 Revert "Remove kubeconfig value from module invocation log (#826)" (#899)
This reverts commit 6efabd3.
SUMMARY

Fixes #870
A better solution is necessary to address #782. The current code makes getting manifests practically unusable. We need to revert this commit until a better solution is found.

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

kubeconfig

Reviewed-by: Bianca Henderson <beeankha@gmail.com>
2025-07-22 16:49:34 +00:00
Felix MatouschekandGitHub 6a0635a2bb fix(k8s,service): Hide fields first before creating diffs (#915)
SUMMARY

By hiding fields first before creating a diff hidden fields will not be shown in the resulting diffs and therefore will also not trigger the changed condition.
The issue can only be reproduced when a mutating webhook changes the object while the kubernetes.core.k8s module is working with it.

kubevirt/kubevirt.core#145
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

kubernetes.core.module_utils.k8s.service
ADDITIONAL INFORMATION


Run kubernetes.core.k8s and create object with hidden fields. After run kubernetes.core.k8s again and let a webhook mutate the object that the module is working with. The module should return with changed: no.

Reviewed-by: Bikouo Aubin
Reviewed-by: Mike Graves <mgraves@redhat.com>
2025-07-15 16:10:26 +00:00
Yuriy NovostavskiyandGitHub f568c9da62 Fix integration test with ansibe-core 2.20 (#951)
SUMMARY
Now that ansible-core 2.19.0rc1 has been released, ansible-core’s devel branch has been bumped from 2.19.0.dev0 to 2.20.0.dev0. This potentially requires collection CIs to be updated which rely on devel using tests/sanity/ignore-2.19.txt, for example. Also it’s now time to add stable-2.19 to CI if you relied on devel to cover 2.19 so far. Note that milestone has also been updated to 2.20.0dev0.
During testing, I noticed that the failed test tasks/test_helm_not_installed.yml due to the new error message with ansible 2.20, please find here and following comments.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
test/CI (tasks/test_helm_not_installed.yml)
ADDITIONAL INFORMATION
to be cherry-picked to the stable-6 and stable-5

Reviewed-by: Bianca Henderson <beeankha@gmail.com>
Reviewed-by: Alina Buzachis
2025-07-15 13:53:51 +00:00
Bianca HendersonandGitHub 94e42354cd Add more functionality coverage to k8s_rollback integration test (#950)
SUMMARY

Resolves #344

This revision adds the following test coverage:

Label Selectors: Tests rollback using label selectors to target specific deployments.
No Rollout History: Tests the warning scenario when attempting to rollback a deployment with only one revision.
Unsupported Resource Types: Tests error handling when trying to rollback unsupported resources like Services.
Non-existent Resources: Tests behavior when attempting to rollback resources that don't exist.
Multiple Resource Rollback: Tests bulk rollback operations using label selectors on multiple deployments.
Return Value Validation: Comprehensive validation of the rollback_info structure and content.
Field Selectors: Tests rollback using field selectors to target specific resources.
Check Mode Validation: Additional validation of check mode behavior and return values.

COMPONENT NAME

tests/integration/targets/k8s_rollback/tasks/main.yml

Reviewed-by: Alina Buzachis
Reviewed-by: Bikouo Aubin
Reviewed-by: Bianca Henderson <beeankha@gmail.com>
2025-07-08 15:28:41 +00:00
Yuriy NovostavskiyandGitHub 642eb936c0 Fix the integration test for helm_registry_auth with helm >= 3.18.0 and clarify idempotency. (#946)
SUMMARY
Fix the integration test for helm_registry_auth with helm >= 3.18.0 and clarify idempotency.
Fixes #944
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
helm_registry_auth
ADDITIONAL INFORMATION
Caused by the changes in helm starting from 3.18.0

Reviewed-by: Bianca Henderson <beeankha@gmail.com>
Reviewed-by: Alina Buzachis
Reviewed-by: Yuriy Novostavskiy
Reviewed-by: Bikouo Aubin
2025-07-08 09:50:08 +00:00
Matteo DanelonandGitHub 775959c3f9 Add plain_http parameter to helm, helm_pull and helm_template (#934)
SUMMARY

This change introduces the plain_http parameter to modules that can interact with OCI registries. This in needed in cases where the OCI registry does not use SSL encryption, forcing Helm to send HTTP requests instead of HTTPS

ISSUE TYPE


Feature Pull Request

COMPONENT NAME

helm, helm_pull and helm_template
ADDITIONAL INFORMATION


This is the output when trying to use an OCI registry that is not configured to use SSL certs.

fatal: [localhost]: FAILED! => {"changed": false, "command": "/usr/local/bin/helm show chart 'oci://<http-registry>/charts/foo'", "msg": "Failure when executing Helm command. Exited 1.\nstdout: \nstderr: Error: Get \"https://<http-registry>/v2/charts/foo/tags/list\": http: server gave HTTP response to HTTPS client\n", "stderr": "Error: Get \"https://<http-registry>/v2/charts/foo/tags/list\": http: server gave HTTP response to HTTPS client\n", "stderr_lines": ["Error: Get \"https://<http-registry>/v2/charts/foo/tags/list\": http: server gave HTTP response to HTTPS client"], "stdout": "", "stdout_lines": []}

Reviewed-by: Bikouo Aubin
Reviewed-by: Matteo Danelon
2025-06-12 10:39:40 +00:00
Chyna SandersandGitHub 77627bb8d9 Copied automation script for tagging new issues from the main AWS collection (#936) 2025-06-10 13:33:52 -04:00
Bianca HendersonandGitHub b1fbd38352 Prep release 6.0.0 (#933) (#945)
Updating main branch after 6.0.0 release.

Reviewed-by: Bikouo Aubin
Reviewed-by: Yuriy Novostavskiy
2025-06-05 14:44:46 +00:00
Bianca HendersonandGitHub a06b2c3969 Update dev version after 6.0.0 major release (#941)
SUMMARY
Updating the dev version listed in Makefile and galaxy.yml since 6.0.0 has been released.

Reviewed-by: Mandar Kulkarni <mandar242@gmail.com>
2025-06-04 20:01:59 +00:00
Bikouo AubinandGitHub 34fd40d46a Fix unit tests (#939)
Some unit tests are broken with ansible-core 2.19, this PR aims to fix them.

Reviewed-by: Bianca Henderson <beeankha@gmail.com>
2025-06-03 14:26:26 +00:00
132 changed files with 1492 additions and 1049 deletions
+3
View File
@@ -1,6 +1,9 @@
---
profile: production
warn_list:
- no-log-password
exclude_paths:
- .ansible/
- .github/
-4
View File
@@ -1,8 +1,4 @@
# https://docs.ansible.com/ansible-lint/docs/rules/
# no-changed-when is not requried for examples
plugins/connection/kubectl.py no-changed-when
# false positive result
plugins/connection/kubectl.py var-naming[no-reserved]
plugins/connection/kubectl.py jinja[invalid]
# collection EE metadata is not an ansible-builder definition file
meta/execution-environment.yml schema[execution-environment]
+3 -27
View File
@@ -81,8 +81,6 @@ jobs:
steps:
- run: |
python -c "
import sys
required = ['sanity', 'units', 'coverage']
if '${{ github.event_name }}' == 'pull_request':
required = ['security-check', 'linters', 'sanity', 'units', 'coverage']
@@ -93,29 +91,7 @@ jobs:
'units': '${{ needs.units.result }}',
'coverage': '${{ needs.coverage.result }}',
}
for name in required:
if results[name] == 'failure':
print(f'all_green: required job failed: {name} results={results}', file=sys.stderr)
sys.exit(1)
# cancel-in-progress superseded this run; do not fail (newer run is authoritative)
if any(v == 'cancelled' for v in results.values()):
print(
'all_green: one or more jobs cancelled (usually concurrency); skipping strict gate.',
results,
)
sys.exit(0)
not_ok = [j for j in required if results[j] != 'success']
if not_ok:
print(f'all_green: required jobs not success: {not_ok} results={results}', file=sys.stderr)
sys.exit(1)
for job, status in results.items():
if job not in required and status not in ('success', 'skipped'):
print(f'all_green: unexpected {job}={status} results={results}', file=sys.stderr)
sys.exit(1)
print('all_green OK', results)
ok = all(results[j] == 'success' for j in required)
skipped_ok = all(results[j] in ('success', 'skipped') for j in results)
assert ok and skipped_ok, f'required={required} results={results}'
"
@@ -0,0 +1,210 @@
name: Integration tests Helm
concurrency:
group: integration-tests-helm-${{ github.head_ref }}
cancel-in-progress: true
on:
pull_request:
types:
- opened
- reopened
- labeled
- unlabeled
- synchronize
branches:
- main
- stable-*
permissions: {}
jobs:
splitter:
env:
source_dir: "./source"
runs-on: ubuntu-latest
outputs:
helm_targets: ${{ steps.select-targets.outputs.targets }}
permissions:
pull-requests: read
contents: read
steps:
- name: Checkout the collection repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: ${{ env.source_dir }}
fetch-depth: "0"
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false
- name: list changes for pull request
id: splitter
uses: ansible-network/github_actions/.github/actions/ansible_test_splitter@4678c74a7d712d55e663c88f66eec6d9c3642550
with:
collections_to_test: ${{ env.source_dir }}
total_jobs: 8
- name: Select Helm targets
id: select-targets
run: |
import os, json
with open(os.environ.get('GITHUB_OUTPUT'), "a", encoding="utf-8") as fh:
data = os.environ.get("ALL_TEST_TARGETS")
targets = []
for target in data.split(";"):
if target and ':' in target:
targets.extend([v for v in target.split(':', maxsplit=1)[1].split(',') if v.startswith('helm')])
fh.write(f'targets={json.dumps(targets)}\n')
shell: python
env:
ALL_TEST_TARGETS: ${{ steps.splitter.outputs.test_targets }}
integration:
runs-on: ubuntu-latest
timeout-minutes: 60
needs:
- splitter
if: ${{ needs.splitter.outputs.helm_targets != '' && needs.splitter.outputs.helm_targets != '[]' }}
env:
source: "./source"
ansible_posix: "./ansible_posix"
community_general: "./community_general"
ansible-version: "milestone"
python-version: "3.13"
permissions:
contents: read
strategy:
fail-fast: false
matrix:
helm-version:
- v3.0.0
- v3.1.0
- v3.8.0
- v3.10.3
- v3.15.4
- v3.16.0
- v3.17.0
- v3.22.0
- v4.0.0
- v4.2.1
- latest
ansible_test_target: ${{ fromJson(needs.splitter.outputs.helm_targets) }}
exclude:
# helm_registry_auth: only test against recent versions to reduce CI cost
- ansible_test_target: "helm_registry_auth"
helm-version: "v3.0.0"
- ansible_test_target: "helm_registry_auth"
helm-version: "v3.1.0"
- ansible_test_target: "helm_registry_auth"
helm-version: "v3.8.0"
- ansible_test_target: "helm_registry_auth"
helm-version: "v3.10.3"
- ansible_test_target: "helm_registry_auth"
helm-version: "v3.15.4"
- ansible_test_target: "helm_registry_auth"
helm-version: "v3.16.0"
# helm install/upgrade --create-namespace requires helm >= 3.2.0
- ansible_test_target: "helm_diff"
helm-version: "v3.0.0"
- ansible_test_target: "helm_diff"
helm-version: "v3.1.0"
- ansible_test_target: "helm_diff"
helm-version: "v3.8.0"
- ansible_test_target: "helm_diff"
helm-version: "v3.10.3"
# UPGRADE FAILED: conflict occurred while applying object helm-diff/test-chart-another-configmap /v1
- ansible_test_target: "helm_diff"
helm-version: "v4.0.0"
- ansible_test_target: "helm_repository"
helm-version: "v3.0.0"
- ansible_test_target: "helm_repository"
helm-version: "v3.1.0"
- ansible_test_target: "helm_kubeconfig"
helm-version: "v3.0.0"
- ansible_test_target: "helm_kubeconfig"
helm-version: "v3.1.0"
- ansible_test_target: "helm_set_values"
helm-version: "v3.0.0"
- ansible_test_target: "helm_set_values"
helm-version: "v3.1.0"
- ansible_test_target: "helm_set_values"
helm-version: "v3.8.0"
- ansible_test_target: "helm"
helm-version: "v3.0.0"
- ansible_test_target: "helm"
helm-version: "v3.1.0"
- ansible_test_target: "helm_uninstall"
helm-version: "v3.0.0"
- ansible_test_target: "helm_uninstall"
helm-version: "v3.1.0"
name: "${{ matrix.ansible_test_target }}-${{ matrix.helm-version }}"
steps:
- name: Checkout kubernetes.core repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: ${{ env.source }}
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false
- name: Set up Python ${{ env.python-version }}
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: ${{ env.python-version }}
# install ansible
- name: Install ansible-core (${{ env.ansible-version }})
env:
ANSIBLE_VERSION: ${{ env.ansible-version }}
run: |
curl -sSL --proto '=https' --tlsv1.2 --retry 5 --retry-delay 10 --retry-all-errors \
"https://github.com/ansible/ansible/archive/${ANSIBLE_VERSION}.tar.gz" \
-o ansible.tar.gz
python3 -m pip install --disable-pip-version-check ./ansible.tar.gz
rm ansible.tar.gz
shell: bash
- name: Build and install collection
id: install-src
uses: ansible-network/github_actions/.github/actions/build_install_collection@4678c74a7d712d55e663c88f66eec6d9c3642550
with:
install_python_dependencies: true
source_path: ${{ env.source }}
- name: create kubernetes cluster
uses: helm/kind-action@ef37e7f390d99f746eb8b610417061a60e82a6cc # v1.14.0
with:
node_image: "kindest/node:v1.29.2"
- name: "Install Helm version ${{ matrix.helm-version }}"
uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1
with:
version: '${{ matrix.helm-version }}'
- name: Verify Helm Installation
run: helm version
- name: Disable selinux with selinux_please_lie_to_me
run: |
python3 -m pip uninstall -y selinux
python3 -m pip install --only-binary=:all: selinux_please_lie_to_me==1.0.1
shell: bash
- name: Install python requirements
run: python3 -m pip install -r requirements.txt -r test-requirements.txt
shell: bash
working-directory: ${{ steps.install-src.outputs.collection_path }}
- name: Run integration tests
run: >-
ansible-test integration
--diff
--no-temp-workdir
--color
--skip-tags False
--retry-on-error
--continue-on-error
--python ${{ env.python-version }}
-v
${{ matrix.ansible_test_target }}
shell: bash
working-directory: ${{ steps.install-src.outputs.collection_path }}
+33 -10
View File
@@ -17,9 +17,8 @@ jobs:
source_dir: "./source"
runs-on: ubuntu-latest
outputs:
test_targets: ${{ steps.splitter.outputs.test_targets }}
test_targets_json: ${{ steps.splitter.outputs.test_targets_json }}
test_jobs: ${{ steps.splitter.outputs.test_jobs }}
test_targets: ${{ steps.select-targets.outputs.targets }}
test_jobs: ${{ steps.select-targets.outputs.jobs }}
steps:
- name: Checkout the collection repository
uses: actions/checkout@v3
@@ -35,18 +34,40 @@ jobs:
collections_to_test: ${{ env.source_dir }}
total_jobs: 8
- name: Display splitter output
- name: Remove all Helm related targets
id: select-targets
run: |
echo "test_targets=${{ steps.splitter.outputs.test_targets }}"
echo "test_targets_json=${{ steps.splitter.outputs.test_targets_json }}"
echo "test_jobs=${{ steps.splitter.outputs.test_jobs }}"
import os, json
with open(os.environ.get('GITHUB_OUTPUT'), "a", encoding="utf-8") as fh:
data = os.environ.get("ALL_TEST_TARGETS")
index = 0
result = {}
for target in data.split(";"):
if target and ':' in target:
k8s = [v for v in target.split(':', maxsplit=1)[1].split(',') if not v.startswith('helm')]
if k8s:
result[index] = ' '.join(k8s)
index += 1
fh.write(f'targets={json.dumps(result)}\n')
fh.write(f'jobs={json.dumps(list(result.keys()))}\n')
shell: python
env:
ALL_TEST_TARGETS: ${{ steps.splitter.outputs.test_targets }}
- name: Display splitter output
env:
TARGETS: ${{ steps.select-targets.outputs.targets }}
JOBS: ${{ steps.select-targets.outputs.jobs }}
run: |
echo "targets => $TARGETS"
echo "jobs => $JOBS"
shell: bash
integration:
runs-on: ubuntu-latest
timeout-minutes: 60
needs:
- splitter
if: ${{ needs.splitter.outputs.test_targets != '' }}
if: ${{ needs.splitter.outputs.test_jobs != '' && needs.splitter.outputs.test_jobs != '[]' }}
env:
source: "./source"
cloud_common: "./cloudcommon"
@@ -87,12 +108,14 @@ jobs:
fh.write(f'ansible_test_targets={json.loads(os.environ.get("ALL_TEST_TARGETS")).get(os.environ.get("WORKFLOW_ID"))}\n')
shell: python
env:
ALL_TEST_TARGETS: ${{ needs.splitter.outputs.test_targets_json }}
ALL_TEST_TARGETS: ${{ needs.splitter.outputs.test_targets }}
WORKFLOW_ID: ${{ matrix.workflow-id }}
- name: Display ansible test targets
env:
ANSIBLE_TEST_TARGETS: ${{ steps.read-targets.outputs.ansible_test_targets }}
run: |
echo "ansible_test_targets -> ${{ steps.read-targets.outputs.ansible_test_targets }}"
echo "ansible_test_targets -> $ANSIBLE_TEST_TARGETS"
- name: Checkout kubernetes.core repository
uses: actions/checkout@v3
+18
View File
@@ -0,0 +1,18 @@
---
name: label new issues
on:
issues:
types:
- opened
- reopened
jobs:
add_label:
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
steps:
- uses: actions-ecosystem/action-add-labels@v1
with:
labels: needs_triage
+2 -1
View File
@@ -16,12 +16,13 @@ tests/integration/cloud-config-*
.ansible
# Helm charts
tests/integration/*-chart-*.tgz
tests/integration/*.tgz
tests/integration/targets/*/*.tgz
# ansible-test generated file
tests/integration/inventory
tests/integration/*-*.yml
tests/integration/integration_config.yml
# IDE and editor settings
.vscode/
+1 -1
View File
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/ansible/cloud-content-ci-automation
rev: precommit_hook
rev: 77f45b0357b6b3c27b04e934f0f51c9b50b7aa25
hooks:
- id: block-ide-ai-files
always_run: true
+103 -3
View File
@@ -184,12 +184,112 @@ Bugfixes
v6.0.0
======
Release Summary
---------------
This major release removes the deprecated ``k8s`` inventory plugin and also removes ``ansible-core<2.16`` support.
Breaking Changes / Porting Guide
--------------------------------
- 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).
v5.5.0
======
Release Summary
---------------
This minor release deprecates Ansible Turbo mode (``ENABLE_TURBO_MODE``), the ``status.values`` return value of the ``helm`` and ``helm_info`` modules, the ``wait_timeout`` parameter of the ``helm`` module, the ``return_code`` return value of the ``k8s_exec`` module, and the ``merge_type=json`` option of the ``k8s_service`` module. It also includes bugfixes for ``helm_repository`` URL comparison and for empty template output handling in ``k8s_info``.
Minor Changes
-------------
- Remove the remaining ``ansible.module_utils.six`` import to avoid deprecation warnings, replacing it with the Python standard library equivalent (https://github.com/ansible-collections/kubernetes.core/pull/1197).
- k8s lookup - warn when ``ENABLE_TURBO_MODE`` is set but the ``cloud.common`` collection is not installed, instead of silently falling back to the standard lookup base (https://github.com/ansible-collections/kubernetes.core/pull/1242).
Deprecated Features
-------------------
- Ansible Turbo mode (``ENABLE_TURBO_MODE``) has been deprecated and will be removed in release 8.0.0, as it depends on the ``cloud.common`` collection, which is being retired (https://github.com/ansible-collections/kubernetes.core/pull/1242).
- helm - the ``status.values`` return value has been deprecated and will be removed in version 8.0.0. Use ``status.release_values`` instead (https://github.com/ansible-collections/kubernetes.core/issues/1239).
- helm - the ``wait_timeout`` parameter has been deprecated and will be removed in version 7.0.0. Use ``timeout`` instead (https://github.com/ansible-collections/kubernetes.core/issues/1239).
- helm_info - the ``status.values`` return value has been deprecated and will be removed in version 8.0.0. Use ``status.release_values`` instead (https://github.com/ansible-collections/kubernetes.core/issues/1239).
- k8s_exec - the ``return_code`` return value has been deprecated and will be removed in version 7.0.0. Use ``rc`` instead (https://github.com/ansible-collections/kubernetes.core/issues/1239).
- k8s_service - the ``merge_type=json`` option has been deprecated and will be removed in version 7.0.0. Use ``kubernetes.core.k8s_json_patch`` module instead (https://github.com/ansible-collections/kubernetes.core/issues/1239).
Bugfixes
--------
- Ansible Turbo mode - ignore ``ENABLE_TURBO_MODE`` on ansible-core 2.19.0 and later, where the ``cloud.common`` collection is not supported, and fall back to the standard ``AnsibleModule`` instead of failing with ``byte indices must be integers or slices, not str`` (https://github.com/ansible-collections/kubernetes.core/pull/1242).
- helm_repository - normalize both sides of the repository URL comparison, so that a repository already registered with a trailing slash is recognized as matching instead of failing with ``Repository already have a repository named <name>`` (https://github.com/ansible-collections/kubernetes.core/pull/1236).
- k8s lookup - ignore ``ENABLE_TURBO_MODE`` on ansible-core 2.19.0 and later, where the ``cloud.common`` collection is not supported. Fall back to the standard ``LookupBase`` instead of failing with a traceback (https://github.com/ansible-collections/kubernetes.core/pull/1253).
- k8s_info - Handle empty template output gracefully by returning ``changed=false`` instead of failing when Jinja2 template renders to an empty string (https://github.com/ansible-collections/kubernetes.core/issues/1042).
v5.4.4
======
Release Summary
---------------
This release corrects the documented and enforced minimum ``ansible-core`` version to ``>=2.16.0``.
Bugfixes
--------
- meta - Update ``requires_ansible`` in ``runtime.yml`` and README to ``>=2.16.0`` to match the actual minimum supported ``ansible-core`` version (https://github.com/ansible-collections/kubernetes.core/pull/1193).
v5.4.3
======
Release Summary
---------------
This release contains bugfixes such as improved idempotency for helm repository URLs with trailing slashes.
Bugfixes
--------
- ee - Add ``meta/execution-environment.yml`` to decouple ansible-builder EE builds from the ``openshift-clients`` system dependency declared in ``bindep.txt``, which is not available in standard UBI repositories and caused builds to fail with ``No package matches 'openshift-clients'`` (https://github.com/ansible-collections/kubernetes.core/issues/1141).
- helm_repository - Correct handling of repository URLs with trailing slashes (https://github.com/ansible-collections/kubernetes.core/pull/1121).
- k8s_drain - Fix logic for handling pods with local storage to correctly check for empty_dir volumes in replicated pods and pods managed by DaemonSets (https://github.com/ansible-collections/kubernetes.core/pull/1095).
v5.4.2
======
Release Summary
---------------
This release includes bugfixes such as replacing the passing of ``warnings`` to ``exit_json`` with ``AnsibleModule.warn`` as well as a security update for selectively redacting sensitive information from kubeconfig, and adds a new ``release_values`` key to the ``status`` return value.
Minor Changes
-------------
- helm - Add ``release_values`` key to ``status`` return value that can be accessed using Jinja2 dot notation (https://github.com/ansible-collections/kubernetes.core/pull/1056).
- helm_info - Add ``release_values`` key to ``status`` return value that can be accessed using Jinja2 dot notation (https://github.com/ansible-collections/kubernetes.core/pull/1056).
Deprecated Features
-------------------
- helm - the ``status.values`` return value has been deprecated and will be removed in a release after 2027-01-08. Use ``status.release_values`` instead (https://github.com/ansible-collections/kubernetes.core/pull/1056).
- helm_info - the ``status.values`` return value has been deprecated and will be removed in a release after 2027-01-08. Use ``status.release_values`` instead (https://github.com/ansible-collections/kubernetes.core/pull/1056).
Security Fixes
--------------
- Selectively redact sensitive info from kubeconfig instead of applying blanket ``no_log=True`` (https://github.com/ansible-collections/kubernetes.core/pull/1014).
Bugfixes
--------
- Add idempotency for ``helm_pull`` module (https://github.com/ansible-collections/kubernetes.core/pull/1055).
- Fixed a bug where setting ``K8S_AUTH_VERIFY_SSL=true`` (or any string value) caused the value to be treated as a separate ``kubectl`` command argument (https://github.com/ansible-collections/kubernetes.core/pull/1049).
- Limit supported versions of Helm to <4.0.0 (https://github.com/ansible-collections/kubernetes.core/pull/1039).
- Replace passing ``warnings`` to ``exit_json`` with ``AnsibleModule.warn`` in the ``k8s_drain``, ``k8s_rollback.py`` and ``k8s_scale.py`` modules as it deprecated in ``ansible-core>=2.19.0`` and will be removed in ``ansible-core>=2.23.0`` (https://github.com/ansible-collections/kubernetes.core/pull/1033).
- k8s - Fix return block from the module documentation (https://github.com/ansible-collections/kubernetes.core/pull/1056).
- meta - Add ``k8s_cluster_info``, ``k8s_json_patch`` and ``k8s_rollback`` to k8s action group (https://github.com/ansible-collections/kubernetes.core/pull/992).
v5.4.1
======
@@ -229,15 +329,15 @@ This release includes minor changes, bug fixes and also bumps ``ansible-lint`` v
Minor Changes
-------------
- 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).
- 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).
- kubernetes.core - Bump version of ``ansible-lint`` to ``25.1.2`` (https://github.com/ansible-collections/kubernetes.core/pull/919).
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
======
+1 -1
View File
@@ -1,5 +1,5 @@
# Also needs to be updated in galaxy.yml
VERSION = 6.6.0
VERSION = 7.0.0-dev0
TEST_ARGS ?= ""
PYTHON_VERSION ?= `python -c 'import platform; print(".".join(platform.python_version_tuple()[0:2]))'`
+41 -33
View File
@@ -22,7 +22,7 @@ Click on the name of a plugin or module to view that content's documentation:
### Connection plugins
Name | Description
--- | ---
[kubernetes.core.kubectl](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/docs/kubernetes.core.kubectl_connection.rst)|Execute tasks in pods running on Kubernetes.
[kubernetes.core.kubectl](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.kubectl_connection.rst)|Execute tasks in pods running on Kubernetes.
### K8s filter plugins
Name | Description
@@ -32,33 +32,33 @@ kubernetes.core.k8s_config_resource_name|Generate resource name for the given re
### Lookup plugins
Name | Description
--- | ---
[kubernetes.core.k8s](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/docs/kubernetes.core.k8s_lookup.rst)|Query the K8s API
[kubernetes.core.kustomize](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/docs/kubernetes.core.kustomize_lookup.rst)|Build a set of kubernetes resources using a 'kustomization.yaml' file.
[kubernetes.core.k8s](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_lookup.rst)|Query the K8s API
[kubernetes.core.kustomize](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.kustomize_lookup.rst)|Build a set of kubernetes resources using a 'kustomization.yaml' file.
### Modules
Name | Description
--- | ---
[kubernetes.core.helm](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/docs/kubernetes.core.helm_module.rst)|Manages Kubernetes packages with the Helm package manager
[kubernetes.core.helm_info](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/docs/kubernetes.core.helm_info_module.rst)|Get information from Helm package deployed inside the cluster
[kubernetes.core.helm_plugin](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/docs/kubernetes.core.helm_plugin_module.rst)|Manage Helm plugins
[kubernetes.core.helm_plugin_info](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/docs/kubernetes.core.helm_plugin_info_module.rst)|Gather information about Helm plugins
[kubernetes.core.helm_pull](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/docs/kubernetes.core.helm_pull_module.rst)|download a chart from a repository and (optionally) unpack it in local directory.
[kubernetes.core.helm_registry_auth](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/docs/kubernetes.core.helm_registry_auth_module.rst)|Helm registry authentication module
[kubernetes.core.helm_repository](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/docs/kubernetes.core.helm_repository_module.rst)|Manage Helm repositories.
[kubernetes.core.helm_template](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/docs/kubernetes.core.helm_template_module.rst)|Render chart templates
[kubernetes.core.k8s](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/docs/kubernetes.core.k8s_module.rst)|Manage Kubernetes (K8s) objects
[kubernetes.core.k8s_cluster_info](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/docs/kubernetes.core.k8s_cluster_info_module.rst)|Describe Kubernetes (K8s) cluster, APIs available and their respective versions
[kubernetes.core.k8s_cp](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/docs/kubernetes.core.k8s_cp_module.rst)|Copy files and directories to and from pod.
[kubernetes.core.k8s_drain](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/docs/kubernetes.core.k8s_drain_module.rst)|Drain, Cordon, or Uncordon node in k8s cluster
[kubernetes.core.k8s_exec](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/docs/kubernetes.core.k8s_exec_module.rst)|Execute command in Pod
[kubernetes.core.k8s_info](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/docs/kubernetes.core.k8s_info_module.rst)|Describe Kubernetes (K8s) objects
[kubernetes.core.k8s_json_patch](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/docs/kubernetes.core.k8s_json_patch_module.rst)|Apply JSON patch operations to existing objects
[kubernetes.core.k8s_log](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/docs/kubernetes.core.k8s_log_module.rst)|Fetch logs from Kubernetes resources
[kubernetes.core.k8s_rollback](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/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/stable-6/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/stable-6/docs/kubernetes.core.k8s_service_module.rst)|Manage Services on Kubernetes
[kubernetes.core.k8s_taint](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/docs/kubernetes.core.k8s_taint_module.rst)|Taint a node in a Kubernetes/OpenShift cluster
[kubernetes.core.kubeconfig](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/docs/kubernetes.core.kubeconfig_module.rst)|Generate, update, and optionally write Kubernetes kubeconfig files
[kubernetes.core.helm](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.helm_module.rst)|Manages Kubernetes packages with the Helm package manager
[kubernetes.core.helm_info](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.helm_info_module.rst)|Get information from Helm package deployed inside the cluster
[kubernetes.core.helm_plugin](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.helm_plugin_module.rst)|Manage Helm plugins
[kubernetes.core.helm_plugin_info](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.helm_plugin_info_module.rst)|Gather information about Helm plugins
[kubernetes.core.helm_pull](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.helm_pull_module.rst)|download a chart from a repository and (optionally) unpack it in local directory.
[kubernetes.core.helm_registry_auth](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.helm_registry_auth_module.rst)|Helm registry authentication module
[kubernetes.core.helm_repository](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.helm_repository_module.rst)|Manage Helm repositories.
[kubernetes.core.helm_template](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.helm_template_module.rst)|Render chart templates
[kubernetes.core.k8s](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_module.rst)|Manage Kubernetes (K8s) objects
[kubernetes.core.k8s_cluster_info](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_cluster_info_module.rst)|Describe Kubernetes (K8s) cluster, APIs available and their respective versions
[kubernetes.core.k8s_cp](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_cp_module.rst)|Copy files and directories to and from pod.
[kubernetes.core.k8s_drain](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_drain_module.rst)|Drain, Cordon, or Uncordon node in k8s cluster
[kubernetes.core.k8s_exec](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_exec_module.rst)|Execute command in Pod
[kubernetes.core.k8s_info](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_info_module.rst)|Describe Kubernetes (K8s) objects
[kubernetes.core.k8s_json_patch](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_json_patch_module.rst)|Apply JSON patch operations to existing objects
[kubernetes.core.k8s_log](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_log_module.rst)|Fetch logs from Kubernetes resources
[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_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
[kubernetes.core.kubeconfig](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.kubeconfig_module.rst)|Generate, update, and optionally write Kubernetes kubeconfig files
<!--end collection content-->
@@ -94,6 +94,8 @@ Before using the Kubernetes collection, you need to install it with the Ansible
ansible-galaxy collection install kubernetes.core
Red Hat customers can install certified content from [Ansible Automation Hub](https://console.redhat.com/ansible/automation-hub). Configure Automation Hub as the primary content source for the Ansible Galaxy CLI by following the [Red Hat configuration guide](https://docs.redhat.com/en/documentation/red_hat_ansible_automation_platform/2.4/html/getting_started_with_automation_hub/configure-hub-primary), then install the collection with `ansible-galaxy collection install kubernetes.core`.
You can also include it in a `requirements.yml` file and install it via `ansible-galaxy collection install -r requirements.yml`, using the format:
```yaml
@@ -105,12 +107,14 @@ collections:
### Installing the Kubernetes Python Library
Content in this collection requires the [Kubernetes Python client](https://pypi.org/project/kubernetes/) to interact with Kubernetes' APIs. You can install it with:
Content in this collection requires the [Kubernetes Python client](https://pypi.org/project/kubernetes/) to interact with Kubernetes' APIs. For installs outside an execution environment, install it with:
```bash
pip3 install kubernetes
```
Execution environments install this dependency when they are built with `ansible-builder`; you do not need to install it separately with `pip3` in that case.
## Use Cases
It's preferable to use content in this collection using their Fully Qualified Collection Namespace (FQCN), for example `kubernetes.core.k8s_info`:
@@ -199,7 +203,7 @@ 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/stable-6/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
@@ -215,6 +219,8 @@ You can run the collection's test suites with the commands:
make test-integration
make test-unit
For instructions on running Helm integration tests locally, see the [integration tests README](https://github.com/ansible-collections/kubernetes.core/blob/main/tests/integration/README.md).
### Testing with `molecule`
There are also integration tests in the `molecule` directory which are meant to be run against a local Kubernetes cluster, e.g. using [KinD](https://kind.sigs.k8s.io) or [Minikube](https://minikube.sigs.k8s.io). To set up a local cluster using KinD and run Molecule:
@@ -226,7 +232,7 @@ There are also integration tests in the `molecule` directory which are meant to
If you want to develop new content for this collection or improve what is already here, clone the Git repository into one of the configured [`COLLECTIONS_PATHS`](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#collections-paths) and work on it there.
See [Contributing to kubernetes.core](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/CONTRIBUTING.md).
See [Contributing to kubernetes.core](https://github.com/ansible-collections/kubernetes.core/blob/main/CONTRIBUTING.md).
Join the Ansible community:
@@ -243,6 +249,8 @@ This project follows the [Ansible Code of Conduct](https://docs.ansible.com/ansi
## Support
This collection is maintained by Red Hat Ansible Cloud Content.
As Red Hat Ansible Certified Content, this collection is entitled to support through the Ansible Automation Platform (AAP) using the **Create issue** button on the top right corner. If a support case cannot be opened with Red Hat and the collection has been obtained either from Galaxy or GitHub, there may be community help available on the [Ansible Forum](https://forum.ansible.com/).
> **Note:** The `stable-4` branch (all `4.x.y` releases) is no longer supported. No backports or releases are performed on `stable-4`.
@@ -251,7 +259,7 @@ We announce releases and important changes through Ansible's [The Bullhorn newsl
We take part in the global quarterly [Ansible Contributor Summit](https://github.com/ansible/community/wiki/Contributor-Summit). Track The Bullhorn and join when announced.
For the latest supported versions, see [Release Notes and Roadmap](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/README.md#release-notes-and-roadmap).
For the latest supported versions, see [Release Notes and Roadmap](https://github.com/ansible-collections/kubernetes.core/blob/main/README.md#release-notes-and-roadmap).
Report bugs, request features, or ask questions by opening an issue in the [GitHub repository](https://github.com/ansible-collections/kubernetes.core/).
@@ -263,7 +271,7 @@ Releases are automatically built and pushed to Ansible Galaxy for any new tag. B
1. The `version` in `galaxy.yml`
2. This README's `requirements.yml` example
3. The `VERSION` in `Makefile`
2. Update the CHANGELOG:
2. Update the [CHANGELOG](CHANGELOG.rst):
1. Make sure you have [`antsibull-changelog`](https://pypi.org/project/antsibull-changelog/) installed.
2. Make sure there are fragments for all known changes in `changelogs/fragments`.
3. Run `antsibull-changelog release`.
@@ -278,9 +286,9 @@ The process for [uploading a supported release to Automation Hub](https://docs.r
* [Using Ansible collections](https://docs.ansible.com/ansible/devel/user_guide/collections_using.html)
* [Ansible communication guide](https://docs.ansible.com/ansible/devel/community/communication.html)
* [Continuous integration (CI) overview](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/CI.md)
* [SonarCloud integration](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/SONARCLOUD.md)
* [Ansible Turbo mode (tech preview)](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/docs/ansible_turbo_mode.rst)
* [Continuous integration (CI) overview](https://github.com/ansible-collections/kubernetes.core/blob/main/CI.md)
* [SonarCloud integration](https://github.com/ansible-collections/kubernetes.core/blob/main/SONARCLOUD.md)
* [Ansible Turbo mode (tech preview)](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/ansible_turbo_mode.rst)
### Code of conduct
@@ -292,4 +300,4 @@ If you encounter abusive behavior, please refer to the [policy violations](https
GNU General Public License v3.0 or later
See [LICENSE](https://github.com/ansible-collections/kubernetes.core/blob/stable-6/LICENSE) to see the full text.
See [LICENSE](https://github.com/ansible-collections/kubernetes.core/blob/main/LICENSE) to see the full text.
+1 -1
View File
@@ -21,7 +21,7 @@ Workflow files:
Scanner configuration lives in [sonar-project.properties](sonar-project.properties).
The **coverage** job (in **`all_green`**) uses **`ansible-test`** (`units --coverage`, then **`coverage combine`** / **`coverage xml`**) with **ansible-core `stable-2.18`** on **`stable-6`**, then writes **`coverage.xml`** with workspace paths normalized for Sonar. **`pytest-cov`** is listed in **`tests/unit/requirements.txt`** for parity and any direct pytest runs; **`ansible-test`** still owns the coverage data used in CI.
The **coverage** job (in **`all_green`**) uses **`ansible-test`** (`units --coverage`, then **`coverage combine`** / **`coverage xml`**), then writes **`coverage.xml`** with workspace paths normalized for Sonar. **`pytest-cov`** is listed in **`tests/unit/requirements.txt`** for parity and any direct pytest runs; **`ansible-test`** still owns the coverage data used in CI.
**`sonarcloud.yml`** declares a required secret **`ANSIBLE_COLLECTIONS_ORG_SONAR_TOKEN_CICD_BOT`** and **`permissions: contents: read`**, **`pull-requests: read`**.
+126
View File
@@ -1073,6 +1073,132 @@ releases:
- 20250922-remove-ansible-six-imports.yaml
- 5.4.1.yml
release_date: '2025-10-07'
5.4.2:
changes:
bugfixes:
- Add idempotency for ``helm_pull`` module (https://github.com/ansible-collections/kubernetes.core/pull/1055).
- Fixed a bug where setting ``K8S_AUTH_VERIFY_SSL=true`` (or any string value)
caused the value to be treated as a separate ``kubectl`` command argument
(https://github.com/ansible-collections/kubernetes.core/pull/1049).
- Limit supported versions of Helm to <4.0.0 (https://github.com/ansible-collections/kubernetes.core/pull/1039).
- Replace passing ``warnings`` to ``exit_json`` with ``AnsibleModule.warn``
in the ``k8s_drain``, ``k8s_rollback.py`` and ``k8s_scale.py`` modules as
it deprecated in ``ansible-core>=2.19.0`` and will be removed in ``ansible-core>=2.23.0``
(https://github.com/ansible-collections/kubernetes.core/pull/1033).
- k8s - Fix return block from the module documentation (https://github.com/ansible-collections/kubernetes.core/pull/1056).
- meta - Add ``k8s_cluster_info``, ``k8s_json_patch`` and ``k8s_rollback`` to
k8s action group (https://github.com/ansible-collections/kubernetes.core/pull/992).
deprecated_features:
- helm - the ``status.values`` return value has been deprecated and will be
removed in a release after 2027-01-08. Use ``status.release_values`` instead
(https://github.com/ansible-collections/kubernetes.core/pull/1056).
- helm_info - the ``status.values`` return value has been deprecated and will
be removed in a release after 2027-01-08. Use ``status.release_values`` instead
(https://github.com/ansible-collections/kubernetes.core/pull/1056).
minor_changes:
- helm - Add ``release_values`` key to ``status`` return value that can be accessed
using Jinja2 dot notation (https://github.com/ansible-collections/kubernetes.core/pull/1056).
- helm_info - Add ``release_values`` key to ``status`` return value that can
be accessed using Jinja2 dot notation (https://github.com/ansible-collections/kubernetes.core/pull/1056).
release_summary: This release includes bugfixes such as replacing the passing
of ``warnings`` to ``exit_json`` with ``AnsibleModule.warn`` as well as a
security update for selectively redacting sensitive information from kubeconfig,
and adds a new ``release_values`` key to the ``status`` return value.
security_fixes:
- Selectively redact sensitive info from kubeconfig instead of applying blanket
``no_log=True`` (https://github.com/ansible-collections/kubernetes.core/pull/1014).
fragments:
- 1033-warnings-deprecations.yaml
- 20251002-fix-k8s-actiongroup.yaml
- 20251007-selective-kubeconfig-redaction.yaml
- 20251115-limit-versions-of-helm.yaml
- 20251220-fix-K8S_AUTH_VERIFY_SSL-in-kubectl-connecton-plugion.yaml
- 20260107-add-idempodency-for-helm-pull.yaml
- 20260108-fix-sanity-failures.yml
- 5-4-2.yaml
release_date: '2026-02-03'
5.4.3:
changes:
bugfixes:
- ee - Add ``meta/execution-environment.yml`` to decouple ansible-builder EE
builds from the ``openshift-clients`` system dependency declared in ``bindep.txt``,
which is not available in standard UBI repositories and caused builds to fail
with ``No package matches 'openshift-clients'`` (https://github.com/ansible-collections/kubernetes.core/issues/1141).
- helm_repository - Correct handling of repository URLs with trailing slashes
(https://github.com/ansible-collections/kubernetes.core/pull/1121).
- k8s_drain - Fix logic for handling pods with local storage to correctly check
for empty_dir volumes in replicated pods and pods managed by DaemonSets (https://github.com/ansible-collections/kubernetes.core/pull/1095).
release_summary: This release contains bugfixes such as improved idempotency
for helm repository URLs with trailing slashes.
fragments:
- 1173-security-check-workflow.yml
- 20260306-k8s_drain-delete-logic-fixes-for-daemonsets.yaml
- 20260506-improve_idempotency_for_helm_repository.yaml
- 5-4-3.yml
- fix-openshift-clients-ee-dependency.yaml
release_date: '2026-07-08'
5.4.4:
changes:
bugfixes:
- meta - Update ``requires_ansible`` in ``runtime.yml`` and README to ``>=2.16.0``
to match the actual minimum supported ``ansible-core`` version (https://github.com/ansible-collections/kubernetes.core/pull/1193).
release_summary: This release corrects the documented and enforced minimum ``ansible-core``
version to ``>=2.16.0``.
release_date: '2026-07-09'
5.5.0:
changes:
bugfixes:
- Ansible Turbo mode - ignore ``ENABLE_TURBO_MODE`` on ansible-core 2.19.0 and
later, where the ``cloud.common`` collection is not supported, and fall back
to the standard ``AnsibleModule`` instead of failing with ``byte indices must
be integers or slices, not str`` (https://github.com/ansible-collections/kubernetes.core/pull/1242).
- helm_repository - normalize both sides of the repository URL comparison, so
that a repository already registered with a trailing slash is recognized as
matching instead of failing with ``Repository already have a repository named
<name>`` (https://github.com/ansible-collections/kubernetes.core/pull/1236).
- k8s lookup - ignore ``ENABLE_TURBO_MODE`` on ansible-core 2.19.0 and later,
where the ``cloud.common`` collection is not supported. Fall back to the standard
``LookupBase`` instead of failing with a traceback (https://github.com/ansible-collections/kubernetes.core/pull/1253).
- k8s_info - Handle empty template output gracefully by returning ``changed=false``
instead of failing when Jinja2 template renders to an empty string (https://github.com/ansible-collections/kubernetes.core/issues/1042).
deprecated_features:
- Ansible Turbo mode (``ENABLE_TURBO_MODE``) has been deprecated and will be
removed in release 8.0.0, as it depends on the ``cloud.common`` collection,
which is being retired (https://github.com/ansible-collections/kubernetes.core/pull/1242).
- helm - the ``status.values`` return value has been deprecated and will be
removed in version 8.0.0. Use ``status.release_values`` instead (https://github.com/ansible-collections/kubernetes.core/issues/1239).
- helm - the ``wait_timeout`` parameter has been deprecated and will be removed
in version 7.0.0. Use ``timeout`` instead (https://github.com/ansible-collections/kubernetes.core/issues/1239).
- helm_info - the ``status.values`` return value has been deprecated and will
be removed in version 8.0.0. Use ``status.release_values`` instead (https://github.com/ansible-collections/kubernetes.core/issues/1239).
- k8s_exec - the ``return_code`` return value has been deprecated and will be
removed in version 7.0.0. Use ``rc`` instead (https://github.com/ansible-collections/kubernetes.core/issues/1239).
- k8s_service - the ``merge_type=json`` option has been deprecated and will
be removed in version 7.0.0. Use ``kubernetes.core.k8s_json_patch`` module
instead (https://github.com/ansible-collections/kubernetes.core/issues/1239).
minor_changes:
- Remove the remaining ``ansible.module_utils.six`` import to avoid deprecation
warnings, replacing it with the Python standard library equivalent (https://github.com/ansible-collections/kubernetes.core/pull/1197).
- k8s lookup - warn when ``ENABLE_TURBO_MODE`` is set but the ``cloud.common``
collection is not installed, instead of silently falling back to the standard
lookup base (https://github.com/ansible-collections/kubernetes.core/pull/1242).
release_summary: This minor release deprecates Ansible Turbo mode (``ENABLE_TURBO_MODE``),
the ``status.values`` return value of the ``helm`` and ``helm_info`` modules,
the ``wait_timeout`` parameter of the ``helm`` module, the ``return_code``
return value of the ``k8s_exec`` module, and the ``merge_type=json`` option
of the ``k8s_service`` module. It also includes bugfixes for ``helm_repository``
URL comparison and for empty template output handling in ``k8s_info``.
fragments:
- 1253-k8s-lookup-turbo-version-check.yml
- 20250108-fix-empty-template-output.yaml
- 20260723-remove-module-utils-six.yaml
- 20260908-helm-repository-trailing-slash.yaml
- 20260911-deprecate-status-values.yaml
- 20260911-update-deprecation-notices.yaml
- 5.5.0.yml
- deprecate-enable-turbo-mode.yml
- fix-ansible-lint-warnings.yaml
release_date: '2026-09-15'
6.0.0:
changes:
breaking_changes:
@@ -0,0 +1,3 @@
---
bugfixes:
- helm - Remove `--plain-http` option from `helm diff upgrade`, as it is not supported by the helm-diff plugin (https://github.com/ansible-collections/kubernetes.core/pull/1232).
@@ -0,0 +1,4 @@
---
bugfixes:
- k8s, k8s_service - emit warnings through ``AnsibleModule.warn`` instead of putting them in the result dict that is unpacked into ``exit_json``/``fail_json``. Passing ``warnings`` that way is deprecated since ansible-core 2.19 and will be removed in 2.23, so every run that produced a warning (for example the "No meaningful diff was generated" hint, warnings returned by the Kubernetes API, or ``validate`` findings) also emitted a deprecation warning (https://github.com/ansible-collections/kubernetes.core/pull/1267).
- k8s - warnings raised while processing a multi-document manifest are now shown to the user. They were previously nested under ``result.results[*].warnings``, where ansible-core never picked them up, so they were silently dropped whenever more than one resource was processed (https://github.com/ansible-collections/kubernetes.core/pull/1267).
+17
View File
@@ -427,6 +427,23 @@ Common return values are documented `here <https://docs.ansible.com/projects/ans
<br/>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>release_values</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></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 6.3.0</div>
</td>
<td>always</td>
<td>
<div>Dict of Values used to deploy.</div>
<br/>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
+1
View File
@@ -1035,6 +1035,7 @@ Examples
Return Values
-------------
Common return values are documented `here <https://docs.ansible.com/projects/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
Common return values are documented `here <https://docs.ansible.com/projects/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
.. raw:: html
+1 -1
View File
@@ -813,7 +813,7 @@ Parameters
</ul>
</td>
<td>
<div>Determines if an object should be created, patched, or deleted. When set to <code>present</code>, an object will be created, if it does not already exist. If set to <code>absent</code>, an existing object will be deleted. If set to <code>present</code>, an existing object will be patched, if its attributes differ from those specified using <em>resource_definition</em> or <em>src</em>.</div>
<div>Determines if an object should be created, patched, or deleted. When set to <code>present</code>, an object will be created if it does not already exist, and an existing object will be patched if its attributes differ from those specified using <em>resource_definition</em> or <em>src</em>. If set to <code>absent</code>, an existing object will be deleted.</div>
<div><code>patched</code> state is an existing resource that has a given patch applied. If the resource doesn&#x27;t exist, silently skip it (do not raise an error).</div>
</td>
</tr>
+1 -1
View File
@@ -509,7 +509,7 @@ Parameters
</ul>
</td>
<td>
<div>Determines if an object should be created, patched, or deleted. When set to <code>present</code>, an object will be created, if it does not already exist. If set to <code>absent</code>, an existing object will be deleted. If set to <code>present</code>, an existing object will be patched, if its attributes differ from those specified using <em>resource_definition</em> or <em>src</em>.</div>
<div>Determines if an object should be created, patched, or deleted. When set to <code>present</code>, an object will be created if it does not already exist, and an existing object will be patched if its attributes differ from those specified using <em>resource_definition</em> or <em>src</em>. If set to <code>absent</code>, an existing object will be deleted.</div>
</td>
</tr>
<tr>
+1 -1
View File
@@ -25,7 +25,7 @@ tags:
- openshift
- okd
- cluster
version: 6.6.0
version: 7.0.0-dev0
build_ignore:
- .DS_Store
- "*.tar.gz"
+3 -3
View File
@@ -228,13 +228,13 @@ EXAMPLES = r"""
gather_facts: no
vars:
kubeconfig: /root/.kube/config
namespace: my-namespace
k8s_namespace: my-namespace
my_app: my-app
tasks:
- name: Get My App pod info based on label
kubernetes.core.k8s_info:
kubeconfig: "{{ kubeconfig }}"
namespace: "{{ namespace }}"
namespace: "{{ k8s_namespace }}"
kind: Pod
label_selectors: app.kubernetes.io/name = "{{ my_app }}"
register: my_app_pod
@@ -249,7 +249,7 @@ EXAMPLES = r"""
ansible_connection: kubernetes.core.kubectl
ansible_kubectl_kubeconfig: "{{ kubeconfig }}"
ansible_kubectl_pod: "{{ my_app_pod_name }}"
ansible_kubectl_namespace: "{{ namespace }}"
ansible_kubectl_namespace: "{{ k8s_namespace }}"
- name: Run a command in My App pod
# be aware that the command is executed as the user that started the container
+2 -3
View File
@@ -16,9 +16,8 @@ options:
state:
description:
- Determines if an object should be created, patched, or deleted. When set to C(present), an object will be
created, if it does not already exist. If set to C(absent), an existing object will be deleted. If set to
C(present), an existing object will be patched, if its attributes differ from those specified using
I(resource_definition) or I(src).
created if it does not already exist, and an existing object will be patched if its attributes differ from
those specified using I(resource_definition) or I(src). If set to C(absent), an existing object will be deleted.
type: str
default: present
choices: [ absent, present ]
+6 -10
View File
@@ -92,10 +92,10 @@ def run_module(module) -> None:
for definition in definitions:
result = {"changed": False, "result": {}}
warnings = []
if module.params.get("validate") is not None:
warnings = validate(client, module, definition)
for warning in validate(client, module, definition):
module.warn(warning)
try:
result = perform_action(svc, definition, module.params)
@@ -109,16 +109,12 @@ def run_module(module) -> None:
except AttributeError:
pass
error["msg"] = to_native(e)
if warnings:
error.setdefault("warnings", []).extend(warnings)
if module.params.get("continue_on_error"):
result["error"] = error
else:
module.fail_json(**error)
if warnings:
result.setdefault("warnings", []).extend(warnings)
changed |= result["changed"]
results.append(result)
@@ -177,7 +173,7 @@ def perform_action(svc, definition: Dict, params: Dict) -> Dict:
result["method"] = "apply"
elif not existing:
if state == "patched":
result.setdefault("warnings", []).append(
svc.module.warn(
"resource 'kind={kind},name={name}' was not found but will not be "
"created as 'state' parameter has been set to '{state}'".format(
kind=kind, name=definition["metadata"].get("name"), state=state
@@ -194,8 +190,8 @@ def perform_action(svc, definition: Dict, params: Dict) -> Dict:
instance, warnings = svc.update(resource, definition, existing)
result["method"] = "update"
if warnings:
result["warnings"] = warnings
for warning in warnings:
svc.module.warn(warning)
# If needed, wait and/or create diff
success = True
@@ -217,7 +213,7 @@ def perform_action(svc, definition: Dict, params: Dict) -> Dict:
existing = {}
match, diffs = diff_objects(existing, instance, hidden_fields)
if match and diffs:
result.setdefault("warnings", []).append(
svc.module.warn(
"No meaningful diff was generated, but the API may not be idempotent "
"(only metadata.generation or metadata.resourceVersion were changed)"
)
+3 -1
View File
@@ -15,4 +15,6 @@ __metaclass__ = type
#
# from ansible.module_utils.compat.version import LooseVersion
from ._version import LooseVersion # noqa: F401
from ._version import LooseVersion # noqa: F401 # pylint: disable=unused-import
__all__ = ["LooseVersion"]
-13
View File
@@ -956,7 +956,6 @@ def helmdiff_check(
reset_values=True,
reset_then_reuse_values=False,
insecure_skip_tls_verify=False,
plain_http=False,
skip_schema_validation=False,
):
"""
@@ -1024,17 +1023,6 @@ def helmdiff_check(
else:
cmd += " --skip-schema-validation"
if plain_http:
helm_version = module.get_helm_version()
if LooseVersion(helm_version) < LooseVersion("3.13.0"):
module.fail_json(
msg="plain_http requires helm >= 3.13.0, current version is {0}".format(
helm_version
)
)
else:
cmd += " --plain-http"
rc, out, err = module.run_helm_command(cmd)
return (len(out.strip()) > 0, out.strip())
@@ -1362,7 +1350,6 @@ def main():
reset_values=reset_values,
reset_then_reuse_values=reset_then_reuse_values,
insecure_skip_tls_verify=insecure_skip_tls_verify,
plain_http=plain_http,
skip_schema_validation=skip_schema_validation,
)
if would_change and module._diff:
+2 -3
View File
@@ -40,9 +40,8 @@ options:
state:
description:
- Determines if an object should be created, patched, or deleted. When set to C(present), an object will be
created, if it does not already exist. If set to C(absent), an existing object will be deleted. If set to
C(present), an existing object will be patched, if its attributes differ from those specified using
I(resource_definition) or I(src).
created if it does not already exist, and an existing object will be patched if its attributes differ from
those specified using I(resource_definition) or I(src). If set to C(absent), an existing object will be deleted.
- C(patched) state is an existing resource that has a given patch applied. If the resource doesn't exist, silently skip it (do not raise an error).
type: str
default: present
+23 -2
View File
@@ -9,7 +9,7 @@ sonar.python.coverage.reportPaths=coverage.xml
sonar.tests=tests/unit,tests/integration
sonar.python.version=3.12
sonar.newCode.referenceBranch=stable-6
sonar.newCode.referenceBranch=main
sonar.exclusions=tests/**,.tox/**
@@ -28,7 +28,7 @@ sonar.cpd.exclusions=tests/**
# constructor (not {...} literals) for readability and consistency across the
# collection. Suppress python:S7498 ("prefer literal syntax"), which conflicts
# with that convention and otherwise re-fires on every new module argument.
sonar.issue.ignore.multicriteria=e1,e2,e3
sonar.issue.ignore.multicriteria=e1,e2,e3,e4,e5
sonar.issue.ignore.multicriteria.e1.ruleKey=python:S7498
sonar.issue.ignore.multicriteria.e1.resourceKey=**/*.py
@@ -45,3 +45,24 @@ sonar.issue.ignore.multicriteria.e2.resourceKey=tests/**/*.py
# to simplify maintenance. Suppress githubactions:S7637 ("use full commit SHA").
sonar.issue.ignore.multicriteria.e3.ruleKey=githubactions:S7637
sonar.issue.ignore.multicriteria.e3.resourceKey=.github/workflows/**/*.yaml
# Workflows across this repo install ansible-core from a GitHub source
# archive (required for devel/milestone builds, which have no published
# wheel) and install this collection's shared test-requirements.txt /
# requirements.txt. Suppress githubactions:S8541 ("omitting --only-binary
# :all:") repo-wide for workflow files: forcing wheel-only installs would
# break the ansible-core source install and fails outright on the
# test-requirements.txt pin coverage==4.5.4, which has no Python 3.13 wheel.
# Scoped the same way as e3 above, since a filename-only resourceKey (as
# originally used here) does not reliably suppress issues already raised
# against this project.
sonar.issue.ignore.multicriteria.e4.ruleKey=githubactions:S8541
sonar.issue.ignore.multicriteria.e4.resourceKey=.github/workflows/**/*.yaml
# Same shared test-requirements.txt / requirements.txt as above are not
# hash-locked; that is a repo-wide dependency-management concern affecting
# every existing workflow. Suppress githubactions:S8544 ("dependencies
# without locking resolved versions") repo-wide for workflow files rather
# than diverging from established practice.
sonar.issue.ignore.multicriteria.e5.ruleKey=githubactions:S8544
sonar.issue.ignore.multicriteria.e5.resourceKey=.github/workflows/**/*.yaml
+46
View File
@@ -0,0 +1,46 @@
# Running Helm Integration Tests Locally
This guide explains how to run the `helm*` integration test targets locally using `ansible-test`.
## Prerequisites
- `ansible-test` available in your environment (installed with `ansible-core`)
- A Kubernetes cluster accessible via `kubectl` (for targets that interact with a cluster)
## Configuration
Create an `integration_config.yml` file under `tests/integration/` with the following variables:
```yaml
setup_helm_version: vx.x.x # e.g v4.2.1
helm_install_path: /path/to/helm/directory
```
### Variables
| Variable | Description |
|---|---|
| `setup_helm_version` | The Helm version to install (e.g. `v4.2.1`). The `v` prefix is optional and will be added automatically if omitted. |
| `helm_install_path` | Path to a directory that either already contains a `helm` executable matching the version set in `setup_helm_version`, or an empty/non-existent directory where Helm will be downloaded and installed. |
If a `helm` binary already exists at `<helm_install_path>/helm`, the setup will skip the download and use the existing binary directly.
## Running Tests
Run a specific Helm test target with:
```bash
ansible-test integration --python <version> -v --no-temp-workdir <target>
```
For example, to run the `helm` target with Python 3.12:
```bash
ansible-test integration --python 3.12 -v --no-temp-workdir helm
```
You can run multiple targets in a single command:
```bash
ansible-test integration --python 3.12 -v --no-temp-workdir helm helm_diff helm_plugin
```
+4 -1
View File
@@ -1 +1,4 @@
disabled # used by test targets helm_vX_XX_XX
helm
helm_info
helm_plugin
helm_template
@@ -1,6 +1,6 @@
---
helm_default_archive_name: "helm-{{ helm_version }}-{{ ansible_system | lower }}-amd64.tar.gz"
helm_binary: "/tmp/helm/{{ ansible_system | lower }}-amd64/helm"
helm_binary: "helm"
setup_helm_version_binary_path: "{{ helm_binary }}"
chart_test: "ingress-nginx"
chart_test_oci: "oci://registry-1.docker.io/bitnamicharts/redis"
@@ -1,96 +0,0 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2021, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
DOCUMENTATION = r"""
---
module: helm_test_version
short_description: check helm executable version
author:
- Aubin Bikouo (@abikouo)
requirements:
- "helm (https://github.com/helm/helm/releases)"
description:
- validate version of helm binary is lower than the specified version.
options:
binary_path:
description:
- The path of a helm binary to use.
required: false
type: path
version:
description:
- version to test against helm binary.
type: str
default: 3.7.0
"""
EXAMPLES = r"""
- name: validate helm binary version is lower than 3.5.0
helm_test_version:
binary_path: path/to/helm
version: "3.5.0"
"""
RETURN = r"""
message:
type: str
description: Text message describing the test result.
returned: always
sample: 'version installed: 3.4.5 is lower than version 3.5.0'
result:
type: bool
description: Test result.
returned: always
sample: 1
"""
import re
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.kubernetes.core.plugins.module_utils.version import (
LooseVersion,
)
def main():
module = AnsibleModule(
argument_spec=dict(
binary_path=dict(type="path"),
version=dict(type="str", default="3.7.0"),
),
)
bin_path = module.params.get("binary_path")
version = module.params.get("version")
if bin_path is not None:
helm_cmd_common = bin_path
else:
helm_cmd_common = "helm"
helm_cmd_common = module.get_bin_path(helm_cmd_common, required=True)
rc, out, err = module.run_command([helm_cmd_common, "version"])
if rc != 0:
module.fail_json(msg="helm version failed.", err=err, out=out, rc=rc)
m = re.match(r'version.BuildInfo{Version:"v([0-9\.]*)",', out)
installed_version = m.group(1)
message = "version installed: %s" % installed_version
if LooseVersion(installed_version) < LooseVersion(version):
message += " is lower than version %s" % version
module.exit_json(changed=False, result=True, message=message)
else:
message += " is greater than version %s" % version
module.exit_json(changed=False, result=False, message=message)
if __name__ == "__main__":
main()
@@ -1,3 +1,5 @@
---
dependencies:
- setup_helm_version
collections:
- kubernetes.core
+4 -15
View File
@@ -1,22 +1,11 @@
---
- name: Ensure helm is not installed
file:
path: "{{ item }}"
ansible.builtin.file:
path: "/tmp/helm"
state: absent
with_items:
- "/tmp/helm"
- name: Check failed if helm is not installed
include_tasks: test_helm_not_installed.yml
- name: Install Helm v4
ansible.builtin.include_role:
name: install_helm
vars:
helm_version: v3.6.0
- name: Test helm uninstall
ansible.builtin.include_tasks: test_helm_uninstall.yml
ansible.builtin.include_tasks: test_helm_not_installed.yml
- name: Run tests
include_tasks: run_test.yml
ansible.builtin.include_tasks: run_test.yml
@@ -1,22 +1,18 @@
---
- name: "Install {{ helm_version }}"
include_role:
name: install_helm
- name: Main helm tests
block:
- name: Install helm-diff plugin
helm_plugin:
binary_path: "{{ helm_binary }}"
plugin_path: https://github.com/databus23/helm-diff
plugin_version: "{{ helm_version is version('v4.0.0', '>=') | ternary('v3.14.0', 'v3.10.0') }}"
plugin_version: "{{ helm_version | string is ansible.builtin.version('4.0.0', '>=') | ternary('v3.14.0', 'v3.10.0') }}"
verify: false
- name: "Ensure we honor the environment variables"
include_tasks: test_read_envvars.yml
ansible.builtin.include_tasks: test_read_envvars.yml
- name: Deploy charts
include_tasks: "tests_chart/{{ test_chart_type }}.yml"
ansible.builtin.include_tasks: "tests_chart/{{ test_chart_type }}.yml"
loop_control:
loop_var: test_chart_type
with_items:
@@ -24,33 +20,34 @@
- from_repository
- from_url
- name: test helm upgrade with reuse_values
include_tasks: test_helm_reuse_values.yml
- name: Test helm upgrade with reuse_values
ansible.builtin.include_tasks: test_helm_reuse_values.yml
- name: test helm upgrade with reset_then_reuse_values
include_tasks: test_helm_reset_then_reuse_values.yml
- name: Test helm upgrade with reset_then_reuse_values
ansible.builtin.include_tasks: test_helm_reset_then_reuse_values.yml
when: helm_version | string is ansible.builtin.version('3.14.0', '>=')
- name: test helm dependency update
include_tasks: test_up_dep.yml
- name: Test helm dependency update
ansible.builtin.include_tasks: test_up_dep.yml
- name: Test helm install with chart name containing space
include_tasks: test_helm_with_space_into_chart_name.yml
ansible.builtin.include_tasks: test_helm_with_space_into_chart_name.yml
# https://github.com/ansible-collections/community.kubernetes/issues/296
- name: Test Skip CRDS feature in helm chart install
include_tasks: test_crds.yml
ansible.builtin.include_tasks: test_crds.yml
- name: Test insecure registry flag feature
include_tasks: test_helm_insecure.yml
ansible.builtin.include_tasks: test_helm_insecure.yml
- name: Test take ownership flag feature
include_tasks: test_helm_take_ownership.yml
ansible.builtin.include_tasks: test_helm_take_ownership.yml
- name: Test helm skip_schema_validation
include_tasks: test_skip_schema_validation.yml
ansible.builtin.include_tasks: test_skip_schema_validation.yml
- name: Test helm wait_for_jobs
include_tasks: test_helm_wait_for_jobs.yml
ansible.builtin.include_tasks: test_helm_wait_for_jobs.yml
always:
- name: Remove helm-diff plugin
@@ -14,7 +14,7 @@
register: install
- name: Validate that insecure flag is not set
assert:
ansible.builtin.assert:
that:
- install is changed
- '"--insecure-skip-tls-verify" not in install.command'
@@ -30,18 +30,18 @@
ignore_errors: true
- name: Validate that insecure flag IS set if helm version is >= 3.16.0
assert:
ansible.builtin.assert:
that:
- install is changed
- '"--insecure-skip-tls-verify" in install.command'
when: '"v3.16.0" <= helm_version'
when: helm_version | string is ansible.builtin.version("3.16.0", ">=")
- name: Validate that feature fails for helm < 3.16.0
assert:
ansible.builtin.assert:
that:
- install is failed
- '"insecure_skip_tls_verify requires helm >= 3.16.0" in install.msg'
when: 'helm_version < "v3.16.0"'
when: helm_version | string is ansible.builtin.version("3.16.0", "<")
always:
- name: Remove helm namespace
@@ -1,7 +1,7 @@
---
- name: Failed test when helm is not installed
helm:
binary_path: "{{ helm_binary}}_fake"
binary_path: "{{ helm_binary }}_fake"
name: test
chart_ref: "{{ chart_test }}"
namespace: "helm-test"
@@ -9,15 +9,7 @@
register: helm_missing_binary
- name: Assert that helm is not installed
assert:
that:
- helm_missing_binary is failed
- "'No such file or directory' in helm_missing_binary.msg"
when: ansible_version.full is version('2.20', '<')
- name: Assert that helm is not installed (ansible 2.20+)
assert:
ansible.builtin.assert:
that:
- helm_missing_binary is failed
- "'Error executing command' in helm_missing_binary.msg"
when: ansible_version.full is version('2.20', '>=')
@@ -32,7 +32,7 @@
register: release_value
- name: Validate that chart values are as expected
assert:
ansible.builtin.assert:
that:
- install is changed
- '"--reset-then-reuse-values" not in install.command'
@@ -80,7 +80,7 @@
register: release_value
- name: Validate that chart values are as expected
assert:
ansible.builtin.assert:
that:
- upgrade is changed
- '"--reset-then-reuse-values" in upgrade.command'
@@ -32,7 +32,7 @@
register: release_value
- name: Validate that chart values are as expected
assert:
ansible.builtin.assert:
that:
- install is changed
- '"--reuse-values=True" not in install.command'
@@ -72,7 +72,7 @@
register: release_value
- name: Validate that chart values are as expected
assert:
ansible.builtin.assert:
that:
- upgrade is changed
- '"--reuse-values=True" in upgrade.command'
@@ -14,7 +14,7 @@
register: install
- name: Validate that take-ownership flag is not set
assert:
ansible.builtin.assert:
that:
- install is changed
- '"--take-ownership" not in install.command'
@@ -50,18 +50,18 @@
ignore_errors: true
- name: Validate that take-ownership flag IS set if helm version is >= 3.17.0
assert:
ansible.builtin.assert:
that:
- upgrade is changed
- '"--take-ownership" in upgrade.command'
when: '"v3.17.0" <= helm_version'
when: helm_version | string is ansible.builtin.version("3.17.0", ">=")
- name: Validate that feature fails for helm < 3.17.0
assert:
ansible.builtin.assert:
that:
- upgrade is failed
- '"take_ownership requires helm >= 3.17.0" in upgrade.msg'
when: 'helm_version < "v3.17.0"'
when: helm_version | string is ansible.builtin.version("3.17.0", "<")
- name: Upgrade chart (take-onwership flag not set)
helm:
@@ -79,18 +79,18 @@
ignore_errors: true
- name: Validate that take-ownership flag IS set if helm version is >= 3.17.0
assert:
ansible.builtin.assert:
that:
- upgrade is changed
- '"--take-ownership" not in upgrade.command'
when: '"v3.17.0" <= helm_version'
when: helm_version | string is ansible.builtin.version("3.17.0", ">=")
- name: Validate that feature fails for helm < 3.17.0
assert:
ansible.builtin.assert:
that:
- upgrade is changed
- upgrade.msg is not defined
when: 'helm_version < "v3.17.0"'
when: helm_version | string is ansible.builtin.version("3.17.0", "<")
always:
- name: Remove helm namespace
@@ -1,97 +0,0 @@
- name: validate helm version lower than 3.7.0
helm_test_version:
binary_path: "{{ helm_binary }}"
version: "3.7.0"
register: test_version
- vars:
chart_source: "https://github.com/kubernetes/kube-state-metrics/releases/download/kube-state-metrics-helm-chart-2.13.3/kube-state-metrics-2.13.3.tgz"
chart_name: "test-wait-uninstall"
chart_name_pending: "test-uninstall-pending-release"
helm_namespace: "{{ test_namespace[1] }}"
block:
- name: Install chart
helm:
binary_path: "{{ helm_binary }}"
name: "{{ chart_name }}"
chart_ref: "{{ chart_source }}"
namespace: "{{ helm_namespace }}"
create_namespace: true
- name: Delete chart with wait
helm:
state: absent
binary_path: "{{ helm_binary }}"
name: "{{ chart_name }}"
namespace: "{{ helm_namespace }}"
wait: yes
register: uninstall
- name: assert warning has been raised
assert:
that:
- uninstall.warnings is defined
- '"helm uninstall support option --wait for helm release >= 3.7.0" in uninstall.warnings'
- name: Install Helm v4
ansible.builtin.include_role:
name: install_helm
vars:
helm_version: v4.0.0
- name: Install chart
helm:
binary_path: "{{ helm_binary }}"
name: "{{ chart_name }}"
chart_ref: "{{ chart_source }}"
namespace: "{{ helm_namespace }}"
create_namespace: true
- name: uninstall chart again using recent version
helm:
state: absent
binary_path: "{{ helm_binary }}"
name: "{{ chart_name }}"
namespace: "{{ helm_namespace }}"
wait: yes
register: uninstall
# Test uninstall chart release with 'pending-install' status
- name: Create chart release with 'pending-install' status
helm_test_pending:
binary_path: "{{ helm_binary }}"
chart_ref: "{{ chart_source }}"
chart_release: "{{ chart_name_pending }}"
chart_release_namespace: "{{ helm_namespace }}"
- name: Uninstall chart release with 'pending-install' status
helm:
binary_path: "{{ helm_binary }}"
release_name: "{{ chart_name_pending }}"
namespace: "{{ helm_namespace }}"
release_state: absent
register: _uninstall
- name: Get Helm release details
helm_info:
binary_path: "{{ helm_binary }}"
release_namespace: "{{ helm_namespace }}"
release_state: pending
release_name: "{{ chart_name_pending }}"
register: _info
- name: assert release does not exist anymore
assert:
that:
- _uninstall is changed
- _info.status is undefined
always:
- name: Remove namespace
k8s:
kind: Namespace
name: "{{ helm_namespace }}"
state: absent
ignore_errors: true
when: test_version.result
@@ -19,19 +19,19 @@
ignore_errors: true
- name: Validate wait_for_jobs with helm >= 3.5.0 works
assert:
ansible.builtin.assert:
that:
- install is changed
- "'--wait' in install.command"
- "'--wait-for-jobs' in install.command"
when: "helm_version is ansible.builtin.version('v3.5.0', '>=')"
when: "helm_version | string is ansible.builtin.version('3.5.0', '>=')"
- name: Validate wait_for_jobs with helm < 3.5.0 fails
assert:
ansible.builtin.assert:
that:
- install is failed
- "'wait_for_jobs requires helm >= 3.5.0' in install.msg"
when: "helm_version is ansible.builtin.version('v3.5.0', '<')"
when: "helm_version | string is ansible.builtin.version('3.5.0', '<')"
- name: Install chart with wait_for_jobs but without wait
helm:
@@ -44,7 +44,7 @@
register: install_no_wait
- name: Validate wait_for_jobs is ignored without wait
assert:
ansible.builtin.assert:
that:
- install_no_wait is changed
- "'--wait-for-jobs' not in install_no_wait.command"
@@ -27,7 +27,7 @@
register: install_chart
- name: Assert that chart is installed
assert:
ansible.builtin.assert:
that:
- install_chart is changed
- install_chart.status.status | lower == 'deployed'
@@ -40,7 +40,7 @@
register: chart_info
- name: Assert that Chart is installed (using helm_info)
assert:
ansible.builtin.assert:
that:
- chart_info.status.status | lower == 'deployed'
@@ -22,22 +22,22 @@
ignore_errors: true
- name: Debug install result
debug:
ansible.builtin.debug:
var: install
- name: Validate skip_schema_validation with helm >= 3.16.0 works
assert:
ansible.builtin.assert:
that:
- install is changed
- "'--skip-schema-validation' in install.command"
when: "helm_version is ansible.builtin.version('v3.16.0', '>=')"
when: "helm_version | string is ansible.builtin.version('3.16.0', '>=')"
- name: Validate skip_schema_validation with helm < 3.16.0 fails
assert:
ansible.builtin.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', '<')"
when: "helm_version | string is ansible.builtin.version('3.16.0', '<')"
always:
- name: Remove helm namespace
@@ -3,8 +3,8 @@
vars:
helm_namespace: "{{ test_namespace[3] }}"
block:
- name: copy chart
copy:
- name: Copy chart
ansible.builtin.copy:
src: "{{ item }}"
dest: /tmp
loop:
@@ -19,16 +19,16 @@
chart_version: "{{ chart_source_version | default(omit) }}"
namespace: "{{ helm_namespace }}"
dependency_update: false
create_namespace: yes
create_namespace: true
register: release
- name: "Get stats of the subchart"
stat:
ansible.builtin.stat:
path: "/tmp/test-chart/Chart.lock"
register: stat_result
- name: "Check if the subchart not exist in chart"
assert:
ansible.builtin.assert:
that:
- not stat_result.stat.exists
success_msg: "subchart not exist in the chart directory"
@@ -41,12 +41,12 @@
chart_ref: "/tmp/test-chart"
chart_version: "{{ chart_source_version | default(omit) }}"
namespace: "{{ helm_namespace }}"
create_namespace: yes
create_namespace: true
dependency_update: true
ignore_errors: true
register: release
- assert:
- ansible.builtin.assert:
that:
- release.warnings[0] == "There is no dependencies block defined in Chart.yaml. Dependency update will not be performed. Please consider add dependencies block or disable dependency_update to remove this warning."
success_msg: "warning when there is no dependencies block with dependency_update enabled"
@@ -59,16 +59,16 @@
chart_version: "{{ chart_source_version | default(omit) }}"
namespace: "{{ helm_namespace }}"
dependency_update: true
create_namespace: yes
create_namespace: true
register: release
- name: "Get stats of the subchart"
stat:
ansible.builtin.stat:
path: "/tmp/dep-up/Chart.lock"
register: stat_result
- name: "Check if the subchart exists in chart"
assert:
ansible.builtin.assert:
that:
- stat_result.stat.exists
success_msg: "subchart exist in the chart directory"
@@ -82,7 +82,7 @@
state: absent
- name: "Remove charts"
file:
ansible.builtin.file:
state: absent
path: "/tmp/{{ item }}"
loop:
@@ -92,8 +92,8 @@
# Helm_template module
- name: "Test dependency update for helm_template module"
block:
- name: copy chart
copy:
- name: Copy chart
ansible.builtin.copy:
src: "{{ item }}"
dest: /tmp
loop:
@@ -110,7 +110,7 @@
register: result
- name: "Get stats of the subchart"
stat:
ansible.builtin.stat:
path: "{{ item }}"
register: stat_result
loop:
@@ -118,7 +118,7 @@
- /tmp/dep_up/charts/test-chart/templates/configmap.yaml
- name: "Check if the subchart exist in chart"
assert:
ansible.builtin.assert:
that:
- stat_result.results[0].stat.exists
- stat_result.results[1].stat.exists
@@ -135,7 +135,7 @@
register: result
- name: "Get stats of the subchart"
stat:
ansible.builtin.stat:
path: "{{ item }}"
register: stat_result
loop:
@@ -143,7 +143,7 @@
- /tmp/test-chart/templates/configmap.yaml
- name: "Check if the subchart not exist in chart"
assert:
ansible.builtin.assert:
that:
- not stat_result.results[0].stat.exists
- stat_result.results[1].stat.exists
@@ -152,7 +152,7 @@
always:
- name: "Remove charts"
file:
ansible.builtin.file:
state: absent
path: "/tmp/{{ item }}"
loop:
@@ -5,12 +5,12 @@
chart_release_replaced_name: "test-{{ chart_name | default(source) }}-001"
block:
- name: Create temp directory
tempfile:
ansible.builtin.tempfile:
state: directory
register: tmpdir
- name: Set temp directory fact
set_fact:
ansible.builtin.set_fact:
temp_dir: "{{ tmpdir.path }}"
- name: Check helm_info empty
@@ -21,7 +21,7 @@
register: empty_info
- name: "Assert that no charts are installed with helm_info"
assert:
ansible.builtin.assert:
that:
- empty_info.status is undefined
@@ -36,7 +36,7 @@
register: install_fail
- name: "Assert that Install fail {{ chart_test }} from {{ source }}"
assert:
ansible.builtin.assert:
that:
- install_fail is failed
- "'Error: create: failed to create: namespaces \"' + helm_namespace + '\" not found' in install_fail.stderr"
@@ -53,7 +53,7 @@
check_mode: true
- name: "Assert that {{ chart_test }} chart is installed from {{ source }} in check mode"
assert:
ansible.builtin.assert:
that:
- install_check_mode is changed
- install_check_mode.status is defined
@@ -70,7 +70,7 @@
register: install
- name: "Assert that {{ chart_test }} chart version {{ chart_test_version }} is installed from {{ source }}"
assert:
ansible.builtin.assert:
that:
- install is changed
- install.status.chart == chart_test+"-"+chart_test_version
@@ -94,7 +94,7 @@
register: release_state_content_info
- name: "Assert that {{ chart_test }} chart version {{ chart_test_version }} is installed from {{ source }} with helm_info"
assert:
ansible.builtin.assert:
that:
- content_info.status.chart == chart_test+"-"+chart_test_version
- content_info.status.status | lower == 'deployed'
@@ -111,7 +111,7 @@
diff: true
- name: Assert idempotency
assert:
ansible.builtin.assert:
that:
- install is not changed
- install.status.chart == chart_test+"-"+chart_test_version
@@ -128,7 +128,7 @@
register: install
- name: "Assert that {{ chart_test }} chart is upgraded with new var from {{ source }}"
assert:
ansible.builtin.assert:
that:
- install is changed
- install.status.status | lower == 'deployed'
@@ -147,7 +147,7 @@
diff: true
- name: Assert idempotency after add vars
assert:
ansible.builtin.assert:
that:
- install is not changed
- install.status.status | lower == 'deployed'
@@ -164,7 +164,7 @@
register: install
- name: "Assert that {{ chart_test }} chart is upgraded with new var from {{ source }}"
assert:
ansible.builtin.assert:
that:
- install is changed
- install.status.status | lower == 'deployed'
@@ -182,7 +182,7 @@
diff: true
- name: Assert idempotency after removing vars
assert:
ansible.builtin.assert:
that:
- install is not changed
- install.status.status | lower == 'deployed'
@@ -199,7 +199,7 @@
register: install
- name: "Assert that {{ chart_test }} chart is upgraded with new version from {{ source }}"
assert:
ansible.builtin.assert:
that:
- install is changed
- install.status.status | lower == 'deployed'
@@ -216,7 +216,7 @@
diff: true
- name: Assert idempotency after upgrade
assert:
ansible.builtin.assert:
that:
- install is not changed
- install.status.status | lower == 'deployed'
@@ -231,7 +231,7 @@
register: install
- name: "Assert that {{ chart_test }} chart is removed from {{ source }}"
assert:
ansible.builtin.assert:
that:
- install is changed
@@ -245,7 +245,7 @@
diff: true
- name: Assert idempotency
assert:
ansible.builtin.assert:
that:
- install is not changed
@@ -260,7 +260,7 @@
register: install
- name: "Assert that {{ chart_test }} chart is installed from {{ source }}"
assert:
ansible.builtin.assert:
that:
- install is changed
@@ -269,12 +269,12 @@
binary_path: "{{ helm_binary }}"
state: absent
name: "{{ chart_release_replaced_name }}"
purge: False
purge: false
namespace: "{{ helm_namespace }}"
register: install
- name: Check if chart is removed
assert:
ansible.builtin.assert:
that:
- install is changed
@@ -285,11 +285,11 @@
chart_ref: "{{ chart_source }}"
chart_version: "{{ chart_test_version }}"
namespace: "{{ helm_namespace }}"
replace: True
replace: true
register: install
- name: "Assert that {{ chart_test }} chart is installed from {{ source }}"
assert:
ansible.builtin.assert:
that:
- install is changed
@@ -302,7 +302,7 @@
register: install
- name: Check if chart is removed
assert:
ansible.builtin.assert:
that:
- install is changed
@@ -318,7 +318,7 @@
register: install
- name: "Assert that {{ chart_test }} chart has var from {{ source }}"
assert:
ansible.builtin.assert:
that:
- install is changed
- install.status.status | lower == 'deployed'
@@ -337,7 +337,7 @@
register: install
- name: "Assert the result is consistent"
assert:
ansible.builtin.assert:
that:
- not (install is changed)
@@ -358,7 +358,7 @@
- "{{ role_path }}/files/values.yaml"
register: result
- assert:
- ansible.builtin.assert:
that:
- result is changed
- result is not failed
@@ -366,11 +366,11 @@
- result.command is match(helm_binary+" template "+chart_source)
- name: Check templates created
stat:
ansible.builtin.stat:
path: "{{ temp_dir }}/{{ chart_test }}/templates"
register: result
- assert:
- ansible.builtin.assert:
that:
result.stat.exists
@@ -379,7 +379,7 @@
binary_path: "{{ helm_binary }}"
chart_ref: "{{ chart_source }}"
chart_version: "{{ chart_test_version }}"
disable_hook: True
disable_hook: true
release_name: "myrelease"
release_namespace: "myreleasenamespace"
show_only:
@@ -389,7 +389,7 @@
register: result
when: chart_source is search("test-chart")
- assert:
- ansible.builtin.assert:
that:
- result is changed
- result is not failed
@@ -412,14 +412,14 @@
register: result
- name: Assert that release fails with non-existent context
assert:
ansible.builtin.assert:
that:
- result is failed
- "'context \"does-not-exist\" does not exist' in result.stderr"
always:
- name: Clean up temp dir
file:
ansible.builtin.file:
state: absent
path: "{{ temp_dir }}"
ignore_errors: true
@@ -1,3 +1,2 @@
---
helm_binary: "/tmp/helm/{{ ansible_system | lower }}-amd64/helm"
helm_namespace: helm-diff
@@ -1,5 +1,6 @@
---
dependencies:
- remove_namespace
- install_helm
- setup_helm_registry
- setup_helm
- setup_helm_version
@@ -1,7 +0,0 @@
---
- connection: local
gather_facts: true
hosts: localhost
roles:
- helm_diff
@@ -1,5 +0,0 @@
#!/usr/bin/env bash
set -eux
export ANSIBLE_CALLBACKS_ENABLED=profile_tasks
export ANSIBLE_ROLES_PATH=../
ansible-playbook playbook.yaml "$@"
@@ -1,4 +1,8 @@
---
- name: Define default value for helm binary path
ansible.builtin.set_fact:
helm_binary: "{{ setup_helm_binary_path | default('helm') }}"
- name: Test helm diff functionality
vars:
test_chart_ref: "/tmp/test-chart"
@@ -10,10 +14,11 @@
binary_path: "{{ helm_binary }}"
state: present
plugin_path: https://github.com/databus23/helm-diff
plugin_version: 3.9.13
verify: false
plugin_version: "{{ helm_version | string is ansible.builtin.version('4.0.0', '>=') | ternary('3.14.0', '3.10.0') }}"
- name: Copy test chart
copy:
ansible.builtin.copy:
src: "test-chart/"
dest: "{{ test_chart_ref }}"
@@ -26,13 +31,13 @@
create_namespace: true
register: install
- assert:
- ansible.builtin.assert:
that:
- install is changed
- name: Modify local chart
blockinfile:
create: yes
ansible.builtin.blockinfile:
create: true
path: "{{ test_chart_ref }}/templates/anothermap.yaml"
block: !unsafe |
apiVersion: v1
@@ -55,7 +60,7 @@
- name: Check if helm diff check is correct
vars:
foo_bar_value: "+ foo: bar"
assert:
ansible.builtin.assert:
that:
- foo_bar_value in diff_result.diff.prepared
@@ -67,7 +72,7 @@
chart_ref: "{{ test_chart_ref }}"
register: install
- assert:
- ansible.builtin.assert:
that:
- install is changed
@@ -77,12 +82,12 @@
name: test-chart
namespace: "{{ helm_namespace }}"
chart_ref: "{{ test_chart_ref }}"
check_mode: yes
check_mode: true
diff: true
register: diff_result
- name: Check if no diff in check mode when no change
assert:
ansible.builtin.assert:
that:
- '"diff" not in diff_result'
@@ -94,12 +99,12 @@
chart_ref: "{{ test_chart_ref }}"
register: install
- assert:
- ansible.builtin.assert:
that:
- install is not changed
- name: Modify values
blockinfile:
ansible.builtin.blockinfile:
create: true
path: "{{ test_chart_ref }}/values.yml"
block: |
@@ -116,7 +121,7 @@
- "{{ test_chart_ref }}/values.yml"
register: install
- assert:
- ansible.builtin.assert:
that:
- install is changed
@@ -130,7 +135,7 @@
- "{{ test_chart_ref }}/values.yml"
register: install
- assert:
- ansible.builtin.assert:
that:
- install is not changed
@@ -146,7 +151,7 @@
- "{{ test_chart_ref }}/values.yml"
register: install
- assert:
- ansible.builtin.assert:
that:
- install is changed
@@ -162,7 +167,7 @@
- "{{ test_chart_ref }}/values.yml"
register: install
- assert:
- ansible.builtin.assert:
that:
- install is not changed
@@ -181,7 +186,7 @@
value_type: string
register: install
- assert:
- ansible.builtin.assert:
that:
- install is changed
@@ -200,7 +205,7 @@
value_type: string
register: install
- assert:
- ansible.builtin.assert:
that:
- install is not changed
@@ -213,7 +218,7 @@
ignore_errors: true
- name: Define chart variables
set_fact:
ansible.builtin.set_fact:
test_chart_values:
myValue: 'Some ConfigMap data value'
myConfigmapName: 'ansible-config-from-url'
@@ -247,7 +252,9 @@
path: '{{ _tmpd.path }}'
- name: Log into Helm registry
ansible.builtin.command: "{{ helm_binary }} registry login -u testuser -p 'pass123!' localhost:6035"
ansible.builtin.shell: >-
echo 'pass123!' | {{ helm_binary }} registry login -u testuser --password-stdin localhost:6035
{{ helm_version | string is ansible.builtin.version("3.18.0", ">=") | ternary('--plain-http', '--insecure') }}
- name: Install chart from remote URL
helm:
@@ -257,6 +264,7 @@
namespace: "{{ helm_namespace }}"
name: another-chart
release_values: "{{ test_chart_values }}"
plain_http: "{{ helm_version | string is ansible.builtin.version('3.13.0', '>=') }}"
- name: Upgrade chart
helm:
@@ -266,44 +274,21 @@
namespace: "{{ helm_namespace }}"
name: another-chart
release_values: "{{ test_chart_values }}"
plain_http: "{{ helm_version | string is ansible.builtin.version('3.13.0', '>=') }}"
check_mode: true
register: _upgrade
- name: Assert that module raised a warning
assert:
ansible.builtin.assert:
that:
- not _upgrade.changed
- _upgrade.warnings is defined
- _upgrade.warnings | length == 1
- _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: 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 chart once again
helm:
binary_path: "{{ helm_binary }}"
chart_ref: "{{ test_chart_ref_url }}"
chart_version: 0.1.0
namespace: "{{ helm_namespace }}"
name: another-chart
release_values: "{{ test_chart_values }}"
check_mode: true
register: _upgrade_2
- name: Assert that module raised a warning
assert:
that:
- _upgrade_2.changed
- _upgrade_2.warnings is not defined
always:
- name: Remove chart directory
file:
ansible.builtin.file:
path: "{{ test_chart_ref }}"
state: absent
ignore_errors: true
@@ -324,6 +309,7 @@
wait: true
ignore_errors: true
- include_tasks: reuse_values.yml
- ansible.builtin.include_tasks: reuse_values.yml
- include_tasks: reset_then_reuse_values.yml
- ansible.builtin.include_tasks: reset_then_reuse_values.yml
when: helm_version | string is ansible.builtin.version('3.8.0', '>')
@@ -1,6 +1,6 @@
---
- name: Create temporary directory for helm chart
tempfile:
ansible.builtin.tempfile:
suffix: .helm
state: directory
register: helm_dir
@@ -16,7 +16,8 @@
binary_path: "{{ helm_binary }}"
state: present
plugin_path: https://github.com/databus23/helm-diff
plugin_version: 3.9.14
verify: false
plugin_version: "{{ helm_version | string is ansible.builtin.version('4.0.0', '>=') | ternary('3.14.0', '3.10.0') }}"
- name: Copy test chart
ansible.builtin.copy:
@@ -58,7 +59,7 @@
register: helm_upgrade
- name: Ensure task did not reported change
assert:
ansible.builtin.assert:
that:
- helm_upgrade is not changed
@@ -75,7 +76,7 @@
register: helm_upgrade
- name: Ensure task reported change
assert:
ansible.builtin.assert:
that:
- helm_upgrade is changed
@@ -88,19 +89,24 @@
ignore_errors: true
- name: Delete Helm folders
file:
ansible.builtin.file:
path: /tmp/helm/
state: absent
- name: Install old version of helm
ansible.builtin.include_role:
name: install_helm
name: setup_helm
vars:
helm_version: "v3.8.0"
setup_helm_version: "v3.8.0"
helm_install_path: "{{ helm_dir.path }}/helm_v3_8_0"
- name: Set path to helm binary v3.8.0
ansible.builtin.set_fact:
helm_binary_path_v3_8_0: "{{ helm_dir.path }}/helm_v3_8_0/helm"
- name: Upgrade helm release (with reset_then_reuse_values=true)
kubernetes.core.helm:
binary_path: "{{ helm_binary }}"
binary_path: "{{ helm_binary_path_v3_8_0 }}"
chart_ref: "{{ test_chart_path }}"
reuse_values: false
reset_then_reuse_values: true
@@ -112,25 +118,26 @@
ignore_errors: true
- name: Debug
debug:
ansible.builtin.debug:
var: helm_upgrade
- name: Ensure warning for Helm version
assert:
ansible.builtin.assert:
that:
- helm_upgrade is failed
- '"reset_then_reuse_values requires helm >= 3.14.0, current version is" in helm_upgrade.msg'
- name: Install helm diff
helm_plugin:
binary_path: "{{ helm_binary }}"
binary_path: "{{ helm_binary_path_v3_8_0 }}"
state: present
plugin_path: https://github.com/databus23/helm-diff
plugin_version: "3.8.0"
verify: false
- name: Upgrade helm release (with reset_then_reuse_values=true)
kubernetes.core.helm:
binary_path: "{{ helm_binary }}"
binary_path: "{{ helm_binary_path_v3_8_0 }}"
chart_ref: "{{ test_chart_path }}"
reuse_values: false
reset_then_reuse_values: true
@@ -142,23 +149,23 @@
ignore_errors: true
- name: Debug
debug:
ansible.builtin.debug:
var: helm_upgrade
- name: Ensure warning for Helm Diff version
assert:
ansible.builtin.assert:
that:
- helm_upgrade is failed
- '"reset_then_reuse_values requires helm diff >= 3.9.12, current version is" in helm_upgrade.msg'
always:
- name: Delete Helm folders
file:
ansible.builtin.file:
path: /tmp/helm/
state: absent
- name: Remove temporary directory
file:
ansible.builtin.file:
path: "{{ helm_dir.path }}"
state: absent
ignore_errors: true
@@ -1,6 +1,6 @@
---
- name: Create temporary directory for helm chart
tempfile:
ansible.builtin.tempfile:
suffix: .helm
state: directory
register: helm_dir
@@ -17,7 +17,8 @@
binary_path: "{{ helm_binary }}"
state: present
plugin_path: https://github.com/databus23/helm-diff
plugin_version: 3.9.4
verify: false
plugin_version: "{{ helm_version | string is ansible.builtin.version('4.0.0', '>=') | ternary('3.14.0', '3.10.0') }}"
- name: Copy test chart
ansible.builtin.copy:
@@ -50,7 +51,7 @@
register: helm_upgrade
- name: Ensure task did not reported change
assert:
ansible.builtin.assert:
that:
- helm_upgrade is not changed
@@ -66,7 +67,7 @@
register: helm_upgrade
- name: Ensure task reported change
assert:
ansible.builtin.assert:
that:
- helm_upgrade is changed
@@ -4,7 +4,4 @@ test_namespace:
- "helm-in-memory-kubeconfig"
- "helm-kubeconfig-with-ca-cert"
- "helm-kubeconfig-with-insecure-skip-tls-verify"
helm_versions:
- v3.10.3
- v3.16.4
- v4.0.0
helm_binary: helm
@@ -1,5 +1,2 @@
---
- ansible.builtin.include_tasks: run_tests.yml
loop: "{{ helm_versions }}"
loop_control:
loop_var: helm_version
@@ -1,10 +1,6 @@
---
- name: Run tests with helm version "{{ helm_version }}"
- name: Run tests
block:
- name: "Install Helm"
ansible.builtin.include_role:
name: install_helm
- name: Test helm with in-memory kubeconfig
ansible.builtin.include_tasks: "from_in_memory_kubeconfig.yml"
@@ -1,8 +1,4 @@
---
# Helm >= 4.2.1 is required for this test to be meaningful: that is the release which
# moved the OCI registry progress messages from stderr to stdout (helm/helm#32056).
helm_oci_version: v4.2.4
helm_oci_namespace: helm-oci-registry-progress
test_namespace: "{{ helm_oci_namespace }}"
@@ -18,3 +14,4 @@ helm_oci_chart_version: 1.0.0+build.1
# A version without build metadata, to cover the case where the progress messages
# happen to be valid YAML and so corrupt the parsed output silently.
helm_oci_chart_version_plain: 1.0.1
helm_binary: "helm"
@@ -2,3 +2,4 @@
dependencies:
- remove_namespace
- setup_helm_registry
- setup_helm_version
@@ -12,15 +12,12 @@
# messages. Without the fix, the helm task below fails with
# "could not find expected ':'".
- name: Test OCI charts whose version contains build metadata
# Helm >= 4.2.1 is required for this test to be meaningful: that is the release which
# moved the OCI registry progress messages from stderr to stdout (helm/helm#32056).
when: helm_version | string is ansible.builtin.version('4.2.1', '>=')
vars:
chart_ref: "oci://{{ helm_oci_registry }}/{{ helm_oci_repo_path }}/{{ helm_oci_chart_name }}"
block:
- name: "Install Helm {{ helm_oci_version }}"
ansible.builtin.include_role:
name: install_helm
vars:
helm_version: "{{ helm_oci_version }}"
- name: Create temporary directory to hold the chart
ansible.builtin.tempfile:
state: directory
@@ -1 +0,0 @@
redis*
@@ -0,0 +1,12 @@
---
helm_binary: helm
setup_helm_version_binary_path: "{{ helm_binary }}"
test_namespace: helm-plain-http
# Matches the plain-HTTP registry stood up by the setup_helm_registry role.
registry_host: "localhost:6035"
registry_username: testuser
registry_password: 'pass123!'
registry_repo_path: testing
chart_name: test-chart-plain-http
chart_version: "0.1.0"
@@ -0,0 +1,6 @@
apiVersion: v2
name: test-chart-plain-http
description: A minimal chart used to exercise plain_http against a plain-HTTP OCI registry
type: application
version: 0.1.0
appVersion: "default"
@@ -0,0 +1,6 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: test-chart-plain-http-configmap
data:
myValue: test
@@ -1,4 +0,0 @@
[all]
helm-3.12.3 helm_version=v3.12.3 test_namespace=helm-plain-http-v3-12-3 tests_should_failed=true
helm-3.18.2 helm_version=v3.18.2 test_namespace=helm-plain-http-v3-18-2 tests_should_failed=false
helm-4.0.0 helm_version=v4.0.0 test_namespace=helm-plain-http-v4-0-0 tests_should_failed=false
@@ -0,0 +1,5 @@
---
dependencies:
- setup_namespace
- setup_helm_registry
- setup_helm_version
@@ -1,15 +0,0 @@
- name: Run test for helm plain http option
hosts: all
gather_facts: true
strategy: free
vars:
ansible_connection: local
ansible_python_interpreter: "{{ ansible_playbook_python }}"
chart_test_oci: "oci://registry-1.docker.io/bitnamicharts/redis"
roles:
- role: setup_namespace
tasks:
- ansible.builtin.include_tasks: tasks/test.yaml
@@ -1,95 +0,0 @@
---
- name: Run test for helm
block:
- name: Create temporary directory to install chart In
ansible.builtin.tempfile:
state: directory
suffix: .helm
register: install_path
- name: Install required helm version
ansible.builtin.include_role:
name: install_helm
vars:
helm_install_path: "{{ install_path.path }}"
# helm
- name: Run helm with plain_http
kubernetes.core.helm:
binary_path: "{{ helm_binary }}"
chart_ref: "{{ chart_test_oci }}"
release_name: test-secure
release_namespace: "{{ test_namespace }}"
create_namespace: true
plain_http: true
register: install_chart
ignore_errors: true
- name: Ensure module failed as expected
ansible.builtin.assert:
that:
- install_chart is failed
- '"plain_http requires helm >= 3.13.0" in install_chart.msg'
when: tests_should_failed | bool
- name: Ensure the result command contains the expected option
ansible.builtin.assert:
that:
- install_chart is not failed
- '"--plain-http" in install_chart.command'
when: not (tests_should_failed | bool)
# helm_pull
- name: Trying to download helm chart with option plain_http
kubernetes.core.helm_pull:
chart_ref: "{{ chart_test_oci }}"
destination: "{{ playbook_dir }}"
binary_path: "{{ helm_binary }}"
plain_http: true
register: pull_chart
ignore_errors: true
- name: Ensure module failed as expected
ansible.builtin.assert:
that:
- pull_chart is failed
- '"plain_http requires helm >= 3.13.0" in pull_chart.msg'
when: tests_should_failed | bool
- name: Ensure the result command contains the expected option
ansible.builtin.assert:
that:
- pull_chart is not failed
- '"--plain-http" in pull_chart.command'
when: not (tests_should_failed | bool)
# helm_template
- name: Test helm render template
kubernetes.core.helm_template:
binary_path: "{{ helm_binary }}"
chart_ref: "{{ chart_test_oci }}"
output_dir: "{{ playbook_dir }}"
plain_http: true
register: template
ignore_errors: true
- name: Ensure module failed as expected
ansible.builtin.assert:
that:
- template is failed
- '"plain_http requires helm >= 3.13.0" in template.msg'
when: tests_should_failed | bool
- name: Ensure the result command contains the expected option
ansible.builtin.assert:
that:
- template is not failed
- '"--plain-http" in template.command'
when: not (tests_should_failed | bool)
always:
- name: Delete temporary file
ansible.builtin.file:
path: "{{ install_path.path }}"
state: absent
ignore_errors: true
@@ -1,4 +0,0 @@
#!/usr/bin/env bash
set -eux
export ANSIBLE_ROLES_PATH=../
ansible-playbook playbooks/play.yaml -i inventory.ini "$@"
@@ -0,0 +1,167 @@
---
- name: Test plain_http against a plain-HTTP OCI registry
vars:
plain_http_supported: "{{ helm_version | string is ansible.builtin.version('3.13.0', '>=') }}"
chart_ref_oci: "oci://{{ registry_host }}/{{ registry_repo_path }}/{{ chart_name }}"
block:
- name: Create a temporary directory to hold the chart
ansible.builtin.tempfile:
state: directory
suffix: .chart
register: _tmpd
# helm < 3.13.0 cannot talk to a plain-HTTP OCI registry: the modules reject
# plain_http before issuing any helm command, so no chart has to be present.
- name: Ensure plain_http is rejected on unsupported helm versions
when: not (plain_http_supported | bool)
block:
- name: Attempt helm install with plain_http
kubernetes.core.helm:
binary_path: "{{ helm_binary }}"
chart_ref: "{{ chart_ref_oci }}"
chart_version: "{{ chart_version }}"
release_name: test-secure
release_namespace: "{{ test_namespace }}"
create_namespace: true
plain_http: true
register: install_chart
ignore_errors: true
- name: Ensure helm failed with the version error
ansible.builtin.assert:
that:
- install_chart is failed
- '"plain_http requires helm >= 3.13.0" in install_chart.msg'
- name: Attempt helm_pull with plain_http
kubernetes.core.helm_pull:
chart_ref: "{{ chart_ref_oci }}"
chart_version: "{{ chart_version }}"
destination: "{{ _tmpd.path }}"
binary_path: "{{ helm_binary }}"
plain_http: true
register: pull_chart
ignore_errors: true
- name: Ensure helm_pull failed with the version error
ansible.builtin.assert:
that:
- pull_chart is failed
- '"plain_http requires helm >= 3.13.0" in pull_chart.msg'
- name: Attempt helm_template with plain_http
kubernetes.core.helm_template:
binary_path: "{{ helm_binary }}"
chart_ref: "{{ chart_ref_oci }}"
chart_version: "{{ chart_version }}"
plain_http: true
register: template
ignore_errors: true
- name: Ensure helm_template failed with the version error
ansible.builtin.assert:
that:
- template is failed
- '"plain_http requires helm >= 3.13.0" in template.msg'
# helm >= 3.13.0 exercises plain HTTP end to end against the registry stood up
# by the setup_helm_registry role, so the assertions prove the flag actually
# reaches a plain-HTTP registry rather than just appearing in the command.
- name: Exercise plain_http end to end
when: plain_http_supported | bool
block:
- name: Copy the test chart
ansible.builtin.copy:
src: "{{ chart_name }}"
dest: "{{ _tmpd.path }}/"
- name: Push the chart to the plain-HTTP registry
ansible.builtin.include_role:
name: push_to_helm_registry
vars:
chart_local_path: "{{ _tmpd.path }}/{{ chart_name }}"
chart_repo_path: "{{ registry_repo_path }}"
helm_binary_path: "{{ helm_binary }}"
- name: Log into the helm registry
ansible.builtin.shell: >-
echo '{{ registry_password }}' | {{ helm_binary }} registry login
-u {{ registry_username }} --password-stdin {{ registry_host }}
{{ helm_version | string is ansible.builtin.version('3.18.0', '>=') | ternary('--plain-http', '') }}
- name: Install the chart over plain HTTP
kubernetes.core.helm:
binary_path: "{{ helm_binary }}"
chart_ref: "{{ chart_ref_oci }}"
chart_version: "{{ chart_version }}"
release_name: test-secure
release_namespace: "{{ test_namespace }}"
create_namespace: true
plain_http: true
register: install_chart
- name: Ensure the release installed over plain HTTP
ansible.builtin.assert:
that:
- install_chart is changed
- '"--plain-http" in install_chart.command'
- name: Pull the chart over plain HTTP
kubernetes.core.helm_pull:
chart_ref: "{{ chart_ref_oci }}"
chart_version: "{{ chart_version }}"
destination: "{{ _tmpd.path }}"
binary_path: "{{ helm_binary }}"
plain_http: true
register: pull_chart
- name: Ensure the chart was pulled over plain HTTP
ansible.builtin.assert:
that:
- pull_chart is not failed
- '"--plain-http" in pull_chart.command'
- name: Render the chart over plain HTTP
kubernetes.core.helm_template:
binary_path: "{{ helm_binary }}"
chart_ref: "{{ chart_ref_oci }}"
chart_version: "{{ chart_version }}"
plain_http: true
register: template
- name: Ensure the chart rendered over plain HTTP
ansible.builtin.assert:
that:
- template is not failed
- '"--plain-http" in template.command'
- "'kind: ConfigMap' in template.stdout"
always:
- name: Uninstall the release
kubernetes.core.helm:
binary_path: "{{ helm_binary }}"
release_name: test-secure
release_namespace: "{{ test_namespace }}"
state: absent
when: plain_http_supported | bool
ignore_errors: true
- name: Remove the test namespace
kubernetes.core.k8s:
api_version: v1
kind: Namespace
name: "{{ test_namespace }}"
state: absent
wait: true
ignore_errors: true
- name: Log out of the helm registry
ansible.builtin.command: "{{ helm_binary }} registry logout {{ registry_host }}"
when: plain_http_supported | bool
ignore_errors: true
- name: Remove the temporary directory
ansible.builtin.file:
path: "{{ _tmpd.path }}"
state: absent
ignore_errors: true
@@ -1,2 +1,2 @@
---
helm_binary: "/tmp/helm/{{ ansible_system | lower }}-amd64/helm"
helm_binary: "helm"
@@ -1,7 +0,0 @@
---
- connection: local
gather_facts: true
hosts: localhost
roles:
- helm_plugin
@@ -1,5 +0,0 @@
#!/usr/bin/env bash
set -eux
export ANSIBLE_CALLBACKS_ENABLED=profile_tasks
export ANSIBLE_ROLES_PATH=../
ansible-playbook playbook.yaml "$@"
@@ -1,8 +1,3 @@
---
- name: Run tests
include_tasks: run_tests.yml
loop_control:
loop_var: helm_version
with_items:
- "v3.17.0"
- "v4.0.0"
ansible.builtin.include_tasks: run_tests.yml
@@ -1,8 +1,4 @@
---
- name: "Install {{ helm_version }}"
include_role:
name: install_helm
- block:
- name: Install env plugin in check mode
helm_plugin:
@@ -13,7 +9,7 @@
register: check_install_env
check_mode: true
- assert:
- ansible.builtin.assert:
that:
- check_install_env.changed
@@ -25,7 +21,7 @@
verify: false
register: install_env
- assert:
- ansible.builtin.assert:
that:
- install_env.changed
@@ -34,7 +30,7 @@
binary_path: "{{ helm_binary }}"
register: plugin_info
- assert:
- ansible.builtin.assert:
that:
- plugin_info.plugin_list is defined
@@ -46,7 +42,7 @@
verify: false
register: install_env
- assert:
- ansible.builtin.assert:
that:
- not install_env.changed
@@ -59,7 +55,7 @@
register: check_uninstall_env
check_mode: true
- assert:
- ansible.builtin.assert:
that:
- check_uninstall_env.changed
@@ -70,7 +66,7 @@
plugin_name: env
register: uninstall_env
- assert:
- ansible.builtin.assert:
that:
- uninstall_env.changed
@@ -81,7 +77,7 @@
plugin_name: env
register: uninstall_env
- assert:
- ansible.builtin.assert:
that:
- not uninstall_env.changed
@@ -95,7 +91,7 @@
# https://github.com/ansible-collections/community.kubernetes/issues/399
- block:
- name: Copy required plugin files
copy:
ansible.builtin.copy:
src: "files/sample_plugin"
dest: "/tmp/helm_plugin_test/"
@@ -107,7 +103,7 @@
register: sample_plugin_output
- name: Assert that sample_plugin is installed or not
assert:
ansible.builtin.assert:
that:
- sample_plugin_output.changed
@@ -117,13 +113,13 @@
register: r
- name: Set sample_plugin version
set_fact:
ansible.builtin.set_fact:
plugin_version: "{{ ( r.plugin_list | selectattr('name', 'equalto', plugin_name) | list )[0].version }}"
vars:
plugin_name: "sample_plugin"
- name: Assert if sample_plugin with multiline comment is installed
assert:
ansible.builtin.assert:
that:
- plugin_version == "0.0.1"
always:
@@ -156,7 +152,7 @@
register: plugin_list
- name: assert that unittest has been installed with specified version
assert:
ansible.builtin.assert:
that:
- plugin_list.plugin_list[0].version == "1.0.1"
@@ -169,7 +165,7 @@
check_mode: true
- name: Assert that module reported change while running in check mode
assert:
ansible.builtin.assert:
that:
- _update_checkmode.changed
- '"Updated plugin: unittest" not in _update_checkmode.stdout'
@@ -181,8 +177,8 @@
state: latest
register: _update
- name: assert update was performed
assert:
- name: Assert update was performed
ansible.builtin.assert:
that:
- _update.changed
- '"Updated plugin: unittest" in _update.stdout'
@@ -0,0 +1,2 @@
---
helm_binary: helm
@@ -0,0 +1,3 @@
---
dependencies:
- setup_helm_version
@@ -1,7 +0,0 @@
---
- connection: local
gather_facts: true
hosts: localhost
roles:
- helm_pull
@@ -1,5 +0,0 @@
#!/usr/bin/env bash
set -eux
export ANSIBLE_CALLBACKS_ENABLED=profile_tasks
export ANSIBLE_ROLES_PATH=../
ansible-playbook playbook.yaml "$@"
@@ -1,101 +1,83 @@
---
- name: Define helm versions to test
set_fact:
helm_versions:
- 3.8.0
- 3.1.0
- 3.0.0
- 4.0.0
- block:
- name: Create temp directory for helm tests
tempfile:
ansible.builtin.tempfile:
state: directory
register: tmpdir
- name: Set temp directory fact
set_fact:
ansible.builtin.set_fact:
temp_dir: "{{ tmpdir.path }}"
- set_fact:
destination: "{{ temp_dir }}"
- name: Install Helm versions
ansible.builtin.include_role:
name: install_helm
loop: "{{ helm_versions }}"
vars:
helm_version: "v{{ item }}"
helm_install_path: "{{ temp_dir }}/{{ item }}"
# Testing helm pull with helm version == 3.0.0
- block:
- name: Run test with helm version '3.0.0'
when: helm_version | string is ansible.builtin.version('3.0.0', "==")
block:
- name: Download chart using chart_ssl_cert_file
helm_pull:
binary_path: "{{ helm_path }}"
binary_path: "{{ helm_binary }}"
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
destination: "{{ destination }}"
destination: "{{ temp_dir }}"
chart_ssl_cert_file: ssl_cert_file
ignore_errors: true
check_mode: true
register: _result
- name: assert that module failed with proper message
assert:
- name: Assert that module failed with proper message
ansible.builtin.assert:
that:
- _result is failed
- _result.msg == "Parameter chart_ssl_cert_file requires helm >= 3.1.0, current version is 3.0.0"
- name: Download chart using chart_ssl_key_file
helm_pull:
binary_path: "{{ helm_path }}"
binary_path: "{{ helm_binary }}"
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
destination: "{{ destination }}"
destination: "{{ temp_dir }}"
chart_ssl_key_file: ssl_key_file
ignore_errors: true
check_mode: true
register: _result
- name: assert that module failed with proper message
assert:
ansible.builtin.assert:
that:
- _result is failed
- _result.msg == "Parameter chart_ssl_key_file requires helm >= 3.1.0, current version is 3.0.0"
- name: Download chart using chart_ca_cert
helm_pull:
binary_path: "{{ helm_path }}"
binary_path: "{{ helm_binary }}"
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
destination: "{{ destination }}"
destination: "{{ temp_dir }}"
chart_ca_cert: ca_cert_file
ignore_errors: true
check_mode: true
register: _result
- name: assert that module failed with proper message
assert:
- name: Assert that module failed with proper message
ansible.builtin.assert:
that:
- _result is failed
- _result.msg == "Parameter chart_ca_cert requires helm >= 3.1.0, current version is 3.0.0"
vars:
helm_path: "{{ temp_dir }}/3.0.0/helm"
# Testing helm pull with helm version == 3.1.0
- block:
- name: Run test with helm version '3.1.0'
when: helm_version | string is ansible.builtin.version('3.1.0', "==")
block:
- name: Download chart using chart_ssl_cert_file, chart_ca_cert, chart_ssl_key_file
helm_pull:
binary_path: "{{ helm_path }}"
binary_path: "{{ helm_binary }}"
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
destination: "{{ destination }}"
destination: "{{ temp_dir }}"
chart_ssl_cert_file: ssl_cert_file
chart_ssl_key_file: ssl_key_file
chart_ca_cert: ca_cert_file
check_mode: true
register: _result
- name: assert that module failed with proper message
assert:
- name: Assert that module failed with proper message
ansible.builtin.assert:
that:
- _result is changed
- '"--ca-file ca_cert_file" in _result.command'
@@ -104,32 +86,31 @@
- name: Download chart using skip_tls_certs_check
helm_pull:
binary_path: "{{ helm_path }}"
binary_path: "{{ helm_binary }}"
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
destination: "{{ destination }}"
destination: "{{ temp_dir }}"
skip_tls_certs_check: true
ignore_errors: true
check_mode: true
register: _result
- name: assert that module failed with proper message
assert:
- name: Assert that module failed with proper message
ansible.builtin.assert:
that:
- _result is failed
- _result.msg == "Parameter skip_tls_certs_check requires helm >= 3.3.0, current version is 3.1.0"
vars:
helm_path: "{{ temp_dir }}/3.1.0/helm"
# Testing helm pull with helm version == 3.8.0
- block:
- name: Run test with helm version '3.8.0'
when: helm_version | string is ansible.builtin.version('3.8.0', "==")
block:
# Test options chart_version, verify, pass-credentials, provenance, untar_chart
# skip_tls_certs_check, repo_url, repo_username, repo_password
- name: Testing chart version
helm_pull:
binary_path: "{{ helm_path }}"
binary_path: "{{ helm_binary }}"
chart_ref: redis
destination: "{{ destination }}"
destination: "{{ temp_dir }}"
chart_version: "0.2.1"
verify_chart: true
pass_credentials: true
@@ -143,7 +124,8 @@
check_mode: true
register: _result
- assert:
- name: Validate module results
ansible.builtin.assert:
that:
- _result is changed
- '"--version 0.2.1" in _result.command'
@@ -154,24 +136,24 @@
- '"--insecure-skip-tls-verify" in _result.command'
- '"--repo https://charts.bitnami.com/bitnami" in _result.command'
- '"--username ansible" in _result.command'
- '"--password ***" in _result.command'
- '"--password " in _result.command' # can be followed by '***' or '$REDACTED$'
- '"--keyring pubring.gpg" in _result.command'
- '"Module did not set no_log for pass_credentials" not in _result.stderr'
- name: Download chart using chart_ref
helm_pull:
binary_path: "{{ helm_path }}"
binary_path: "{{ helm_binary }}"
chart_ref: https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz
destination: "{{ destination }}"
destination: "{{ temp_dir }}"
register: _result
- name: Check chart on local filesystem
stat:
path: "{{ destination }}/grafana-5.6.0.tgz"
ansible.builtin.stat:
path: "{{ temp_dir }}/grafana-5.6.0.tgz"
register: _chart
- name: Validate that chart was downloaded
assert:
ansible.builtin.assert:
that:
- _result is changed
- _chart.stat.exists
@@ -179,19 +161,19 @@
- name: Download chart using untar_chart
helm_pull:
binary_path: "{{ helm_path }}"
binary_path: "{{ helm_binary }}"
chart_ref: "oci://registry-1.docker.io/bitnamicharts/redis"
destination: "{{ destination }}"
destination: "{{ temp_dir }}"
untar_chart: true
register: _result
- name: Check chart on local filesystem
stat:
path: "{{ destination }}/redis"
ansible.builtin.stat:
path: "{{ temp_dir }}/redis"
register: _chart
- name: Validate that chart was downloaded
assert:
ansible.builtin.assert:
that:
- _result is changed
- _chart.stat.exists
@@ -200,22 +182,22 @@
# Test idempotency with tarred chart
- name: Download chart with version (first time)
helm_pull:
binary_path: "{{ helm_path }}"
binary_path: "{{ helm_binary }}"
chart_ref: "oci://registry-1.docker.io/bitnamicharts/redis"
destination: "{{ destination }}"
destination: "{{ temp_dir }}"
chart_version: "24.1.0"
register: _result_first
- name: Download chart with version (second time - should be idempotent)
helm_pull:
binary_path: "{{ helm_path }}"
binary_path: "{{ helm_binary }}"
chart_ref: "oci://registry-1.docker.io/bitnamicharts/redis"
destination: "{{ destination }}"
destination: "{{ temp_dir }}"
chart_version: "24.1.0"
register: _result_second
- name: Validate idempotency for tarred chart
assert:
ansible.builtin.assert:
that:
- _result_first is changed
- _result_second is not changed
@@ -223,81 +205,77 @@
# Test force parameter with tarred chart
- name: Download chart with force=true (should always download)
helm_pull:
binary_path: "{{ helm_path }}"
binary_path: "{{ helm_binary }}"
chart_ref: "oci://registry-1.docker.io/bitnamicharts/redis"
destination: "{{ destination }}"
destination: "{{ temp_dir }}"
chart_version: "24.1.0"
force: true
register: _result_force
- name: Validate force parameter causes download
assert:
ansible.builtin.assert:
that:
- _result_force is changed
# Test idempotency with untarred chart in the separate folder
- name: Create separate directory for untar test under {{ temp_dir }}
ansible.builtin.file:
path: "{{ destination }}/untar_test"
path: "{{ temp_dir }}/untar_test"
state: directory
mode: '0755'
- name: Download and untar chart (first time)
helm_pull:
binary_path: "{{ helm_path }}"
binary_path: "{{ helm_binary }}"
chart_ref: "oci://registry-1.docker.io/bitnamicharts/redis"
destination: "{{ destination }}/untar_test"
destination: "{{ temp_dir }}/untar_test"
chart_version: "24.0.0"
untar_chart: true
register: _result_untar_first
- name: Download and untar chart (second time - should be idempotent)
helm_pull:
binary_path: "{{ helm_path }}"
binary_path: "{{ helm_binary }}"
chart_ref: "oci://registry-1.docker.io/bitnamicharts/redis"
destination: "{{ destination }}/untar_test"
destination: "{{ temp_dir }}/untar_test"
chart_version: "24.0.0"
untar_chart: true
register: _result_untar_second
- name: Validate idempotency for untarred chart
assert:
ansible.builtin.assert:
that:
- _result_untar_first is changed
- _result_untar_second is not changed
- name: Download and untar chart with force=true (should remove existing directory and re-extract)
helm_pull:
binary_path: "{{ helm_path }}"
binary_path: "{{ helm_binary }}"
chart_ref: "oci://registry-1.docker.io/bitnamicharts/redis"
destination: "{{ destination }}/untar_test"
destination: "{{ temp_dir }}/untar_test"
chart_version: "24.0.0"
untar_chart: true
force: true
register: _result_untar_force
- name: Validate first force extraction works
assert:
ansible.builtin.assert:
that:
- _result_untar_force is changed
- name: Verify chart directory still exists after force re-extraction
stat:
path: "{{ destination }}/untar_test/redis"
ansible.builtin.stat:
path: "{{ temp_dir }}/untar_test/redis"
register: _chart_after_force
- name: Validate chart directory exists
assert:
ansible.builtin.assert:
that:
- _chart_after_force.stat.exists
- _chart_after_force.stat.isdir
vars:
helm_path: "{{ temp_dir }}/3.8.0/helm"
always:
- name: Delete temp directory
file:
ansible.builtin.file:
state: absent
path: "{{ temp_dir }}"
@@ -7,7 +7,4 @@ wrong_password: 'WrongPassword'
registry_name: oci_registry
registry_port: 5002
test_chart: https://github.com/grafana/helm-charts/releases/download/k8s-monitoring-1.6.8/k8s-monitoring-1.6.8.tgz
helm_versions:
- v3.17.0
- v3.20.0
- v4.0.0
helm_binary: helm
@@ -0,0 +1,3 @@
---
dependencies:
- setup_helm_version
@@ -1,7 +0,0 @@
---
- name: Test helm_registry_auth module
hosts: localhost
connection: local
gather_facts: true
roles:
- helm_registry_auth
@@ -1,5 +0,0 @@
#!/usr/bin/env bash
set -eux
export ANSIBLE_CALLBACKS_ENABLED=profile_tasks
export ANSIBLE_ROLES_PATH=../
ansible-playbook playbook.yaml "$@"
@@ -44,9 +44,6 @@
- name: Run tests
ansible.builtin.include_tasks: run_tests.yml
loop: "{{ helm_versions }}"
loop_control:
loop_var: helm_version
always:
- name: Stop and remove the registry
@@ -1,9 +1,5 @@
---
- block:
- name: Install helm versions
ansible.builtin.include_role:
name: install_helm
# - name: Test the registry with correct credentials to ensure that the registry is running
# ansible.builtin.shell: >-
# echo {{ password | quote }} | {{ helm_binary }} registry login localhost:{{ registry_port }}
@@ -31,7 +27,7 @@
# Helm < 4.2.1 prints success messages to stderr (https://github.com/helm/helm/issues/13464),
# Helm >= 4.2.1 moves them to stdout (https://github.com/helm/helm/pull/32056).
# Check both streams to stay version-agnostic.
assert:
ansible.builtin.assert:
that:
- "'Login Succeeded' in _helm_registry_auth_correct.stdout_lines + _helm_registry_auth_correct.stderr_lines"
- password not in _helm_registry_auth_correct.command
@@ -48,7 +44,7 @@
# Helm < 4.2.1 prints success messages to stderr (https://github.com/helm/helm/issues/13464),
# Helm >= 4.2.1 moves them to stdout (https://github.com/helm/helm/pull/32056).
# Check both streams to stay version-agnostic.
assert:
ansible.builtin.assert:
that: "'Pushed: localhost:' + registry_port | string + '/test/k8s-monitoring' in _save_chart.stdout + _save_chart.stderr"
- name: Test logout
@@ -62,7 +58,7 @@
# Helm < 4.2.1 prints success messages to stderr (https://github.com/helm/helm/issues/13464),
# Helm >= 4.2.1 moves them to stdout (https://github.com/helm/helm/pull/32056).
# Check both streams to stay version-agnostic.
assert:
ansible.builtin.assert:
that: "'Removing login credentials' in _helm_registry_auth_logout.stdout + _helm_registry_auth_logout.stderr"
- name: Ensure that not able to push to the registry
@@ -79,7 +75,7 @@
- "_save_chart.rc != 0"
- name: Test idempotency of logout with helm < 3.18.0
when: helm_version is ansible.builtin.version('v3.18.0', '<')
when: helm_version | string is ansible.builtin.version('3.18.0', '<')
block:
- name: Test logout idempotency
@@ -1,5 +1,3 @@
---
chart_test_repo: "https://kubernetes.github.io/ingress-nginx"
helm_versions:
- v3.20.0
- v4.0.0
helm_binary: helm
@@ -1,7 +0,0 @@
---
- connection: local
gather_facts: true
hosts: localhost
roles:
- helm_repository
@@ -1,5 +0,0 @@
#!/usr/bin/env bash
set -eux
export ANSIBLE_CALLBACKS_ENABLED=profile_tasks
export ANSIBLE_ROLES_PATH=../
ansible-playbook playbook.yaml "$@"
@@ -1,6 +1,3 @@
---
- name: Run test for helm_repository module
ansible.builtin.include_tasks: run_tests.yml
loop: "{{ helm_versions }}"
loop_control:
loop_var: helm_version
@@ -1,8 +1,4 @@
---
- name: "Install helm version {{ helm_version }}"
ansible.builtin.include_role:
name: install_helm
- name: "Ensure test_helm_repo doesn't exist"
helm_repository:
binary_path: "{{ helm_binary }}"
@@ -17,7 +13,7 @@
register: repository
- name: Assert that test_helm_repo repository is added
assert:
ansible.builtin.assert:
that:
- repository is changed
- '"--insecure-skip-tls-verify" not in repository.command'
@@ -30,7 +26,7 @@
register: repository
- name: Assert idempotency
assert:
ansible.builtin.assert:
that:
- repository is not changed
@@ -43,7 +39,7 @@
ignore_errors: true
- name: Assert that adding repository with the same name failed
assert:
ansible.builtin.assert:
that:
- repository_errors is failed
@@ -56,7 +52,7 @@
register: repository
- name: Assert that test_helm_repo repository is changed
assert:
ansible.builtin.assert:
that:
- repository is changed
@@ -68,7 +64,7 @@
register: repository
- name: Assert that test_helm_repo repository is removed
assert:
ansible.builtin.assert:
that:
- repository is changed
@@ -80,7 +76,7 @@
register: repository
- name: Assert idempotency
assert:
ansible.builtin.assert:
that:
- repository is not changed
@@ -93,7 +89,7 @@
register: repository
- name: Assert that repository added and flag set
assert:
ansible.builtin.assert:
that:
- repository is changed
- '"--insecure-skip-tls-verify" in repository.command'
@@ -1,5 +1,3 @@
---
helm_namespace: helm-set-values
helm_versions:
- v3.10.3
- v4.0.0
helm_binary: helm
@@ -1,4 +1,3 @@
---
dependencies:
- remove_namespace
- install_helm
@@ -1,7 +0,0 @@
---
- connection: local
gather_facts: true
hosts: localhost
roles:
- helm_set_values
@@ -1,5 +0,0 @@
#!/usr/bin/env bash
set -eux
export ANSIBLE_CALLBACKS_ENABLED=profile_tasks
export ANSIBLE_ROLES_PATH=../
ansible-playbook playbook.yaml "$@"
@@ -1,4 +1,4 @@
- name: Install helm using set_values parameters
- name: Install helm chart using set_values parameters
helm:
binary_path: "{{ helm_binary }}"
chart_ref: oci://registry-1.docker.io/bitnamicharts/mariadb
@@ -18,7 +18,7 @@
register: user_values
- name: Assert that release was created with user-defined variables
assert:
ansible.builtin.assert:
that:
- '"phase" in user_values.status["release_values"]'
- '"versioned" in user_values.status["release_values"]'
@@ -27,16 +27,15 @@
- block:
- name: create temporary file to save values in
tempfile:
ansible.builtin.tempfile:
suffix: .yml
register: ymlfile
- ansible.builtin.include_tasks: run_tests.yml
loop: "{{ helm_versions }}"
always:
- name: Delete temporary file
file:
ansible.builtin.file:
state: absent
path: "{{ ymlfile.path }}"
ignore_errors: true
@@ -1,16 +1,9 @@
---
# install chart using set_values and release_values
- name: 'Install helm binary (> 3.10.0) requires to use set-json (helm_version={{ item }})'
include_role:
name: install_helm
vars:
helm_version: "{{ item }}"
- name: Install helm using set_values parameters
- name: Install helm chart using set_values parameters
helm:
binary_path: "{{ helm_binary }}"
chart_ref: oci://registry-1.docker.io/bitnamicharts/apache
release_name: 'test-apache-{{ item }}'
release_name: 'test-apache'
release_namespace: "{{ helm_namespace }}"
create_namespace: true
set_values:
@@ -22,12 +15,12 @@
- name: Get release info
helm_info:
binary_path: "{{ helm_binary }}"
release_name: 'test-apache-{{ item }}'
release_name: 'test-apache'
release_namespace: "{{ helm_namespace }}"
register: values
- name: Assert that release was created with user-defined variables
assert:
ansible.builtin.assert:
that:
- values.status["release_values"].replicaCount == 3
- values.status["release_values"].master.image.registry == "docker.io"
@@ -35,8 +28,8 @@
- values.status["release_values"].master.image.tag == "2.4.54-debian-11-r74"
# install chart using set_values and values_files
- name: copy content into values file
copy:
- name: Copy content into values file
ansible.builtin.copy:
content: |
---
mode: distributed
@@ -46,7 +39,7 @@
helm:
binary_path: "{{ helm_binary }}"
chart_ref: oci://registry-1.docker.io/bitnamicharts/minio
release_name: 'test-minio-{{ item }}'
release_name: 'test-minio'
release_namespace: "{{ helm_namespace }}"
create_namespace: true
set_values:
@@ -57,12 +50,12 @@
- name: Get release info
helm_info:
binary_path: "{{ helm_binary }}"
release_name: 'test-minio-{{ item }}'
release_name: 'test-minio'
release_namespace: "{{ helm_namespace }}"
register: values
- name: Assert that release was created with user-defined variables
assert:
ansible.builtin.assert:
that:
- values.status["release_values"].mode == "distributed"
- values.status["release_values"].disableWebUI is true
@@ -0,0 +1,3 @@
time=40
helm
helm_info
@@ -0,0 +1,3 @@
---
helm_binary: helm
helm_namespace: helm-uninstall
@@ -0,0 +1,4 @@
---
dependencies:
- remove_namespace
- setup_helm_version
@@ -0,0 +1,90 @@
- vars:
chart_source: "https://github.com/kubernetes/kube-state-metrics/releases/download/kube-state-metrics-helm-chart-2.13.3/kube-state-metrics-2.13.3.tgz"
chart_name: "test-wait-uninstall"
chart_name_pending: "test-uninstall-pending-release"
block:
- name: Install chart
helm:
binary_path: "{{ helm_binary }}"
name: "{{ chart_name }}"
chart_ref: "{{ chart_source }}"
namespace: "{{ helm_namespace }}"
create_namespace: true
- name: Delete chart with wait
helm:
state: absent
binary_path: "{{ helm_binary }}"
name: "{{ chart_name }}"
namespace: "{{ helm_namespace }}"
wait: true
register: uninstall
- name: Assert chart was uninstalled
ansible.builtin.assert:
that:
- uninstall is changed
- when: helm_version | string is ansible.builtin.version('4.0.0', '<')
block:
- name: Install Helm v4
ansible.builtin.include_role:
name: setup_helm
vars:
setup_helm_version: v4.0.0
- name: Install chart
helm:
binary_path: "{{ setup_helm_binary_path }}"
name: "{{ chart_name }}"
chart_ref: "{{ chart_source }}"
namespace: "{{ helm_namespace }}"
create_namespace: true
- name: Uninstall chart again using recent version
helm:
state: absent
binary_path: "{{ setup_helm_binary_path }}"
name: "{{ chart_name }}"
namespace: "{{ helm_namespace }}"
wait: true
register: uninstall
# Test uninstall chart release with 'pending-install' status
- name: Create chart release with 'pending-install' status
helm_test_pending:
binary_path: "{{ setup_helm_binary_path }}"
chart_ref: "{{ chart_source }}"
chart_release: "{{ chart_name_pending }}"
chart_release_namespace: "{{ helm_namespace }}"
- name: Uninstall chart release with 'pending-install' status
helm:
binary_path: "{{ setup_helm_binary_path }}"
release_name: "{{ chart_name_pending }}"
namespace: "{{ helm_namespace }}"
release_state: absent
register: _uninstall
- name: Get Helm release details
helm_info:
binary_path: "{{ setup_helm_binary_path }}"
release_namespace: "{{ helm_namespace }}"
release_state: pending
release_name: "{{ chart_name_pending }}"
register: _info
- name: Assert release does not exist anymore
ansible.builtin.assert:
that:
- _uninstall is changed
- _info.status is undefined
always:
- name: Remove namespace
k8s:
kind: Namespace
name: "{{ helm_namespace }}"
state: absent
ignore_errors: true

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