Compare commits

..
35 Commits
Author SHA1 Message Date
3ef0b05928 [PR #1268/177297fd backport][stable-5] Resolve ansible-test sanity validation errors (#1270)
* fix(sanity): resolve ansible-test devel validation errors (#1268)

(cherry picked from commit 177297fdae)

* chore: remove invalid ignore statement

---------

Co-authored-by: Don Naro <dnaro@redhat.com>
2026-09-22 10:36:58 +01:00
747964cefe 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>
2026-09-15 13:55:57 -07:00
d7b53d0464 :fix(helm_repository): normalize both sides of the repo URL comparison (#1236) (#1259)
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

(cherry picked from commit 094240ab77)

Co-authored-by: Yuriy Novostavskiy <yuriy@novostavskiy.kyiv.ua>
2026-09-15 11:03:54 -07:00
14712d57a7 [PR #1253/c46180bb backport][stable-5] Add ansible-core version check to k8s lookup turbo mode (#1255)
* 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>
(cherry picked from commit c46180bb6f)

* fix: make the linter happy

---------

Co-authored-by: Don Naro <dnaro@redhat.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-09-15 17:21:16 +01:00
51f0386633 Add deprecation warnings for the status.values return value (#1241) (#1257)
* chore: add deprecation warning for status.values

* docs: add changelog entries for status.values deprecation

(cherry picked from commit f42c78ce83)

Co-authored-by: Don Naro <dnaro@redhat.com>
2026-09-15 08:52:06 -07:00
8c0de50fb8 **This is a manual backport of PR #1242 as merged into main ([031bc47](https://github.com/ansible-collections/kubernetes.core/commit/031bc475fadd0fcf8152d3c9083e22a77e3d870d)).** (#1251)
Emit an explicit deprecation warning when users enable Ansible Turbo mode via `ENABLE_TURBO_MODE`, and stop turbo mode from being used on ansible-core versions where `cloud.common` is not supported.

Turbo mode depends on `cloud.common`, which is being retired. PR #1120 already deprecated the `cloud.common` dependency; without this change, removing that dependency later would cause `ENABLE_TURBO_MODE` to stop working silently. This PR warns users at runtime so they can migrate before support is removed in `kubernetes.core` 8.0.0.

Changes:

* Modules: emit the deprecation at import time via the module-level `deprecate()` in `plugins/module_utils/ansiblemodule.py`. `AnsibleTurboModule.__init__()` ends in `run_on_daemon()`, which calls `exit_json()` and exits the process, so a `deprecate()` call tied to instance construction is never reached.
* Modules: skip turbo mode on ansible-core >= 2.19.0 and fall back to the standard `AnsibleModule`, emitting a warning. `cloud.common` declares `requires_ansible '>=2.15.0,<2.19'`, but that is only enforced at collection load time and the turbo import itself still succeeds on newer cores, so turbo mode would otherwise fail later with `byte indices must be integers or slices, not str`.
* Modules and lookup: warn instead of silently falling back when `ENABLE_TURBO_MODE` is set but `cloud.common` is not installed.
* Lookup: call `Display.deprecated()` in the `k8s` lookup when turbo mode is enabled. The lookup path still works on >= 2.19, so it keeps using turbo and is not version-gated.
* Docs: add deprecation notices to `README.md` and `docs/ansible_turbo_mode.rst`.
* Changelog: add `deprecated_features`, `bugfixes`, and `minor_changes` fragment entries.

On ansible-core < 2.19 with `cloud.common` installed, turbo mode continues to work exactly as before and only gains a deprecation warning. On ansible-core >= 2.19 turbo mode is now deliberately bypassed, which replaces a confusing traceback with a clear warning.

* Bugfix Pull Request
* Docs Pull Request

`ENABLE_TURBO_MODE` / Ansible Turbo mode

On a supported ansible-core (< 2.19) with `cloud.common` installed, turbo mode stays active and users see:

```
[DEPRECATION WARNING]: ENABLE_TURBO_MODE is deprecated, as it relies on the cloud.common collection which is being retired. Setting this environment variable will have no effect once support is removed. This feature will be removed from kubernetes.core in version 8.0.0.
```

On ansible-core >= 2.19.0, turbo mode is bypassed and an additional warning is emitted:

```
[WARNING]: ENABLE_TURBO_MODE is ignored on ansible-core 2.21.4: Ansible Turbo mode requires the cloud.common collection, which supports ansible-core < 2.19.0 only. Continuing without Turbo mode.
```

Warnings are emitted from:

* `plugins/module_utils/ansiblemodule.py` for collection modules
* `plugins/lookup/k8s.py` for the `k8s` lookup plugin

To verify locally:

```shell
export ENABLE_TURBO_MODE=1
ansible localhost -m kubernetes.core.k8s_info -a "kind=Namespace" 2>&1 | grep -iE "deprecat|warning"
```

Integration tests that run with `ENABLE_TURBO_MODE=true` use ansible-core 2.18, where turbo mode remains enabled, so turbo behaviour there is unchanged.

Thanks to @yurnov for diagnosing the unreachable deprecation and for the suggested fix in [mandar242#1](https://github.com/mandar242/kubernetes.core/pull/1).

(cherry picked from commit 031bc475fa)

Co-authored-by: Mandar Kulkarni <mandkulk@redhat.com>
2026-09-15 15:31:27 +01:00
8ec2912419 ci: add the PE certification checker workflow (#1231) (#1248)
* ci: add the PE certification checker workflow

* ci: add stable branches to certification workflow

(cherry picked from commit 732925b986)

Co-authored-by: Don Naro <dnaro@redhat.com>
2026-09-15 14:25:59 +01:00
c35fc5e10e Remove remaining ansible.module_utils.six import from kubectl connection plugin (#1197) (#1199)
* 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



---------


(cherry picked from commit dd4ca7a8b0)

Co-authored-by: Zhiwei Liang <zhiwei.liang@zliang.me>
Co-authored-by: Bikouo Aubin <79859644+abikouo@users.noreply.github.com>
2026-09-14 15:09:04 +01:00
66ec4758f0 [PR #1240/cb00cf3c backport][stable-5] Address stale deprecations (#1246)
* 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

(cherry picked from commit cb00cf3c9e)

* fix: remove unnecessary ignore statements

---------

Co-authored-by: Don Naro <dnaro@redhat.com>
2026-09-14 14:37:21 +01:00
feb44ae16a chore(test): add ansible 2.21 to integration tests matrix (#1234) (#1244)
* 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

(cherry picked from commit 7df5e01974)

Co-authored-by: Yuriy Novostavskiy <yuriy@novostavskiy.kyiv.ua>
2026-09-14 13:21:34 +01:00
00dab977a5 test(sanity): align python_requires with documented 3.9+ support (#1226) (#1228)
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.

(cherry picked from commit d9e0218dba)

Co-authored-by: Yuriy Novostavskiy <yuriy@novostavskiy.kyiv.ua>
2026-09-10 17:27:16 +01:00
983851296a Fix ansible-lint no-changed-when and execution-environment schema warnings (#1196) (#1238)
* 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.



* Add changelog fragment for ansible-lint warning fixes



* Fix changelog fragment YAML formatting

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



---------


(cherry picked from commit a7922e498c)

Co-authored-by: Daniel Brennand <52419383+dbrennand@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-09-10 16:20:19 +01:00
Yuriy NovostavskiyandGitHub d3e177d62c Use the pinned helm binary in helm_registry_auth and helm_diff tests (#1219)
SUMMARY
Fixes #1218.
helm_registry_auth and helm_diff resolved helm from PATH instead of the binary installed by the install_helm role. The runner image now ships helm v3.21.3, which returns 401 Unauthorized when pushing to the plain-HTTP test registry, while install_helm pins v3.16.4.

helm_registry_auth — added helm_binary to the target defaults and used it in the shell tasks and as binary_path for the module calls. The target already depended on install_helm, it just never used the result.
helm_diff — pass helm_binary_path: "{{ helm_binary }}" when including push_to_helm_registry. Without it the role used its own default of helm, so the target was mixing two helm binaries: the pinned one for Log into Helm registry and the one from PATH for the push.

This is the stable-5 counterpart of what #1090 did on main, limited to the test files. main and stable-6 additionally rewrote helm_registry_auth to run against several pinned helm versions with --plain-http, which depends on the plain_http module option that does not exist on stable-5. Pinning the binary keeps this to a test-only change, so stable-5 continues to be tested against helm 3.16.4 while newer helm coverage stays on main/stable-6.
No changelog fragment: tests/ only.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
tests/integration/targets/helm_registry_auth, tests/integration/targets/helm_diff
ADDITIONAL INFORMATION
Before, on #1199 (all four matrix combinations of shards 4 and 8):
TASK [helm_registry_auth : Test module helm_registry_auth with correct credentials] ***
changed: [localhost] => {"command": "/usr/local/bin/helm registry login localhost:5000 --username=testuser --password-stdin", "stderr": "Login Succeeded\n", ...}

TASK [helm_registry_auth : Ensure that push to the registry is working] ********
fatal: [localhost]: FAILED! => {
    "cmd": "helm push \"/tmp/ansible.poej0iam.helm/k8s-monitoring-1.6.8.tgz\"  oci://localhost:5000/test/",
    "rc": 1,
    "stderr": "Error: failed to perform \"Exists\" on destination: HEAD \"http://localhost:5000/v2/test/k8s-monitoring/manifests/sha256:fea90b12...\": response status code 401: Unauthorized"
}

FATAL: The 1 integration test(s) listed below (out of 3) failed. See error output above for details:
helm_registry_auth

TASK [push_to_helm_registry : Helm push chart to the registry] *****************
fatal: [localhost]: FAILED! => {
    "cmd": ["helm", "push", "/tmp/ansible._h27f4p0.chart/test-chart-deployment-time-0.1.0.tgz", "oci://localhost:6035/testing"],
    "rc": 1,
    "stderr": "Error: failed to perform \"Exists\" on destination: HEAD \"http://localhost:6035/v2/testing/test-chart-deployment-time/manifests/sha256:1de6f019...\": response status code 401: Unauthorized"
}

FATAL: The 1 integration test(s) listed below (out of 9) failed. See error output above for details:
helm_diff

Note that with the pinned 3.16.4 the Test idempotency of logout with helm < 3.18.0 block in helm_registry_auth runs again; it was being skipped while the newer binary from PATH was in use.

Reviewed-by: Alina Buzachis
Reviewed-by: Bianca Henderson <beeankha@gmail.com>
Reviewed-by: Don Naro <dnaro@redhat.com>
Reviewed-by: Bikouo Aubin
2026-09-08 13:39:08 +00:00
b5d5fa4d65 ci: exclude test code from SonarCloud duplication detection (#1207) (#1212)
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.

(cherry picked from commit f31ecce59c)

Co-authored-by: Yuriy Novostavskiy <yuriy@novostavskiy.kyiv.ua>
2026-08-10 12:01:15 -04:00
dad9a8457e Handle empty template output gracefully (#1044) (#1204)
* 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.



* 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.



* 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.



---------



(cherry picked from commit ec8942dd90)

Co-authored-by: W. H. Wang <mattwang44@gmail.com>
Co-authored-by: aubin bikouo <abikouo@redhat.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-08-10 11:30:33 +02:00
Bianca HendersonandGitHub 1a0914352a Prep 5.4.4 release (#1193)
* Fix ansible version for 5.4.3 release

* Prep release 5.4.4

(cherry picked from commit 44fbb83be4b2ea9d3ee4479f7aa131cf72b3b0e3)
2026-07-09 17:04:18 -04:00
Bianca HendersonandGitHub efe2d1aa69 Prep release 5.4.3 (#1187)
* Prep k8s collection release 5.4.3

* Update release date for 5.4.3

* Update changelog.yaml and changelog.rst mismatches
2026-07-08 11:04:38 -04:00
0cd0f3df9e Add meta/execution-environment.yml to fix EE builds on UBI images (#1142) (#1182)
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


(cherry picked from commit a80e2d067c)

Co-authored-by: Christopher Brown <snecklifter@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-07-07 09:48:42 -04:00
d0daf56ea7 Add lint ignore entry (#1184) (#1185)
(cherry picked from commit 75a5560aec)

Co-authored-by: Bianca Henderson <bianca@redhat.com>
2026-07-07 09:42:59 -04:00
3967f5e2ca feat(ci): add security check to block .claude/ and .vscode/ directories (#1173) (#1180)
* 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



* 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.



* 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



* docs: add changelog fragment for security check workflow



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

---------



(cherry picked from commit 6bb9cce51b)

Co-authored-by: GomathiselviS <gomathiselvi@gmail.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Bianca Henderson <beeankha@gmail.com>
2026-07-03 08:39:56 -04:00
7150d04f01 Point to Python 3.13 for ansible-core devel (#1174) (#1175)
(cherry picked from commit ceeafa8c6d)

Co-authored-by: Bianca Henderson <bianca@redhat.com>
2026-07-01 12:19:02 -04:00
Bianca HendersonandGitHub 00f3d12a1d [manual backport stable-5] Fix CI Test Collision (#1162) (#1166)
* Fix CI Test Collision (#1162)

* Fix CI concurrency issue

* More CI fixes

* Fix coverage job install

* Install correct test dependencies

(cherry picked from commit d211f316ad)

* Restore cancel-in-progress: true
2026-06-30 12:01:44 -04:00
33bb3b81ba ci: suppress SonarCloud python:S5443 for test code (#1165) (#1168)
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

(cherry picked from commit 0836e96c2d)

Co-authored-by: Yuriy Novostavskiy <yuriy@novostavskiy.kyiv.ua>
2026-06-30 11:48:42 -04:00
e4b748a791 CI - configure precommit hook to block commit when files from .claude… (#1149) (#1170)
* 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

(cherry picked from commit a4fc40732a)

Co-authored-by: Bikouo Aubin <79859644+abikouo@users.noreply.github.com>
2026-06-30 10:57:50 +02:00
c76cc63a75 Fix workflow concurrency issue (#1159) (#1160)
(cherry picked from commit bb80dde66d)

Co-authored-by: Bianca Henderson <bianca@redhat.com>
2026-06-26 12:03:21 -04:00
c9b918a453 Fix all-green CI workflow (#1153) (#1157)
(cherry picked from commit 8bf31513f5)

Co-authored-by: Bianca Henderson <bianca@redhat.com>
2026-06-26 10:53:45 -04:00
d3e408556b ci: suppress SonarCloud python:S7498 for argument_spec dict() convention (#1152) (#1154)
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

(cherry picked from commit 1c20b53bdc)

Co-authored-by: Yuriy Novostavskiy <yuriy@novostavskiy.kyiv.ua>
2026-06-25 14:07:10 -04:00
Bianca HendersonandGitHub 16f4b49c43 Manual backport of SonarQube configuration to stable-5 branch (#1137) 2026-05-29 17:31:39 -04:00
178611ef5d Fix unit test failures in CI (#1133) (#1134)
(cherry picked from commit f69761f37c)

Co-authored-by: Bianca Henderson <bianca@redhat.com>
2026-05-25 11:00:48 -04:00
2b52790a01 Update pod deletion conditions for local storage used in a daemon set pod (#1095) (#1127)
* 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

---------


(cherry picked from commit b58b2ca70e)

Co-authored-by: Juan Morete <morete@gmail.com>
Co-authored-by: Bianca Henderson <bianca@redhat.com>
2026-05-15 15:16:07 -04:00
84cf83fe0f fix(helm_repository): strip trailing slashes from repo_url (#1121) (#1125)
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

(cherry picked from commit 8a58d3b6de)

Co-authored-by: Yuriy Novostavskiy <yuriy@novostavskiy.kiev.ua>
2026-05-14 10:56:35 -04:00
a2aa079829 docs: add until example to k8s_info (#885) (#1118)
I would liked to have an example like this when I was using the
documentation.

(cherry picked from commit 4d7dc2a7d1)

Co-authored-by: Birger Johan Nordølum <33870508+MindTooth@users.noreply.github.com>
2026-05-06 10:16:35 -04:00
ca050aa3f6 Update URL reference in integration-test CI file (#1112) (#1113)
(cherry picked from commit 210467b26d)

Co-authored-by: Bianca Henderson <bianca@redhat.com>
2026-04-22 14:15:08 -04:00
84249fc4f1 ci: conditionally test turbo mode and cloud.common (#1109) (#1110)
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.

(cherry picked from commit 11f619b69e)

Co-authored-by: Yuriy Novostavskiy <yuriy@novostavskiy.kiev.ua>
2026-04-21 14:51:49 -04:00
229575fe8f Add sanity test ignores for ansible-core 2.22 (#1102) (#1105)
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
#

(cherry picked from commit 58f8f2e6e9)

Co-authored-by: Yuriy Novostavskiy <yuriy@novostavskiy.kiev.ua>
2026-04-20 18:34:47 -04:00
73 changed files with 1614 additions and 260 deletions
+2
View File
@@ -4,3 +4,5 @@ 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]
+121
View File
@@ -0,0 +1,121 @@
---
name: all_green
concurrency:
group: ${{ github.head_ref || github.ref }}
cancel-in-progress: true
on: # yamllint disable-line rule:truthy
pull_request:
types:
- opened
- reopened
- synchronize
branches:
- main
- stable-*
push:
branches:
- main
- stable-*
jobs:
security-check:
if: github.event_name == 'pull_request'
uses: ./.github/workflows/security-check.yaml
linters:
if: github.event_name == 'pull_request'
uses: ./.github/workflows/linters.yaml
sanity:
uses: ./.github/workflows/sanity-tests.yaml
units:
uses: ./.github/workflows/unit-tests.yaml
coverage:
name: Unit test coverage
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
path: ansible_collections/kubernetes/core
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Run unit tests with coverage
working-directory: ansible_collections/kubernetes/core
env:
PYTHONPATH: ${{ github.workspace }}
run: |
python -m pip install --upgrade pip
python -m pip install ansible-compat
python -m pip install https://github.com/ansible/ansible/archive/stable-2.19.tar.gz
# Same deps as the units matrix (build_install_collection); do not use
# tests/unit/requirements.txt — its kubernetes pin breaks test_core.py.
python -m pip install -r requirements.txt -r test-requirements.txt
python -m coverage run --source=plugins -m pytest tests/unit \
--ansible-host-pattern localhost
python -m coverage xml -o coverage.xml
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage
path: ansible_collections/kubernetes/core/coverage.xml
all_green:
if: ${{ always() }}
needs:
- security-check
- linters
- sanity
- units
- coverage
runs-on: ubuntu-latest
steps:
- run: |
python -c "
import sys
required = ['sanity', 'units', 'coverage']
if '${{ github.event_name }}' == 'pull_request':
required = ['security-check', 'linters', 'sanity', 'units', 'coverage']
results = {
'security-check': '${{ needs.security-check.result }}',
'linters': '${{ needs.linters.result }}',
'sanity': '${{ needs.sanity.result }}',
'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)
"
+20
View File
@@ -0,0 +1,20 @@
---
name: Run collection certification checks
permissions:
contents: read
on:
pull_request:
branches:
- main
- stable-*
workflow_dispatch:
concurrency:
group: cert-ver-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
call:
uses: ansible-collections/partner-certification-checker/.github/workflows/certification-reusable.yml@f4bf7ba4d3f008b2db8fc6a812fa3f89fdf42c2e # v4.1.0
+24 -8
View File
@@ -55,15 +55,29 @@ jobs:
strategy:
fail-fast: false
matrix:
ansible-version:
- milestone
python-version:
- "3.12"
enable-turbo-mode:
- true
- false
# Ref must match a branch/tag on github.com/ansible/ansible (e.g. stable-2.18, not 2.18).
#
ansible-version: ["stable-2.18", "stable-2.21", "milestone"]
enable-turbo-mode: [true, false]
python-version: ["3.12", "3.13"]
exclude:
# stable-2.18 is used mainly because turbo mode, no reason to test it with turbo mode disabled
- ansible-version: "stable-2.18"
enable-turbo-mode: false
# turbo mode is supported only by ansible<2.19
- ansible-version: "milestone"
enable-turbo-mode: true
- ansible-version: "stable-2.21"
enable-turbo-mode: true
# stable-2.18 supports 3.12
- ansible-version: "stable-2.18"
python-version: "3.13"
- ansible-version: "stable-2.21"
python-version: "3.12"
- ansible-version: "milestone"
python-version: "3.12"
workflow-id: ${{ fromJson(needs.splitter.outputs.test_jobs) }}
name: "integration-py${{ matrix.python-version }}-${{ matrix.ansible-version }}-${{ matrix.workflow-id }}-enable_turbo=${{ matrix.enable-turbo-mode }}"
name: Integration tests
steps:
- name: Read target
id: read-targets
@@ -107,6 +121,7 @@ jobs:
source_path: ${{ env.source }}
- name: checkout ansible-collections/cloud.common
if: ${{ matrix.enable-turbo-mode == true }}
uses: ansible-network/github_actions/.github/actions/checkout_dependency@main
with:
repository: ansible-collections/cloud.common
@@ -128,6 +143,7 @@ jobs:
ref: main
- name: install cloud.common collection
if: ${{ matrix.enable-turbo-mode == true }}
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
with:
install_python_dependencies: true
+1 -10
View File
@@ -1,16 +1,7 @@
---
name: Linters
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
branches:
- main
- stable-*
tags:
- '*'
on: [workflow_call]
jobs:
linters:
+1 -8
View File
@@ -1,14 +1,7 @@
---
name: Sanity tests
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
branches:
- main
- stable-*
on: [workflow_call]
jobs:
sanity:
+17
View File
@@ -0,0 +1,17 @@
---
name: Security Check
on: [workflow_call]
jobs:
security-check:
name: Block unsafe directories
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for blocked directories
uses: ansible/cloud-content-ci-automation/.github/actions/security_check_directories@74b5fe870e1d5346c5fcea332b97a6fb26f1ad8a
+89
View File
@@ -0,0 +1,89 @@
## SonarCloud Analysis Workflow for kubernetes.core
#
# This workflow runs SonarCloud analysis triggered by all_green workflow completion.
#
# FLOW: all_green completes (linters, ansible-test, coverage) → workflow_run triggers this workflow → finalize job runs
#
# - Triggered by: workflow_run (all_green on pull_request or push to main/stable-*)
# - Steps: Checkout → Download coverage from all_green run → Get PR info (if PR) → Run SonarCloud scan
# - Coverage: Unit test coverage is produced by the coverage job in all_green and passed to SonarCloud here.
---
name: SonarCloud
on:
workflow_run:
workflows:
- all_green
types:
- completed
permissions:
contents: read
pull-requests: read
actions: read
jobs:
finalize:
name: finalize
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_sha }}
fetch-depth: 0
show-progress: false
- name: Download coverage artifacts
uses: dawidd6/action-download-artifact@2536c51d3d126276eb39f74d6bc9c72ac6ef30d3 # v16
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: all_green
run_id: ${{ github.event.workflow_run.id }}
pattern: coverage*
- name: Set coverage report paths
run: |
coverage_files=$(find . -name "coverage*.xml" -type f 2>/dev/null | tr '\n' ',' | sed 's/,$//')
echo "Found coverage files: ${coverage_files:-none}"
echo "COVERAGE_PATHS=${coverage_files}" >> "${GITHUB_ENV}"
- name: Get PR number and info
if: github.event.workflow_run.event == 'pull_request'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
REPO: ${{ github.repository }}
run: |
PR_NUMBER=$(gh pr list --head "$HEAD_BRANCH" --repo "$REPO" --json number -q '.[0].number')
echo "PR_NUMBER=${PR_NUMBER}" >> "${GITHUB_ENV}"
if [ -n "${PR_NUMBER}" ]; then
PR_DATA=$(gh api "repos/${REPO}/pulls/${PR_NUMBER}")
echo "PR_BASE=$(echo "${PR_DATA}" | jq -r '.base.ref')" >> "${GITHUB_ENV}"
echo "PR_HEAD=$(echo "${PR_DATA}" | jq -r '.head.ref')" >> "${GITHUB_ENV}"
fi
- name: Prepare SonarCloud args
env:
COMMIT_SHA: ${{ github.event.workflow_run.head_sha }}
EVENT_TYPE: ${{ github.event.workflow_run.event }}
run: |
SONAR_ARGS="-Dsonar.scm.revision=\"${COMMIT_SHA}\""
if [[ "${EVENT_TYPE}" == "pull_request" && -n "${PR_NUMBER:-}" ]]; then
SONAR_ARGS="${SONAR_ARGS} -Dsonar.pullrequest.key=${PR_NUMBER}"
SONAR_ARGS="${SONAR_ARGS} -Dsonar.pullrequest.branch=${PR_HEAD}"
SONAR_ARGS="${SONAR_ARGS} -Dsonar.pullrequest.base=${PR_BASE}"
fi
if [[ -n "${COVERAGE_PATHS:-}" ]]; then
SONAR_ARGS="${SONAR_ARGS} -Dsonar.python.coverage.reportPaths=${COVERAGE_PATHS}"
fi
echo "SONAR_ARGS=${SONAR_ARGS}" >> "${GITHUB_ENV}"
- name: SonarCloud Scan
uses: SonarSource/sonarqube-scan-action@a31c9398be7ace6bbfaf30c0bd5d415f843d45e9 # v7
env:
SONAR_TOKEN: ${{ secrets.ANSIBLE_COLLECTIONS_ORG_SONAR_TOKEN_CICD_BOT }}
with:
args: ${{ env.SONAR_ARGS }}
+1 -8
View File
@@ -1,13 +1,6 @@
name: Unit tests
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
branches:
- main
- stable-*
on: [workflow_call]
jobs:
unit-source:
+5 -1
View File
@@ -22,5 +22,9 @@ tests/integration/*-chart-*.tgz
tests/integration/inventory
tests/integration/*-*.yml
# VS Code settings
# IDE and editor settings
.vscode/
.claude/
# Root coverage report for SonarCloud (generated locally or in CI)
/coverage.xml
+6
View File
@@ -0,0 +1,6 @@
repos:
- repo: https://github.com/ansible/cloud-content-ci-automation
rev: precommit_hook
hooks:
- id: block-ide-ai-files
always_run: true
+67 -7
View File
@@ -4,19 +4,79 @@ Kubernetes Collection Release Notes
.. contents:: Topics
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.
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).
- 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
-------------------
@@ -65,7 +125,7 @@ This release updates the ``helm_registry_auth`` module to match the behavior of
Minor Changes
-------------
- Module ``helm_registry_auth`` does not support idempotency with ``helm >= 3.18.0`` (https://github.com/ansible-collections/kubernetes.core/pull/946)
- Module ``helm_registry_auth`` does not support idempotency with ``helm >= 3.18.0`` (https://github.com/ansible-collections/kubernetes.core/pull/946).
v5.3.0
======
@@ -78,15 +138,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
======
+37
View File
@@ -0,0 +1,37 @@
# Continuous Integration (CI)
## Kubernetes Upstream Testing
GitHub Actions are used to run the CI for the kubernetes.core collection. The workflows used for the CI can be found in the [.github/workflows](.github/workflows) directory.
### PR Testing Workflows
The following tests run on every pull request:
| Job | Description | Python Versions | ansible-core Versions |
| --- | ----------- | --------------- | --------------------- |
| [Changelog](.github/workflows/changelog.yaml) | Checks for the presence of changelog fragments | 3.12 | devel |
| [Linters](.github/workflows/linters.yaml) | Runs `black`, `flake8`, `isort`, `yamllint`, and `ansible-lint` on plugins and tests | 3.10 | devel |
| [Sanity](.github/workflows/sanity-tests.yaml) | Runs ansible sanity checks | See compatibility table below | devel, stable-2.18, stable-2.19, stable-2.20 |
| [Unit tests](.github/workflows/unit-tests.yaml) | Executes unit test cases | See compatibility table below | devel, stable-2.16, stable-2.17, stable-2.18, stable-2.19, stable-2.20 |
| [Integration](.github/workflows/integration-tests.yaml) | Executes integration test suites using KinD cluster (split across 8 jobs, tests with Turbo mode enabled/disabled) | 3.12 (stable-2.18), 3.13 (milestone) | stable-2.18, milestone |
| [all_green](.github/workflows/all_green_check.yaml) | Linters (PR only), sanity, units, coverage XML, aggregate gate, and SonarCloud scan (same-repo PR / push only) | (see jobs) | (see jobs) |
**Note:** Integration tests require a KinD (Kubernetes in Docker) cluster and test both with Turbo mode enabled and disabled.
### Python Version Compatibility by ansible-core Version
These are outlined in the collection's [tox.ini](tox.ini) file (`envlist`) and GitHub Actions workflow exclusions.
| ansible-core Version | Sanity Tests | Unit Tests | Integration Tests |
| -------------------- | ------------ | ---------- | ----------------- |
| devel | 3.12, 3.13, 3.14 | 3.13 | 3.13 (milestone) |
| stable-2.20 | 3.12, 3.13, 3.14 | 3.12, 3.13, 3.14 | — |
| stable-2.19 | 3.11, 3.12, 3.13 | 3.11, 3.12, 3.13 | — |
| stable-2.18 | 3.11, 3.12, 3.13 | 3.11, 3.12, 3.13 | 3.12 |
| stable-2.17 | 3.10, 3.11, 3.12 | 3.10, 3.11, 3.12 | — |
| stable-2.16 | 3.10, 3.11 | 3.10, 3.11 | — |
## SonarCloud
SonarCloud analysis runs from **[`all_green_check.yaml`](.github/workflows/all_green_check.yaml)** via the **`sonarcloud`** job, which calls **[`sonarcloud.yml`](.github/workflows/sonarcloud.yml)** (**`workflow_call`**) after the **`all_green`** gate and **coverage** succeed. The reusable workflow checks out the PR head or push SHA, downloads the **`coverage`** artifact, and runs the pinned **SonarSource** scan action. Same-repo **`pull_request`** and **`push`** only (fork PRs are excluded by the job **`if:`** gate). Details: [SONARCLOUD.md](SONARCLOUD.md).
+14
View File
@@ -66,6 +66,20 @@ After installation, you can update documentation
Review the changes and create a pull request using updated files.
### Pre-Commit Hooks
To prevent accidental commits of local configuration and IDE files (specifically `.vscode/` and `.claude/`), this repository utilizes the `pre-commit` framework.
Please set up the hooks locally before making your first commit:
```bash
# Install the pre-commit tool
pip install pre-commit
# Register the hooks with Git
pre-commit install
```
### Code of Conduct
The `kubernetes.core` collection follows the Ansible project's
[Code of Conduct](https://docs.ansible.com/ansible/devel/community/code_of_conduct.html).
+1 -1
View File
@@ -1,5 +1,5 @@
# Also needs to be updated in galaxy.yml
VERSION = 5.4.2
VERSION = 5.5.0
TEST_ARGS ?= ""
PYTHON_VERSION ?= `python -c 'import platform; print(".".join(platform.python_version_tuple()[0:2]))'`
+112 -98
View File
@@ -1,3 +1,11 @@
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ansible-collections_kubernetes.core&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=ansible-collections_kubernetes.core)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=ansible-collections_kubernetes.core&metric=coverage)](https://sonarcloud.io/summary/new_code?id=ansible-collections_kubernetes.core)
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=ansible-collections_kubernetes.core&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=ansible-collections_kubernetes.core)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=ansible-collections_kubernetes.core&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=ansible-collections_kubernetes.core)
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=ansible-collections_kubernetes.core&metric=bugs)](https://sonarcloud.io/summary/new_code?id=ansible-collections_kubernetes.core)
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=ansible-collections_kubernetes.core&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=ansible-collections_kubernetes.core)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=ansible-collections_kubernetes.core&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=ansible-collections_kubernetes.core)
# Kubernetes Collection for Ansible
This repository hosts the `kubernetes.core` (formerly known as `community.kubernetes`) Ansible Collection.
@@ -6,27 +14,65 @@ This repository hosts the `kubernetes.core` (formerly known as `community.kubern
The collection includes a variety of Ansible content to help automate the management of applications in Kubernetes and OpenShift clusters, as well as the provisioning and maintenance of clusters themselves.
## Communication
### Included Content
* Join the Ansible forum:
* [Get Help](https://forum.ansible.com/c/help/6): get help or help others.
* [Posts tagged with 'kubernetes'](https://forum.ansible.com/tag/kubernetes): subscribe to participate in collection-related conversations.
* [Social Spaces](https://forum.ansible.com/c/chat/4): gather and interact with fellow enthusiasts.
* [News & Announcements](https://forum.ansible.com/c/news/5): track project-wide announcements including social events.
Click on the name of a plugin or module to view that content's documentation:
* The Ansible [Bullhorn newsletter](https://docs.ansible.com/ansible/devel/community/communication.html#the-bullhorn): used to announce releases and important changes.
<!--start collection content-->
### Connection plugins
Name | Description
--- | ---
[kubernetes.core.kubectl](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/kubernetes.core.kubectl_connection.rst)|Execute tasks in pods running on Kubernetes.
For more information about communication, see the [Ansible communication guide](https://docs.ansible.com/ansible/devel/community/communication.html).
### K8s filter plugins
Name | Description
--- | ---
kubernetes.core.k8s_config_resource_name|Generate resource name for the given resource of type ConfigMap, Secret
### Inventory plugins
Name | Description
--- | ---
[kubernetes.core.k8s](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/kubernetes.core.k8s_inventory.rst)|Kubernetes (K8s) inventory source
### Lookup plugins
Name | Description
--- | ---
[kubernetes.core.k8s](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/kubernetes.core.k8s_lookup.rst)|Query the K8s API
[kubernetes.core.kustomize](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/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-5/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-5/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-5/docs/kubernetes.core.helm_plugin_module.rst)|Manage Helm plugins
[kubernetes.core.helm_plugin_info](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/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-5/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-5/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-5/docs/kubernetes.core.helm_repository_module.rst)|Manage Helm repositories.
[kubernetes.core.helm_template](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/kubernetes.core.helm_template_module.rst)|Render chart templates
[kubernetes.core.k8s](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/kubernetes.core.k8s_module.rst)|Manage Kubernetes (K8s) objects
[kubernetes.core.k8s_cluster_info](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/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-5/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-5/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-5/docs/kubernetes.core.k8s_exec_module.rst)|Execute command in Pod
[kubernetes.core.k8s_info](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/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-5/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-5/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-5/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-5/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-5/docs/kubernetes.core.k8s_service_module.rst)|Manage Services on Kubernetes
[kubernetes.core.k8s_taint](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/kubernetes.core.k8s_taint_module.rst)|Taint a node in a Kubernetes/OpenShift cluster
<!--end collection content-->
## Requirements
<!--start requires_ansible-->
## Ansible Version Compatibility
## Ansible version compatibility
This collection has been tested against following Ansible versions: **>=2.15.0**.
This collection has been tested against the following Ansible versions: **>=2.16.0**.
For collections that support Ansible 2.9, please ensure you update your `network_os` to use the
fully qualified collection name (for example, `cisco.ios.ios`).
Plugins and modules within a collection may be tested with only specific Ansible versions.
A collection may contain metadata that identifies these versions.
PEP440 is the schema used to describe the versions of Ansible.
@@ -46,58 +92,6 @@ Note: Python2 is deprecated from [1st January 2020](https://www.python.org/doc/s
This collection supports Kubernetes versions >= 1.24.
### Included Content
Click on the name of a plugin or module to view that content's documentation:
<!--start collection content-->
### Connection Plugins
Name | Description
--- | ---
[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
--- | ---
kubernetes.core.k8s_config_resource_name|Generate resource name for the given resource of type ConfigMap, Secret
### Inventory Plugins
Name | Description
--- | ---
[kubernetes.core.k8s](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_inventory.rst)|Kubernetes (K8s) inventory source
### Lookup Plugins
Name | Description
--- | ---
[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/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
<!--end collection content-->
## Installation
Before using the Kubernetes collection, you need to install it with the Ansible Galaxy CLI:
@@ -110,14 +104,16 @@ You can also include it in a `requirements.yml` file and install it via `ansible
---
collections:
- name: kubernetes.core
version: 5.4.2
version: 5.5.0
```
### 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:
pip3 install kubernetes
```bash
pip3 install kubernetes
```
## Use Cases
@@ -189,7 +185,11 @@ For documentation on how to use individual modules and other content included in
## Ansible Turbo Mode Tech Preview
The ``kubernetes.core`` collection supports Ansible Turbo mode as a tech preview via the ``cloud.common`` collection. By default, this feature is disabled. To enable Turbo mode for modules, set the environment variable `ENABLE_TURBO_MODE=1` on the managed node. For example:
> **Deprecated:** Ansible Turbo mode (`ENABLE_TURBO_MODE`) is deprecated and will be removed in a future major release (planned for 8.0.0), since it depends on the `cloud.common` collection, which is being retired. Setting `ENABLE_TURBO_MODE` will keep emitting a deprecation warning until support is removed, at which point the variable will have no effect.
> **Note:** Ansible Turbo mode is supported only with ``ansible-core`` versions **lower than 2.19**. Starting from ``ansible-core`` 2.19, the ``cloud.common`` collection is no longer supported, and therefore Ansible Turbo mode is also not supported in ``kubernetes.core``. If ``ENABLE_TURBO_MODE`` is set to ``1`` (or any truthy value) with ``ansible-core >= 2.19.0``, Turbo mode is ignored and a warning is emitted; modules run without it.
The ``kubernetes.core`` collection supports Ansible Turbo mode as a tech preview via the ``cloud.common`` collection (requires `ansible-core < 2.19`). By default, this feature is disabled. To enable Turbo mode for modules, set the environment variable `ENABLE_TURBO_MODE=1` on the managed node. For example:
```yaml
---
@@ -203,13 +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/main/docs/ansible_turbo_mode.rst).
## Contributing to this Collection
If you want to develop new content for this collection or improve what's already here, the easiest way to work on the collection is to clone it 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](CONTRIBUTING.md).
Please read more about Ansible Turbo mode - [here](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/ansible_turbo_mode.rst).
## Testing
@@ -232,7 +226,40 @@ There are also integration tests in the `molecule` directory which are meant to
kind create cluster
make test-molecule
## Publishing New Versions
## Contributing to this Collection
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-5/CONTRIBUTING.md).
Join the Ansible community:
* [Get Help](https://forum.ansible.com/c/help/6)
* [Posts tagged with 'kubernetes'](https://forum.ansible.com/tag/kubernetes)
* [Social Spaces](https://forum.ansible.com/c/chat/4)
* [News & Announcements](https://forum.ansible.com/c/news/5)
The Ansible [Bullhorn newsletter](https://docs.ansible.com/ansible/devel/community/communication.html#the-bullhorn) announces releases and important changes. For more information, see the [Ansible communication guide](https://docs.ansible.com/ansible/devel/community/communication.html).
### Code of Conduct
This project follows the [Ansible Code of Conduct](https://docs.ansible.com/ansible/devel/community/code_of_conduct.html). If you encounter abusive behavior, see the [policy violations](https://docs.ansible.com/ansible/devel/community/code_of_conduct.html#policy-violations) section for how to raise a complaint.
## Support
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`.
We announce releases and important changes through Ansible's [The Bullhorn newsletter](https://github.com/ansible/community/wiki/News#the-bullhorn). Subscribe via [this link](https://eepurl.com/gZmiEP).
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-5/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/).
## Release Notes and Roadmap
Releases are automatically built and pushed to Ansible Galaxy for any new tag. Before tagging a release, make sure to do the following:
@@ -249,37 +276,24 @@ Releases are automatically built and pushed to Ansible Galaxy for any new tag. B
After the version is published, verify it exists on the [Kubernetes Collection Galaxy page](https://galaxy.ansible.com/kubernetes/core).
The process for uploading a supported release to Automation Hub is documented separately.
The process for [uploading a supported release to Automation Hub](https://docs.redhat.com/en/documentation/red_hat_ansible_automation_platform/2.1/html/uploading_content_to_red_hat_automation_hub/proc-upload-collection) is documented separately.
## Support
## Related Information
<!--List available communication channels. In addition to channels specific to your collection, we also recommend to use the following ones.-->
* [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-5/CI.md)
* [SonarCloud integration](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/SONARCLOUD.md)
* [Ansible Turbo mode (tech preview)](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/ansible_turbo_mode.rst)
> **Note:** The `stable-4` branch, which handles all `4.x.y` releases of this collection, is no longer supported. This means that no backports nor releases will be performed on the `stable-4` branch.
We announce releases and important changes through Ansible's [The Bullhorn newsletter](https://github.com/ansible/community/wiki/News#the-bullhorn). Be sure you are [subscribed](https://eepurl.com/gZmiEP).
We take part in the global quarterly [Ansible Contributor Summit](https://github.com/ansible/community/wiki/Contributor-Summit) virtually or in-person. Track [The Bullhorn newsletter](https://eepurl.com/gZmiEP) and join us.
For more information about communication, refer to the [Ansible Communication guide](https://docs.ansible.com/ansible/devel/community/communication.html).
For the latest supported versions, refer to the release notes below.
If you encounter issues or have questions, you can submit a support request through the following channels:
- GitHub Issues: Report bugs, request features, or ask questions by opening an issue in the [GitHub repository](https://github.com/ansible-collections/kubernetes.core/).
## Release Notes
See the [raw generated changelog](https://github.com/ansible-collections/kubernetes.core/blob/main/CHANGELOG.rst).
## Code of Conduct
### Code of conduct
We follow the [Ansible Code of Conduct](https://docs.ansible.com/ansible/devel/community/code_of_conduct.html) in all our interactions within this project.
If you encounter abusive behavior, please refer to the [policy violations](https://docs.ansible.com/ansible/devel/community/code_of_conduct.html#policy-violations) section of the Code for information on how to raise a complaint.
## License
## License Information
GNU General Public License v3.0 or later
See LICENSE to see the full text.
See [LICENSE](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/LICENSE) to see the full text.
+32
View File
@@ -0,0 +1,32 @@
# SonarCloud
Dashboard:
[SonarCloud project overview](https://sonarcloud.io/project/overview?id=ansible-collections_kubernetes.core)
## CI integration
Sonar analysis is implemented in **[.github/workflows/sonarcloud.yml](.github/workflows/sonarcloud.yml)** as a **reusable workflow** (`on: workflow_call` only). It is **not** triggered by `workflow_run`.
**[.github/workflows/all_green_check.yaml](.github/workflows/all_green_check.yaml)** runs **linters** (on pull requests), **sanity**, **units**, and **coverage**, passes the aggregate **`all_green`** gate, then calls **`sonarcloud.yml`** via a **`sonarcloud`** job when the conditions below are met. The **coverage** job uploads a **`coverage`** artifact; the Sonar job downloads it in the **same** workflow run.
The caller runs on **`pull_request`** or **`push`**, so the reusable workflow inherits that **`github.event`**. **`actions/checkout`** uses **`github.event.pull_request.head.sha`** on pull requests and **`github.sha`** on push (Sonar-friendly checkout). PR parameters (**`sonar.pullrequest.*`**) are taken from **`github.event.pull_request`** (no `gh` API calls in **`sonarcloud.yml`**).
The scan step uses **`SonarSource/sonarqube-scan-action`** (pinned SHA in the workflow file) with **`sonar.python.coverage.reportPaths`** set from any **`coverage*.xml`** files found under the workspace after the artifact download. The overall flow (coverage in CI, then Sonar with XML) follows the same idea as [ansible-collections/amazon.aws#2871](https://github.com/ansible-collections/amazon.aws/pull/2871), using **`workflow_call`** from **`all_green`** instead of a separate **`workflow_run`** finalize workflow.
Workflow files:
- [.github/workflows/all_green_check.yaml](.github/workflows/all_green_check.yaml) -- **`all_green`** gate, **coverage** artifact upload, and **`sonarcloud`** job (**`uses: ./.github/workflows/sonarcloud.yml`**, passing only **`ANSIBLE_COLLECTIONS_ORG_SONAR_TOKEN_CICD_BOT`**) after **`all_green`** and **`coverage`** succeed, gated for **`push`** and same-repo **`pull_request`** only.
- [.github/workflows/sonarcloud.yml](.github/workflows/sonarcloud.yml) -- **`scan`** job: checkout, download **`coverage`**, **`SONAR_ARGS`**, SonarCloud scan.
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-5`**, 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`**.
Org secrets and fork PR behavior follow GitHub's [secrets in Actions](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions) documentation. The **`sonarcloud`** job is **`if:`**-gated so the org token is not used for fork-head checkouts; fork PRs still run **`all_green`** for CI without running Sonar.
## Branch protection (repository settings)
If **`SonarCloud scan`** or **`all_green`** should block merges, add them under **Settings** > **Branches** > **Required status checks** for the protected branch. That is not configured in YAML.
+92 -8
View File
@@ -1029,11 +1029,12 @@ releases:
- 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).
minor_changes:
- kubernetes.core - 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).
release_summary: This release includes minor changes, bug fixes and also bumps
``ansible-lint`` version to ``25.1.2``.
fragments:
@@ -1096,13 +1097,14 @@ releases:
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 - added ``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 - added ``release_values`` key to ``status`` return value that can
- 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 various bugfixes such as replacing the
passing of ``warnings`` to ``exit_json`` with ``AnsibleModule.warn`` as well
as security updates for selectively redacting sensitive information from kubeconfig.
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).
@@ -1116,3 +1118,85 @@ releases:
- 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'
+14
View File
@@ -12,6 +12,20 @@ Following document provides overview of Ansible Turbo mode in ``kubernetes.core`
:depth: 1
.. warning::
Ansible Turbo mode is **deprecated** and will be removed in a future major release
(planned for 8.0.0), as it depends on the ``cloud.common`` collection, which is being
retired. Setting ``ENABLE_TURBO_MODE`` now emits a deprecation warning; once support is
removed, the variable will have no effect. Start planning your migration away from
Turbo mode.
.. warning::
Ansible Turbo mode is supported only with ``ansible-core`` versions **lower than 2.19**.
Starting from ``ansible-core`` 2.19, the ``cloud.common`` collection is no longer supported,
and therefore Ansible Turbo mode is also not supported in ``kubernetes.core``.
If ``ENABLE_TURBO_MODE`` is set to ``1`` (or any truthy value) with ``ansible-core >= 2.19.0``,
Turbo mode is ignored and a warning is emitted; modules run without it.
Synopsis
--------
- A brief introduction about Ansible Turbo mode in ``kuberentes.core`` collection.
+20 -2
View File
@@ -268,7 +268,7 @@ Examples
Return Values
-------------
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
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
@@ -410,6 +410,23 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
<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">
@@ -465,12 +482,13 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
<b>values</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
<span style="color: purple">dictionary</span>
</div>
</td>
<td>always</td>
<td>
<div>Dict of Values used to deploy</div>
<div>This return value has been deprecated and will be removed in version 8.0.0. Use RV(status.release_values) instead.</div>
<br/>
</td>
</tr>
+22 -4
View File
@@ -713,7 +713,7 @@ Parameters
</td>
<td>
<div>Timeout when wait option is enabled (helm2 is a number of seconds, helm3 is a duration).</div>
<div>The use of <em>wait_timeout</em> to wait for kubernetes commands to complete has been deprecated and will be removed after 2022-12-01.</div>
<div>The use of <em>wait_timeout</em> to wait for kubernetes commands to complete has been deprecated and will be removed in version 7.0.0. Use O(timeout) instead.</div>
</td>
</tr>
</table>
@@ -851,7 +851,7 @@ Examples
Return Values
-------------
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
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
@@ -957,6 +957,23 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
<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">
@@ -1012,12 +1029,13 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
<b>values</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
<span style="color: purple">dictionary</span>
</div>
</td>
<td>always</td>
<td>
<div>Dict of Values used to deploy</div>
<div>Dict of Values used to deploy.</div>
<div>This return value has been deprecated and will be removed in version 8.0.0. Use RV(status.release_values) instead.</div>
<br/>
</td>
</tr>
@@ -196,7 +196,7 @@ Examples
Return Values
-------------
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
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
@@ -272,7 +272,7 @@ Examples
Return Values
-------------
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
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
@@ -336,7 +336,7 @@ Examples
Return Values
-------------
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
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
@@ -409,7 +409,7 @@ Examples
Return Values
-------------
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
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
@@ -416,7 +416,7 @@ Examples
Return Values
-------------
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
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
@@ -571,7 +571,7 @@ Examples
Return Values
-------------
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
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
@@ -627,7 +627,7 @@ Examples
Return Values
-------------
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
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
+2 -2
View File
@@ -481,7 +481,7 @@ Examples
Return Values
-------------
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
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
@@ -535,7 +535,7 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
</td>
<td></td>
<td>
<div>The command status code. This attribute is deprecated and will be removed in a future release. Please use rc instead.</div>
<div>The command status code. This attribute is deprecated and will be removed in version 7.0.0. Use RV(result.rc) instead.</div>
<br/>
</td>
</tr>
+16 -1
View File
@@ -701,11 +701,26 @@ Examples
wait_sleep: 10
wait_timeout: 360
- name: Wait for OpenShift bootstrap to complete
kubernetes.core.k8s_info:
api_version: v1
kind: ConfigMap
name: bootstrap
namespace: kube-system
register: ocp_bootstrap_status
until: >
ocp_bootstrap_status.resources is defined and
(ocp_bootstrap_status.resources | length > 0) and
(ocp_bootstrap_status.resources[0].data.status is defined) and
(ocp_bootstrap_status.resources[0].data.status == 'complete')
retries: 60
delay: 15
Return Values
-------------
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
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
@@ -621,7 +621,7 @@ Examples
Return Values
-------------
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
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
@@ -612,7 +612,7 @@ Examples
Return Values
-------------
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
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
+133 -20
View File
@@ -38,13 +38,13 @@ Parameters
<table border=0 cellpadding=0 class="documentation-table">
<tr>
<th colspan="1">Parameter</th>
<th colspan="2">Parameter</th>
<th>Choices/<font color="blue">Defaults</font></th>
<th>Configuration</th>
<th width="100%">Comments</th>
</tr>
<tr>
<td colspan="1">
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>api_key</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -61,7 +61,7 @@ Parameters
</td>
</tr>
<tr>
<td colspan="1">
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>api_version</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -79,7 +79,7 @@ Parameters
</td>
</tr>
<tr>
<td colspan="1">
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>ca_cert</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -97,7 +97,7 @@ Parameters
</td>
</tr>
<tr>
<td colspan="1">
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>client_cert</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -115,7 +115,7 @@ Parameters
</td>
</tr>
<tr>
<td colspan="1">
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>client_key</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -133,7 +133,7 @@ Parameters
</td>
</tr>
<tr>
<td colspan="1">
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>cluster_info</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -150,7 +150,7 @@ Parameters
</td>
</tr>
<tr>
<td colspan="1">
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>context</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -167,7 +167,7 @@ Parameters
</td>
</tr>
<tr>
<td colspan="1">
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>field_selector</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -184,7 +184,7 @@ Parameters
</td>
</tr>
<tr>
<td colspan="1">
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>host</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -201,7 +201,7 @@ Parameters
</td>
</tr>
<tr>
<td colspan="1">
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>kind</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -219,7 +219,7 @@ Parameters
</td>
</tr>
<tr>
<td colspan="1">
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>kubeconfig</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -236,7 +236,7 @@ Parameters
</td>
</tr>
<tr>
<td colspan="1">
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>label_selector</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -253,7 +253,7 @@ Parameters
</td>
</tr>
<tr>
<td colspan="1">
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>namespace</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -270,7 +270,26 @@ Parameters
</td>
</tr>
<tr>
<td colspan="1">
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>no_proxy</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
</td>
<td>
</td>
<td>
</td>
<td>
<div>The comma separated list of hosts/domains/IP/CIDR that shouldn&#x27;t go through proxy. Can also be specified via K8S_AUTH_NO_PROXY environment variable.</div>
<div>Please note that this module does not pick up typical proxy settings from the environment (e.g. NO_PROXY).</div>
<div>This feature requires kubernetes&gt;=19.15.0. When kubernetes library is less than 19.15.0, it fails even if no_proxy is set correctly.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>password</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -287,7 +306,101 @@ Parameters
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>proxy</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
</td>
<td>
</td>
<td>
</td>
<td>
<div>The URL of an HTTP proxy to use for the connection. Can also be specified via K8S_AUTH_PROXY environment variable.</div>
<div>Please note that this module does not pick up typical proxy settings from the environment (e.g. HTTP_PROXY).</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>proxy_headers</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">dictionary</span>
</div>
</td>
<td>
</td>
<td>
</td>
<td>
<div>The Header used for the HTTP proxy.</div>
<div>Documentation can be found here <a href='https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html?highlight=proxy_headers#urllib3.util.make_headers'>https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html?highlight=proxy_headers#urllib3.util.make_headers</a>.</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>basic_auth</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
</td>
<td>
</td>
<td>
</td>
<td>
<div>Colon-separated username:password for basic authentication header.</div>
<div>Can also be specified via K8S_AUTH_PROXY_HEADERS_BASIC_AUTH environment.</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>proxy_basic_auth</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
</td>
<td>
</td>
<td>
</td>
<td>
<div>Colon-separated username:password for proxy basic authentication header.</div>
<div>Can also be specified via K8S_AUTH_PROXY_HEADERS_PROXY_BASIC_AUTH environment.</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>user_agent</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
</td>
<td>
</td>
<td>
</td>
<td>
<div>String representing the user-agent you want, such as foo/1.0.</div>
<div>Can also be specified via K8S_AUTH_PROXY_HEADERS_USER_AGENT environment.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>resource_definition</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -304,7 +417,7 @@ Parameters
</td>
</tr>
<tr>
<td colspan="1">
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>resource_name</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -321,7 +434,7 @@ Parameters
</td>
</tr>
<tr>
<td colspan="1">
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>src</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -339,7 +452,7 @@ Parameters
</td>
</tr>
<tr>
<td colspan="1">
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>username</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -356,7 +469,7 @@ Parameters
</td>
</tr>
<tr>
<td colspan="1">
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>validate_certs</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
@@ -432,7 +545,7 @@ Examples
Return Values
-------------
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this lookup:
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 lookup:
.. raw:: html
+162 -23
View File
@@ -1279,18 +1279,35 @@ Examples
Return Values
-------------
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
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
<table border=0 cellpadding=0 class="documentation-table">
<tr>
<th colspan="2">Key</th>
<th colspan="3">Key</th>
<th>Returned</th>
<th width="100%">Description</th>
</tr>
<tr>
<td colspan="2">
<td colspan="3">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>method</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
</td>
<td>success</td>
<td>
<div>The method used to deploy the resource.</div>
<br/>
<div style="font-size: smaller"><b>Sample:</b></div>
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">create</div>
</td>
</tr>
<tr>
<td colspan="3">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>result</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
@@ -1306,6 +1323,105 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="2">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>api_version</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
</td>
<td>when O(resource_definition) or O(src) contains a single object.</td>
<td>
<div>The versioned schema of this representation of an object.</div>
<br/>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="2">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>duration</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">integer</span>
</div>
</td>
<td>when <code>wait</code> is true</td>
<td>
<div>elapsed time of task in seconds</div>
<br/>
<div style="font-size: smaller"><b>Sample:</b></div>
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">48</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="2">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>error</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">complex</span>
</div>
</td>
<td>error</td>
<td>
<div>error while trying to create/delete the object.</div>
<br/>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="2">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>kind</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
</td>
<td>when O(resource_definition) or O(src) contains a single object.</td>
<td>
<div>Represents the REST resource this object represents.</div>
<br/>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="2">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>metadata</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">complex</span>
</div>
</td>
<td>when O(resource_definition) or O(src) contains a single object.</td>
<td>
<div>Standard object metadata. Includes name, namespace, annotations, labels, etc.</div>
<br/>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="2">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>results</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">complex</span>
</div>
</td>
<td>when O(resource_definition) or O(src) contains a list of objects.</td>
<td>
<div>An array of created, patched, or otherwise present objects.</div>
<br/>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>api_version</b>
@@ -1314,7 +1430,7 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
<span style="color: purple">string</span>
</div>
</td>
<td>success</td>
<td>when O(resource_definition) or O(src) contains a single object.</td>
<td>
<div>The versioned schema of this representation of an object.</div>
<br/>
@@ -1322,6 +1438,7 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>duration</b>
@@ -1340,6 +1457,7 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>error</b>
@@ -1356,21 +1474,6 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>items</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
</div>
</td>
<td>when resource_definition or src contains list of objects</td>
<td>
<div>Returned only when multiple yaml documents are passed to src or resource_definition</div>
<br/>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
@@ -1380,7 +1483,7 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
<span style="color: purple">string</span>
</div>
</td>
<td>success</td>
<td>when O(resource_definition) or O(src) contains a single object.</td>
<td>
<div>Represents the REST resource this object represents.</div>
<br/>
@@ -1388,6 +1491,7 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>metadata</b>
@@ -1396,7 +1500,7 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
<span style="color: purple">complex</span>
</div>
</td>
<td>success</td>
<td>when O(resource_definition) or O(src) contains a single object.</td>
<td>
<div>Standard object metadata. Includes name, namespace, annotations, labels, etc.</div>
<br/>
@@ -1404,6 +1508,7 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>spec</b>
@@ -1412,7 +1517,7 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
<span style="color: purple">complex</span>
</div>
</td>
<td>success</td>
<td>when O(resource_definition) or O(src) contains a single object.</td>
<td>
<div>Specific attributes of the object. Will vary based on the <em>api_version</em> and <em>kind</em>.</div>
<br/>
@@ -1420,6 +1525,7 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>status</b>
@@ -1428,7 +1534,40 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
<span style="color: purple">complex</span>
</div>
</td>
<td>success</td>
<td>when O(resource_definition) or O(src) contains a single object.</td>
<td>
<div>Current status details for the object.</div>
<br/>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="2">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>spec</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">complex</span>
</div>
</td>
<td>when O(resource_definition) or O(src) contains a single object.</td>
<td>
<div>Specific attributes of the object. Will vary based on the <em>api_version</em> and <em>kind</em>.</div>
<br/>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="2">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>status</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">complex</span>
</div>
</td>
<td>when O(resource_definition) or O(src) contains a single object.</td>
<td>
<div>Current status details for the object.</div>
<br/>
+1 -1
View File
@@ -503,7 +503,7 @@ Examples
Return Values
-------------
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
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
@@ -686,7 +686,7 @@ Examples
Return Values
-------------
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
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
+2 -1
View File
@@ -247,6 +247,7 @@ Parameters
<div>See <a href='https://kubernetes.io/docs/tasks/run-application/update-api-object-kubectl-patch/#use-a-json-merge-patch-to-update-a-deployment'>https://kubernetes.io/docs/tasks/run-application/update-api-object-kubectl-patch/#use-a-json-merge-patch-to-update-a-deployment</a></div>
<div>If more than one <code>merge_type</code> is given, the merge_types will be tried in order</div>
<div>This defaults to <code>[&#x27;strategic-merge&#x27;, &#x27;merge&#x27;]</code>, which is ideal for using the same parameters on resource kinds that combine Custom Resources and built-in resources.</div>
<div><em>merge_type=json</em> has been deprecated and will be removed in version 7.0.0. Use <span class='module'>kubernetes.core.k8s_json_patch</span> instead.</div>
</td>
</tr>
<tr>
@@ -614,7 +615,7 @@ Examples
Return Values
-------------
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
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
@@ -541,7 +541,7 @@ Examples
Return Values
-------------
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
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
@@ -383,6 +383,7 @@ Examples
# and requires python to be installed in the image
- name: Run a command in a pod
ansible.builtin.command: echo "Hello, World!"
changed_when: false
- name: Run a command in a pod using local kubectl with inventory variables
# Example inventory:
@@ -407,6 +408,7 @@ Examples
# and requires python to be installed in the image
- name: Run a command in a pod
ansible.builtin.command: echo "Hello, World!"
changed_when: false
- name: Run a command in a pod using dynamic inventory
hosts: localhost
@@ -440,6 +442,7 @@ Examples
# be aware that the command is executed as the user that started the container
# and requires python to be installed in the image
ansible.builtin.command: echo "Hello, World!"
changed_when: false
delegate_to: "{{ my_app_pod_name }}"
+1 -1
View File
@@ -149,7 +149,7 @@ Examples
Return Values
-------------
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this lookup:
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 lookup:
.. raw:: html
+1 -1
View File
@@ -25,7 +25,7 @@ tags:
- openshift
- okd
- cluster
version: 5.4.2
version: 5.5.0
build_ignore:
- .DS_Store
- "*.tar.gz"
+1
View File
@@ -0,0 +1 @@
kubernetes-client [platform:fedora]
+5
View File
@@ -0,0 +1,5 @@
---
version: 3
dependencies:
python: requirements.txt
system: meta/ee-bindep.txt
+1 -1
View File
@@ -1,5 +1,5 @@
---
requires_ansible: '>=2.15.0'
requires_ansible: '>=2.16.0'
action_groups:
helm:
+11 -2
View File
@@ -35,7 +35,11 @@ def _from_yaml_to_definition(buffer):
import yaml
except ImportError:
raise AnsibleError("Failed to import the required Python library (PyYAML).")
return list(yaml.safe_load_all(buffer))
# Handle empty template output
if buffer is None:
return []
return [doc for doc in yaml.safe_load_all(buffer) if doc is not None]
ENV_KUBECONFIG_PATH_SEPARATOR = ";" if platform.system() == "Windows" else ":"
@@ -380,10 +384,15 @@ class ActionModule(ActionBase):
template = self._task.args.get("template", None)
if template:
self.load_template(template, new_module_args, task_vars)
# If template rendered to empty definition, return early with no changes
if not new_module_args.get("definition"):
result["changed"] = False
return self._ensure_invocation(result)
local_path = self._task.args.get("local_path")
state = self._task.args.get("state", None)
if local_path and state == "to_pod" and not remote_transport:
is_local_pod_upload = local_path and state == "to_pod" and not remote_transport
if is_local_pod_upload:
new_module_args["local_path"] = self.get_file_realpath(local_path)
# Execute the k8s_* module.
+4 -1
View File
@@ -196,6 +196,7 @@ EXAMPLES = r"""
# and requires python to be installed in the image
- name: Run a command in a pod
ansible.builtin.command: echo "Hello, World!"
changed_when: false
- name: Run a command in a pod using local kubectl with inventory variables
# Example inventory:
@@ -220,6 +221,7 @@ EXAMPLES = r"""
# and requires python to be installed in the image
- name: Run a command in a pod
ansible.builtin.command: echo "Hello, World!"
changed_when: false
- name: Run a command in a pod using dynamic inventory
hosts: localhost
@@ -253,6 +255,7 @@ EXAMPLES = r"""
# be aware that the command is executed as the user that started the container
# and requires python to be installed in the image
ansible.builtin.command: echo "Hello, World!"
changed_when: false
delegate_to: "{{ my_app_pod_name }}"
"""
@@ -262,11 +265,11 @@ import os.path
import shutil
import subprocess
import tempfile
from shlex import quote as shlex_quote
from ansible.errors import AnsibleError, AnsibleFileNotFound
from ansible.module_utils._text import to_bytes
from ansible.module_utils.parsing.convert_bool import boolean
from ansible.module_utils.six.moves import shlex_quote
from ansible.parsing.yaml.loader import AnsibleLoader
from ansible.plugins.connection import BUFSIZE, ConnectionBase
from ansible.utils.display import Display
+32
View File
@@ -211,26 +211,58 @@ RETURN = """
import os
from ansible.errors import AnsibleError
from ansible.module_utils.ansible_release import __version__ as ansible_version
from ansible.module_utils.common._collections_compat import KeysView
from ansible.module_utils.common.validation import check_type_bool
from ansible.utils.display import Display
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
get_api_client,
)
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.resource import (
create_definitions,
)
from ansible_collections.kubernetes.core.plugins.module_utils.version import (
LooseVersion,
)
display = Display()
# cloud.common declares requires_ansible '>=2.15.0,<2.19'. On newer ansible-core the
# import still succeeds, so the version has to be checked explicitly: relying on
# ImportError alone lets turbo mode fail later with an unrelated traceback.
TURBO_UNSUPPORTED_CORE = "2.19.0"
try:
enable_turbo_mode = check_type_bool(os.environ.get("ENABLE_TURBO_MODE"))
except TypeError:
enable_turbo_mode = False
if enable_turbo_mode:
display.deprecated(
"ENABLE_TURBO_MODE is deprecated, as it relies on the cloud.common "
"collection which is being retired. Setting this environment "
"variable will have no effect once support is removed.",
version="8.0.0",
collection_name="kubernetes.core",
)
if LooseVersion(ansible_version) >= LooseVersion(TURBO_UNSUPPORTED_CORE):
display.warning(
"ENABLE_TURBO_MODE is ignored on ansible-core %s: Ansible Turbo mode requires "
"the cloud.common collection, which supports ansible-core < %s only. "
"Continuing without Turbo mode." % (ansible_version, TURBO_UNSUPPORTED_CORE)
)
enable_turbo_mode = False
if enable_turbo_mode:
try:
from ansible_collections.cloud.common.plugins.plugin_utils.turbo.lookup import (
TurboLookupBase as LookupBase,
)
except ImportError:
display.warning(
"ENABLE_TURBO_MODE is set but the cloud.common collection is not installed. "
"Continuing without Turbo mode."
)
from ansible.plugins.lookup import LookupBase # noqa: F401
else:
from ansible.plugins.lookup import LookupBase # noqa: F401
+30
View File
@@ -5,13 +5,39 @@ __metaclass__ = type
import os
from ansible.module_utils.ansible_release import __version__ as ansible_version
from ansible.module_utils.common.validation import check_type_bool
from ansible.module_utils.common.warnings import deprecate, warn
from ansible_collections.kubernetes.core.plugins.module_utils.version import (
LooseVersion,
)
# cloud.common declares requires_ansible '>=2.15.0,<2.19'. On newer ansible-core the
# import still succeeds, so the version has to be checked explicitly: relying on
# ImportError alone lets turbo mode fail later with an unrelated traceback.
TURBO_UNSUPPORTED_CORE = "2.19.0"
try:
enable_turbo_mode = check_type_bool(os.environ.get("ENABLE_TURBO_MODE"))
except TypeError:
enable_turbo_mode = False
if enable_turbo_mode:
deprecate(
"ENABLE_TURBO_MODE is deprecated, as it relies on the cloud.common collection "
"which is being retired. Setting this environment variable will have no effect "
"once support is removed.",
version="8.0.0",
collection_name="kubernetes.core",
)
if LooseVersion(ansible_version) >= LooseVersion(TURBO_UNSUPPORTED_CORE):
warn(
"ENABLE_TURBO_MODE is ignored on ansible-core %s: Ansible Turbo mode requires "
"the cloud.common collection, which supports ansible-core < %s only. "
"Continuing without Turbo mode." % (ansible_version, TURBO_UNSUPPORTED_CORE)
)
enable_turbo_mode = False
if enable_turbo_mode:
try:
from ansible_collections.cloud.common.plugins.module_utils.turbo.module import ( # noqa: F401
@@ -20,6 +46,10 @@ if enable_turbo_mode:
AnsibleModule.collection_name = "kubernetes.core"
except ImportError:
warn(
"ENABLE_TURBO_MODE is set but the cloud.common collection is not installed. "
"Continuing without Turbo mode."
)
from ansible.module_utils.basic import AnsibleModule # noqa: F401
else:
from ansible.module_utils.basic import AnsibleModule # noqa: F401
+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"]
+18 -3
View File
@@ -183,7 +183,7 @@ options:
wait_timeout:
description:
- Timeout when wait option is enabled (helm2 is a number of seconds, helm3 is a duration).
- The use of I(wait_timeout) to wait for kubernetes commands to complete has been deprecated and will be removed after 2022-12-01.
- The use of I(wait_timeout) to wait for kubernetes commands to complete has been deprecated and will be removed in version 7.0.0. Use O(timeout) instead.
type: str
timeout:
description:
@@ -396,8 +396,8 @@ status:
returned: always
description:
- Dict of Values used to deploy.
- This return value has been deprecated and will be removed in a release after
2027-01-08. Use RV(status.release_values) instead.
- This return value has been deprecated and will be removed in version 8.0.0.
Use RV(status.release_values) instead.
release_values:
type: dict
returned: always
@@ -486,6 +486,13 @@ def get_release_status(module, release_name, all_status=False):
release["release_values"] = module.get_values(release_name)
release["values"] = release["release_values"]
# Add deprecation warning for status.values
module.deprecate(
"The 'status.values' return value is deprecated and will be removed in version 8.0.0. Use 'status.release_values' instead.",
version="8.0.0",
collection_name="kubernetes.core",
)
return release
@@ -839,6 +846,14 @@ def main():
supports_check_mode=True,
)
# Add deprecation warning for wait_timeout
if module.params.get("wait_timeout") is not None:
module.deprecate(
"The 'wait_timeout' parameter is deprecated and will be removed in version 7.0.0. Use 'timeout' instead.",
version="7.0.0",
collection_name="kubernetes.core",
)
if not IMP_YAML:
module.fail_json(msg=missing_required_lib("yaml"), exception=IMP_YAML_ERR)
+10 -2
View File
@@ -119,8 +119,8 @@ status:
returned: always
description:
- Dict of Values used to deploy
- This return value has been deprecated and will be removed in a release after
2027-01-08. Use RV(status.release_values) instead.
- This return value has been deprecated and will be removed in version 8.0.0.
Use RV(status.release_values) instead.
release_values:
type: dict
returned: always
@@ -213,6 +213,14 @@ def get_release_status(module, release_name, release_state, get_all_values=False
release["release_values"] = module.get_values(release_name, get_all_values)
release["values"] = release["release_values"]
# Add deprecation warning for status.values
module.deprecate(
"The 'status.values' return value is deprecated and will be removed in version 8.0.0. Use 'status.release_values' instead.",
version="8.0.0",
collection_name="kubernetes.core",
)
release["manifest"] = module.get_manifest(release_name)
release["notes"] = module.get_notes(release_name)
release["hooks"] = module.get_hooks(release_name)
+3 -1
View File
@@ -302,6 +302,8 @@ def main():
repo_name = module.params.get("repo_name")
repo_url = module.params.get("repo_url")
if repo_url:
repo_url = repo_url.rstrip("/")
repo_username = module.params.get("repo_username")
repo_password = module.params.get("repo_password")
repo_state = module.params.get("repo_state")
@@ -329,7 +331,7 @@ def main():
insecure_skip_tls_verify,
)
changed = True
elif repository_status["url"] != repo_url:
elif repository_status["url"].rstrip("/") != repo_url:
module.fail_json(
msg="Repository already have a repository named {0}".format(repo_name)
)
+12 -12
View File
@@ -214,21 +214,21 @@ def filter_pods(pods, force, ignore_daemonset, delete_emptydir_data):
to_delete.append((pod.metadata.namespace, pod.metadata.name))
continue
# Pod with local storage cannot be deleted
if pod.spec.volumes and any(vol.empty_dir for vol in pod.spec.volumes):
localStorage.append((pod.metadata.namespace, pod.metadata.name))
continue
# Check replicated Pod
owner_ref = pod.metadata.owner_references
if not owner_ref:
owner_ref = pod.metadata.owner_references or []
has_local_storage = bool(
pod.spec.volumes and any(vol.empty_dir for vol in pod.spec.volumes)
)
is_daemonset_managed = any(owner.kind == "DaemonSet" for owner in owner_ref)
if is_daemonset_managed:
daemonSet.append((pod.metadata.namespace, pod.metadata.name))
elif has_local_storage:
localStorage.append((pod.metadata.namespace, pod.metadata.name))
elif not owner_ref:
unmanaged.append((pod.metadata.namespace, pod.metadata.name))
else:
for owner in owner_ref:
if owner.kind == "DaemonSet":
daemonSet.append((pod.metadata.namespace, pod.metadata.name))
else:
to_delete.append((pod.metadata.namespace, pod.metadata.name))
to_delete.append((pod.metadata.namespace, pod.metadata.name))
warnings, errors = [], []
if unmanaged:
+8 -1
View File
@@ -118,7 +118,7 @@ result:
type: int
version_added: 2.2.0
return_code:
description: The command status code. This attribute is deprecated and will be removed in a future release. Please use rc instead.
description: The command status code. This attribute is deprecated and will be removed in version 7.0.0. Use RV(result.rc) instead.
type: int
"""
@@ -219,6 +219,13 @@ def execute_module(module, client):
else:
rc = int(err["details"]["causes"][0]["message"])
# Add deprecation warning for return_code return value
module.deprecate(
"The 'return_code' return value is deprecated and will be removed in version 7.0.0. Use 'rc' instead.",
version="7.0.0",
collection_name="kubernetes.core",
)
module.exit_json(
# Some command might change environment, but ultimately failing at end
changed=True,
+15
View File
@@ -120,6 +120,21 @@ EXAMPLES = r"""
namespace: default
wait_sleep: 10
wait_timeout: 360
- name: Wait for OpenShift bootstrap to complete
kubernetes.core.k8s_info:
api_version: v1
kind: ConfigMap
name: bootstrap
namespace: kube-system
register: ocp_bootstrap_status
until: >
ocp_bootstrap_status.resources is defined and
(ocp_bootstrap_status.resources | length > 0) and
(ocp_bootstrap_status.resources[0].data.status is defined) and
(ocp_bootstrap_status.resources[0].data.status == 'complete')
retries: 60
delay: 15
"""
RETURN = r"""
+10
View File
@@ -36,6 +36,7 @@ options:
- If more than one C(merge_type) is given, the merge_types will be tried in order
- This defaults to C(['strategic-merge', 'merge']), which is ideal for using the same parameters
on resource kinds that combine Custom Resources and built-in resources.
- I(merge_type=json) has been deprecated and will be removed in version 7.0.0. Use M(kubernetes.core.k8s_json_patch) instead.
choices:
- json
- merge
@@ -251,6 +252,15 @@ def main():
supports_check_mode=True,
)
# Add deprecation warning for merge_type=json
merge_type = module.params.get("merge_type")
if merge_type and "json" in merge_type:
module.deprecate(
"The 'merge_type=json' option is deprecated and will be removed in version 7.0.0. Use the 'kubernetes.core.k8s_json_patch' module instead.",
version="7.0.0",
collection_name="kubernetes.core",
)
try:
client = get_api_client(module=module)
svc = K8sService(client, module)
+47
View File
@@ -0,0 +1,47 @@
# SonarCloud project configuration for kubernetes.core
# Parameters: https://docs.sonarqube.org/latest/analysis/analysis-parameters/
sonar.projectKey=ansible-collections_kubernetes.core
sonar.organization=ansible-collections
sonar.sources=.
sonar.projectName=kubernetes.core
sonar.python.coverage.reportPaths=coverage.xml
sonar.tests=tests/unit,tests/integration
sonar.python.version=3.12
sonar.newCode.referenceBranch=stable-5
sonar.exclusions=tests/**,.tox/**
# Exclude test code from copy/paste detection. 'sonar.exclusions' above only
# filters the *source* set (it disambiguates 'sonar.sources=.' from
# 'sonar.tests'), so test files are still indexed as tests and still scored for
# duplication. Unit tests here are unittest.TestCase classes: every class needs
# its own setUp, and per-case arrange/assert blocks are deliberately repeated so
# a failing test reads on its own. Because SonarCloud scores only *new code* on
# a pull request, any PR adding cases to an already-repetitive test module
# inherits duplication accrued across earlier PRs. Production code under
# plugins/ stays fully covered by duplication analysis.
sonar.cpd.exclusions=tests/**
# Ansible module argument_spec is conventionally defined with the dict(...)
# 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.ruleKey=python:S7498
sonar.issue.ignore.multicriteria.e1.resourceKey=**/*.py
# Unit tests pass hardcoded '/tmp/...' strings as fake module arguments (e.g.
# chart_ref) to fully mocked commands; no file is ever created there. Suppress
# python:S5443 ("temporary files in publicly writable directories") for test
# code only. Production code creates temp files via tempfile.mkstemp /
# NamedTemporaryFile and stays covered by the rule.
sonar.issue.ignore.multicriteria.e2.ruleKey=python:S5443
sonar.issue.ignore.multicriteria.e2.resourceKey=tests/**/*.py
# GitHub Actions workflows in this repo use @main for internal reusable actions
# (ansible-network/github_actions, ansible-collections/cloud-content-ci-automation)
# 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
+1 -1
View File
@@ -1,2 +1,2 @@
modules:
python_requires: ">=3.6"
python_requires: ">=3.9"
@@ -239,6 +239,7 @@
vars:
chart_local_path: '{{ _tmpd.path }}/test-chart-deployment-time'
chart_repo_path: 'testing'
helm_binary_path: "{{ helm_binary }}"
always:
- name: Delete temporary directory
ansible.builtin.file:
@@ -4,6 +4,9 @@
username: testuser
password: testpassword
wrong_password: 'WrongPassword'
# Use the helm binary installed by the install_helm role rather than the one
# shipped with the CI image, whose version is outside of our control.
helm_binary: "/tmp/helm/{{ ansible_system | lower }}-amd64/helm"
registry_name: oci_registry
registry_port: 5000
test_chart: https://github.com/grafana/helm-charts/releases/download/k8s-monitoring-1.6.8/k8s-monitoring-1.6.8.tgz
@@ -4,7 +4,7 @@
# and it allow to not install any additional dependencies
block:
- name: Ensure that helm is installed
ansible.builtin.shell: helm version --client --short | grep v3
ansible.builtin.shell: "{{ helm_binary }} version --client --short | grep v3"
register: _helm_version
failed_when: _helm_version.rc != 0
@@ -44,14 +44,14 @@
- name: Test the registry with correct credentials to ensure that the registry is running
ansible.builtin.shell: >-
echo {{ password | quote }} | helm registry login localhost:{{ registry_port }}
echo {{ password | quote }} | {{ helm_binary }} registry login localhost:{{ registry_port }}
-u {{ username }} --password-stdin
register: _login_correct
failed_when: _login_correct.rc != 0
- name: Clean up credentials to run test on clean environment
ansible.builtin.shell: >-
helm registry logout localhost:{{ registry_port }}
{{ helm_binary }} registry logout localhost:{{ registry_port }}
register: _logout
failed_when: _logout.rc != 0
@@ -70,6 +70,7 @@
- name: Test module helm_registry_auth with correct credentials
helm_registry_auth:
binary_path: "{{ helm_binary }}"
username: "{{ username }}"
password: "{{ password }}"
host: localhost:{{ registry_port }}
@@ -87,7 +88,7 @@
- name: Ensure that push to the registry is working
ansible.builtin.shell: >-
helm push "{{ _destination.path }}/k8s-monitoring-1.6.8.tgz" oci://localhost:{{ registry_port }}/test/
{{ helm_binary }} push "{{ _destination.path }}/k8s-monitoring-1.6.8.tgz" oci://localhost:{{ registry_port }}/test/
register: _save_chart
failed_when: _save_chart.rc != 0
@@ -99,6 +100,7 @@
- name: Test logout
helm_registry_auth:
binary_path: "{{ helm_binary }}"
host: localhost:{{ registry_port }}
state: absent
register: _helm_registry_auth_logout
@@ -114,6 +116,7 @@
- name: Test logout idempotency
helm_registry_auth:
binary_path: "{{ helm_binary }}"
host: localhost:{{ registry_port }}
state: absent
register: _helm_registry_auth_logout_idempotency
@@ -124,7 +127,7 @@
- name: Ensure that not able to push to the registry
ansible.builtin.shell: >-
helm push "{{ _destination.path }}/k8s-monitoring-1.6.8.tgz" oci://localhost:{{ registry_port }}/test/
{{ helm_binary }} push "{{ _destination.path }}/k8s-monitoring-1.6.8.tgz" oci://localhost:{{ registry_port }}/test/
register: _save_chart
failed_when: _save_chart.rc == 0
@@ -143,6 +146,7 @@
- name: Test module helm_registry_auth with wrong credentials
helm_registry_auth:
binary_path: "{{ helm_binary }}"
username: "{{ username }}"
password: "{{ wrong_password }}"
host: localhost:{{ registry_port }}
@@ -99,3 +99,81 @@
binary_path: "{{ helm_binary }}"
name: test_helm_repo
state: absent
# https://github.com/ansible-collections/kubernetes.core/issues/1235
- name: Ensure the trailing slash test repositories don't exist
helm_repository:
binary_path: "{{ helm_binary }}"
name: "{{ item }}"
state: absent
loop:
- test_helm_repo_slash
- test_helm_repo_noslash
- name: Register test_helm_repo_slash directly through helm, keeping the trailing slash
ansible.builtin.command: "{{ helm_binary }} repo add test_helm_repo_slash {{ chart_test_repo }}/"
changed_when: true
- name: Add test_helm_repo_noslash chart repository without a trailing slash
helm_repository:
binary_path: "{{ helm_binary }}"
name: test_helm_repo_noslash
repo_url: "{{ chart_test_repo }}"
- name: Check idempotency when the stored and the requested URL both have a trailing slash
helm_repository:
binary_path: "{{ helm_binary }}"
name: test_helm_repo_slash
repo_url: "{{ chart_test_repo }}/"
register: repository
- name: Assert idempotency when the stored and the requested URL both have a trailing slash
assert:
that:
- repository is not changed
- name: Check idempotency when only the stored URL has a trailing slash
helm_repository:
binary_path: "{{ helm_binary }}"
name: test_helm_repo_slash
repo_url: "{{ chart_test_repo }}"
register: repository
- name: Assert idempotency when only the stored URL has a trailing slash
assert:
that:
- repository is not changed
- name: Check idempotency when only the requested URL has a trailing slash
helm_repository:
binary_path: "{{ helm_binary }}"
name: test_helm_repo_noslash
repo_url: "{{ chart_test_repo }}/"
register: repository
- name: Assert idempotency when only the requested URL has a trailing slash
assert:
that:
- repository is not changed
- name: Failed to add repository with the same name and a different URL, trailing slash aside
helm_repository:
binary_path: "{{ helm_binary }}"
name: test_helm_repo_slash
repo_url: "https://other-charts.url/"
register: repository_errors
ignore_errors: true
- name: Assert that adding repository with the same name and a different URL failed
assert:
that:
- repository_errors is failed
- name: Clean the trailing slash test repositories
helm_repository:
binary_path: "{{ helm_binary }}"
name: "{{ item }}"
state: absent
loop:
- test_helm_repo_slash
- test_helm_repo_noslash
@@ -238,7 +238,55 @@
- resource.result.results | selectattr('changed') | list | length == 1
- resource.result.results | selectattr('error', 'defined') | list | length == 1
- name: Apply template where all items are disabled (empty output)
kubernetes.core.k8s:
state: present
template:
path: "conditional_empty.j2"
vars:
items:
- name: test1
enabled: false
- name: test2
enabled: false
k8s_pod_namespace: "{{ template_namespace }}"
register: r
- name: Check that empty template succeeds with no changes
assert:
that:
- r is successful
- r is not changed
- name: Apply template where some items are enabled
kubernetes.core.k8s:
state: present
template:
path: "conditional_empty.j2"
vars:
items:
- name: conditional-configmap-1
enabled: true
- name: conditional-configmap-2
enabled: false
k8s_pod_namespace: "{{ template_namespace }}"
register: r
- name: Check that partial template creates resources
assert:
that:
- r is successful
- r is changed
always:
- name: Cleanup conditional configmap
kubernetes.core.k8s:
state: absent
kind: ConfigMap
name: conditional-configmap-1
namespace: "{{ template_namespace }}"
ignore_errors: true
- name: Remove namespace (Cleanup)
kubernetes.core.k8s:
kind: Namespace
@@ -0,0 +1,12 @@
{% for item in items %}
{% if item.enabled %}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: "{{ item.name }}"
namespace: "{{ k8s_pod_namespace }}"
data:
key: value
{% endif %}
{% endfor %}
+6
View File
@@ -1,9 +1,15 @@
plugins/module_utils/client/discovery.py import-3.9!skip
plugins/module_utils/client/discovery.py import-3.10!skip
plugins/module_utils/client/discovery.py import-3.11!skip
plugins/module_utils/client/discovery.py import-3.12!skip
plugins/module_utils/client/discovery.py import-3.13!skip
plugins/module_utils/client/resource.py import-3.9!skip
plugins/module_utils/client/resource.py import-3.10!skip
plugins/module_utils/client/resource.py import-3.11!skip
plugins/module_utils/client/resource.py import-3.12!skip
plugins/module_utils/client/resource.py import-3.13!skip
plugins/module_utils/k8sdynamicclient.py import-3.9!skip
plugins/module_utils/k8sdynamicclient.py import-3.10!skip
plugins/module_utils/k8sdynamicclient.py import-3.11!skip
plugins/module_utils/k8sdynamicclient.py import-3.12!skip
plugins/module_utils/k8sdynamicclient.py import-3.13!skip
+6
View File
@@ -1,9 +1,15 @@
plugins/module_utils/client/discovery.py import-3.9!skip
plugins/module_utils/client/discovery.py import-3.10!skip
plugins/module_utils/client/discovery.py import-3.11!skip
plugins/module_utils/client/discovery.py import-3.12!skip
plugins/module_utils/client/discovery.py import-3.13!skip
plugins/module_utils/client/resource.py import-3.9!skip
plugins/module_utils/client/resource.py import-3.10!skip
plugins/module_utils/client/resource.py import-3.11!skip
plugins/module_utils/client/resource.py import-3.12!skip
plugins/module_utils/client/resource.py import-3.13!skip
plugins/module_utils/k8sdynamicclient.py import-3.9!skip
plugins/module_utils/k8sdynamicclient.py import-3.10!skip
plugins/module_utils/k8sdynamicclient.py import-3.11!skip
plugins/module_utils/k8sdynamicclient.py import-3.12!skip
plugins/module_utils/k8sdynamicclient.py import-3.13!skip
+6
View File
@@ -1,11 +1,17 @@
plugins/module_utils/client/discovery.py import-3.9!skip
plugins/module_utils/client/discovery.py import-3.10!skip
plugins/module_utils/client/discovery.py import-3.11!skip
plugins/module_utils/client/discovery.py import-3.12!skip
plugins/module_utils/client/discovery.py import-3.13!skip
plugins/module_utils/client/discovery.py import-3.14!skip
plugins/module_utils/client/resource.py import-3.9!skip
plugins/module_utils/client/resource.py import-3.10!skip
plugins/module_utils/client/resource.py import-3.11!skip
plugins/module_utils/client/resource.py import-3.12!skip
plugins/module_utils/client/resource.py import-3.13!skip
plugins/module_utils/client/resource.py import-3.14!skip
plugins/module_utils/k8sdynamicclient.py import-3.9!skip
plugins/module_utils/k8sdynamicclient.py import-3.10!skip
plugins/module_utils/k8sdynamicclient.py import-3.11!skip
plugins/module_utils/k8sdynamicclient.py import-3.12!skip
plugins/module_utils/k8sdynamicclient.py import-3.13!skip
+6
View File
@@ -1,11 +1,17 @@
plugins/module_utils/client/discovery.py import-3.9!skip
plugins/module_utils/client/discovery.py import-3.10!skip
plugins/module_utils/client/discovery.py import-3.11!skip
plugins/module_utils/client/discovery.py import-3.12!skip
plugins/module_utils/client/discovery.py import-3.13!skip
plugins/module_utils/client/discovery.py import-3.14!skip
plugins/module_utils/client/resource.py import-3.9!skip
plugins/module_utils/client/resource.py import-3.10!skip
plugins/module_utils/client/resource.py import-3.11!skip
plugins/module_utils/client/resource.py import-3.12!skip
plugins/module_utils/client/resource.py import-3.13!skip
plugins/module_utils/client/resource.py import-3.14!skip
plugins/module_utils/k8sdynamicclient.py import-3.9!skip
plugins/module_utils/k8sdynamicclient.py import-3.10!skip
plugins/module_utils/k8sdynamicclient.py import-3.11!skip
plugins/module_utils/k8sdynamicclient.py import-3.12!skip
plugins/module_utils/k8sdynamicclient.py import-3.13!skip
+44
View File
@@ -0,0 +1,44 @@
plugins/module_utils/client/discovery.py import-3.9!skip
plugins/module_utils/client/discovery.py import-3.10!skip
plugins/module_utils/client/discovery.py import-3.11!skip
plugins/module_utils/client/discovery.py import-3.12!skip
plugins/module_utils/client/discovery.py import-3.13!skip
plugins/module_utils/client/discovery.py import-3.14!skip
plugins/module_utils/client/discovery.py import-3.15!skip
plugins/module_utils/client/resource.py import-3.9!skip
plugins/module_utils/client/resource.py import-3.10!skip
plugins/module_utils/client/resource.py import-3.11!skip
plugins/module_utils/client/resource.py import-3.12!skip
plugins/module_utils/client/resource.py import-3.13!skip
plugins/module_utils/client/resource.py import-3.14!skip
plugins/module_utils/client/resource.py import-3.15!skip
plugins/module_utils/k8sdynamicclient.py import-3.9!skip
plugins/module_utils/k8sdynamicclient.py import-3.10!skip
plugins/module_utils/k8sdynamicclient.py import-3.11!skip
plugins/module_utils/k8sdynamicclient.py import-3.12!skip
plugins/module_utils/k8sdynamicclient.py import-3.13!skip
plugins/module_utils/k8sdynamicclient.py import-3.14!skip
plugins/module_utils/k8sdynamicclient.py import-3.15!skip
plugins/module_utils/version.py pylint!skip
plugins/modules/k8s.py validate-modules:parameter-type-not-in-doc
plugins/modules/k8s_scale.py validate-modules:parameter-type-not-in-doc
plugins/modules/k8s_service.py validate-modules:parameter-type-not-in-doc
tests/unit/module_utils/fixtures/clusteroperator.yml yamllint!skip
tests/unit/module_utils/fixtures/definitions.yml yamllint!skip
tests/unit/module_utils/fixtures/deployments.yml yamllint!skip
tests/integration/targets/k8s_delete/files/deployments.yaml yamllint!skip
tests/unit/module_utils/fixtures/pods.yml yamllint!skip
tests/integration/targets/helm/files/appversionless-chart-v2/templates/configmap.yaml yamllint!skip
tests/integration/targets/helm/files/appversionless-chart/templates/configmap.yaml yamllint!skip
tests/integration/targets/helm/files/test-chart-v2/templates/configmap.yaml yamllint!skip
tests/integration/targets/helm/files/test-chart/templates/configmap.yaml yamllint!skip
tests/integration/targets/helm_diff/files/test-chart/templates/configmap.yaml yamllint!skip
tests/integration/targets/k8s_scale/files/deployment.yaml yamllint!skip
plugins/modules/k8s.py validate-modules:return-syntax-error
plugins/modules/k8s_scale.py validate-modules:return-syntax-error
plugins/modules/k8s_service.py validate-modules:return-syntax-error
plugins/modules/k8s_taint.py validate-modules:return-syntax-error
tests/integration/targets/helm_diff/files/test-chart-reuse-values/templates/configmap.yaml yamllint!skip
tests/integration/targets/helm_diff/files/test-chart-deployment-time/templates/configmap.yaml yamllint!skip
plugins/modules/helm.py validate-modules:bad-return-value-key
plugins/modules/helm_info.py validate-modules:bad-return-value-key
+43
View File
@@ -0,0 +1,43 @@
plugins/module_utils/client/discovery.py import-3.9!skip
plugins/module_utils/client/discovery.py import-3.10!skip
plugins/module_utils/client/discovery.py import-3.11!skip
plugins/module_utils/client/discovery.py import-3.12!skip
plugins/module_utils/client/discovery.py import-3.13!skip
plugins/module_utils/client/discovery.py import-3.14!skip
plugins/module_utils/client/discovery.py import-3.15!skip
plugins/module_utils/client/resource.py import-3.9!skip
plugins/module_utils/client/resource.py import-3.10!skip
plugins/module_utils/client/resource.py import-3.11!skip
plugins/module_utils/client/resource.py import-3.12!skip
plugins/module_utils/client/resource.py import-3.13!skip
plugins/module_utils/client/resource.py import-3.14!skip
plugins/module_utils/client/resource.py import-3.15!skip
plugins/module_utils/k8sdynamicclient.py import-3.9!skip
plugins/module_utils/k8sdynamicclient.py import-3.10!skip
plugins/module_utils/k8sdynamicclient.py import-3.11!skip
plugins/module_utils/k8sdynamicclient.py import-3.12!skip
plugins/module_utils/k8sdynamicclient.py import-3.13!skip
plugins/module_utils/k8sdynamicclient.py import-3.14!skip
plugins/module_utils/k8sdynamicclient.py import-3.15!skip
plugins/modules/k8s.py validate-modules:parameter-type-not-in-doc
plugins/modules/k8s_scale.py validate-modules:parameter-type-not-in-doc
plugins/modules/k8s_service.py validate-modules:parameter-type-not-in-doc
tests/unit/module_utils/fixtures/clusteroperator.yml yamllint!skip
tests/unit/module_utils/fixtures/definitions.yml yamllint!skip
tests/unit/module_utils/fixtures/deployments.yml yamllint!skip
tests/integration/targets/k8s_delete/files/deployments.yaml yamllint!skip
tests/unit/module_utils/fixtures/pods.yml yamllint!skip
tests/integration/targets/helm/files/appversionless-chart-v2/templates/configmap.yaml yamllint!skip
tests/integration/targets/helm/files/appversionless-chart/templates/configmap.yaml yamllint!skip
tests/integration/targets/helm/files/test-chart-v2/templates/configmap.yaml yamllint!skip
tests/integration/targets/helm/files/test-chart/templates/configmap.yaml yamllint!skip
tests/integration/targets/helm_diff/files/test-chart/templates/configmap.yaml yamllint!skip
tests/integration/targets/k8s_scale/files/deployment.yaml yamllint!skip
plugins/modules/k8s.py validate-modules:return-syntax-error
plugins/modules/k8s_scale.py validate-modules:return-syntax-error
plugins/modules/k8s_service.py validate-modules:return-syntax-error
plugins/modules/k8s_taint.py validate-modules:return-syntax-error
tests/integration/targets/helm_diff/files/test-chart-reuse-values/templates/configmap.yaml yamllint!skip
tests/integration/targets/helm_diff/files/test-chart-deployment-time/templates/configmap.yaml yamllint!skip
plugins/modules/helm.py validate-modules:bad-return-value-key
plugins/modules/helm_info.py validate-modules:bad-return-value-key
+21 -14
View File
@@ -57,6 +57,11 @@ def _create_temp_file(content=""):
return name
def _assert_configuration(actual, expected):
for key, value in expected.items():
assert getattr(actual, key) == value
def test_create_auth_spec_ssl_no_options():
module = MagicMock()
module.params = {}
@@ -138,13 +143,14 @@ def test_load_kube_config_from_file_path():
auth = {"kubeconfig": config_file, "context": "simple_token"}
actual_configuration = _create_configuration(auth)
expected_configuration = {
"host": TEST_HOST,
"kubeconfig": config_file,
"context": "simple_token",
}
assert expected_configuration.items() <= actual_configuration.__dict__.items()
_assert_configuration(
actual_configuration,
{
"host": TEST_HOST,
"kubeconfig": config_file,
"context": "simple_token",
},
)
_remove_temp_file()
@@ -152,13 +158,14 @@ def test_load_kube_config_from_dict():
auth_spec = {"kubeconfig": TEST_KUBE_CONFIG, "context": "simple_token"}
actual_configuration = _create_configuration(auth_spec)
expected_configuration = {
"host": TEST_HOST,
"kubeconfig": TEST_KUBE_CONFIG,
"context": "simple_token",
}
assert expected_configuration.items() <= actual_configuration.__dict__.items()
_assert_configuration(
actual_configuration,
{
"host": TEST_HOST,
"kubeconfig": TEST_KUBE_CONFIG,
"context": "simple_token",
},
)
_remove_temp_file()
@@ -0,0 +1,89 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type
import sys
from unittest.mock import MagicMock, patch
import pytest
from ansible.plugins.lookup import LookupBase as StandardLookupBase
class TestK8sTurboMode:
"""Test turbo mode version checking in k8s lookup plugin."""
@pytest.fixture(autouse=True)
def cleanup_k8s_module(self):
"""Ensure clean module state before each test."""
sys.modules.pop("ansible_collections.kubernetes.core.plugins.lookup.k8s", None)
@pytest.mark.parametrize("ansible_version", ["2.19.0", "2.21.4"])
def test_turbo_mode_disabled_on_newer_ansible(self, monkeypatch, ansible_version):
"""Test that turbo mode is disabled on ansible-core >= 2.19.0."""
monkeypatch.setenv("ENABLE_TURBO_MODE", "true")
mock_display = MagicMock()
with patch.dict(
"sys.modules",
{
"ansible.module_utils.ansible_release": MagicMock(
__version__=ansible_version
),
"ansible.utils.display": MagicMock(Display=lambda: mock_display),
},
):
from ansible_collections.kubernetes.core.plugins.lookup import k8s
mock_display.deprecated.assert_called()
assert (
"ENABLE_TURBO_MODE is deprecated"
in mock_display.deprecated.call_args[0][0]
)
mock_display.warning.assert_called()
assert (
f"ENABLE_TURBO_MODE is ignored on ansible-core {ansible_version}"
in mock_display.warning.call_args[0][0]
)
assert "ansible-core < 2.19.0 only" in mock_display.warning.call_args[0][0]
assert k8s.LookupBase == StandardLookupBase
def test_turbo_mode_enabled_on_ansible_core_2_18(self, monkeypatch):
"""Test that turbo mode is still enabled on ansible-core < 2.19.0."""
monkeypatch.setenv("ENABLE_TURBO_MODE", "true")
mock_display = MagicMock()
mock_turbo_lookup = MagicMock()
with patch.dict(
"sys.modules",
{
"ansible.module_utils.ansible_release": MagicMock(__version__="2.18.0"),
"ansible.utils.display": MagicMock(Display=lambda: mock_display),
"ansible_collections.cloud.common.plugins.plugin_utils.turbo.lookup": mock_turbo_lookup,
},
):
from ansible_collections.kubernetes.core.plugins.lookup import ( # noqa: F401
k8s,
)
mock_display.deprecated.assert_called()
assert not mock_display.warning.called
def test_turbo_mode_disabled_when_env_not_set(self, monkeypatch):
"""Test that turbo mode is disabled when ENABLE_TURBO_MODE is not set."""
monkeypatch.delenv("ENABLE_TURBO_MODE", raising=False)
mock_display = MagicMock()
with patch.dict(
"sys.modules",
{
"ansible.module_utils.ansible_release": MagicMock(__version__="2.18.0"),
"ansible.utils.display": MagicMock(Display=lambda: mock_display),
},
):
from ansible_collections.kubernetes.core.plugins.lookup import k8s
mock_display.deprecated.assert_not_called()
mock_display.warning.assert_not_called()
assert k8s.LookupBase == StandardLookupBase
+1
View File
@@ -1,3 +1,4 @@
pytest
pytest-cov
PyYAML
kubernetes