* 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>
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.
* 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>
* 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>
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.
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.
Fixesansible-collections/kubernetes.core#1201
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* 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>
* 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>
* 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>
* 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>
* 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>
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>
* 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>
* 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>
* 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
* 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
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
* 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
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
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
* 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>
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
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.
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>
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
#
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
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>
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>