mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-11 20:12:18 +00:00
Compare commits
76 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
96464f1ea8 | ||
|
|
fe4858d556 | ||
|
|
07e8a76f2d | ||
|
|
0488b79f0f | ||
|
|
4fa6465f3e | ||
|
|
e1b341d9be | ||
|
|
8feb564b4d | ||
|
|
42832bc9d2 | ||
|
|
19b2efd0dd | ||
|
|
1c3bf95b74 | ||
|
|
018c92429b | ||
|
|
9267e03538 | ||
|
|
eb3ab99709 | ||
|
|
a1ac6b99dc | ||
|
|
4ad57fdb6c | ||
|
|
ee9939c54f | ||
|
|
c1549db1bb | ||
|
|
c6bd8ab453 | ||
|
|
6299f242a2 | ||
|
|
cd55f596ab | ||
|
|
00bbf16cff | ||
|
|
31fd4058f1 | ||
|
|
5c748bd4e9 | ||
|
|
1c295560ba | ||
|
|
615d3d8bd0 | ||
|
|
4854d7fbd9 | ||
|
|
baa59f388c | ||
|
|
e071ae73b6 | ||
|
|
00cb40094a | ||
|
|
ef829b8a56 | ||
|
|
d86a652c36 | ||
|
|
a4242f0131 | ||
|
|
d75e9a0fa3 | ||
|
|
5044cfc030 | ||
|
|
ddd7e79a12 | ||
|
|
edc979ff11 | ||
|
|
37c1f911cb | ||
|
|
80a5bf623a | ||
|
|
8f653558f6 | ||
|
|
1c0734dd4e | ||
|
|
e6d138dbf0 | ||
|
|
eed4ebb0af | ||
|
|
d3031fcbd3 | ||
|
|
e756cedf33 | ||
|
|
1a601213eb | ||
|
|
abb9e0b6d5 | ||
|
|
bdd429981c | ||
|
|
6956a77f8c | ||
|
|
1670e35cd8 | ||
|
|
b44fdd3f05 | ||
|
|
b066a2dda3 | ||
|
|
9e9962bc6c | ||
|
|
9ca13c3799 | ||
|
|
318529abaa | ||
|
|
6d0a3af311 | ||
|
|
54d8193972 | ||
|
|
a624251bba | ||
|
|
869f06f1e4 | ||
|
|
7919231df1 | ||
|
|
ea28cbaa59 | ||
|
|
560e0e3d40 | ||
|
|
ed09047699 | ||
|
|
2d1ec22405 | ||
|
|
71599e2fde | ||
|
|
8687994e9f | ||
|
|
8640c16cd4 | ||
|
|
deb4859f19 | ||
|
|
fb2af07583 | ||
|
|
151ed8245f | ||
|
|
09a3c837c3 | ||
|
|
31c1ccf962 | ||
|
|
031cc7c40d | ||
|
|
22764492d2 | ||
|
|
3d313cf837 | ||
|
|
deaf8ee4f3 | ||
|
|
0f7963beb9 |
7
.ansible-lint-ignore
Normal file
7
.ansible-lint-ignore
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# https://docs.ansible.com/ansible-lint/docs/rules/
|
||||||
|
# no-changed-when is not requried for examples
|
||||||
|
plugins/connection/kubectl.py no-changed-when
|
||||||
|
# false positive result
|
||||||
|
plugins/connection/kubectl.py var-naming[no-reserved]
|
||||||
|
# stable-3 branch support ansible-core>=2.14.0
|
||||||
|
meta/runtime.yml meta-runtime[unsupported-version]
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
---
|
---
|
||||||
profile: production
|
profile: production
|
||||||
skip_list:
|
|
||||||
- meta-runtime[unsupported-version]
|
|
||||||
exclude_paths:
|
exclude_paths:
|
||||||
|
- .ansible/
|
||||||
- tests/integration
|
- tests/integration
|
||||||
|
- tests/unit
|
||||||
- tests/sanity
|
- tests/sanity
|
||||||
59
.github/stale.yml
vendored
59
.github/stale.yml
vendored
@@ -1,59 +0,0 @@
|
|||||||
---
|
|
||||||
# Configuration for probot-stale - https://github.com/probot/stale
|
|
||||||
|
|
||||||
# Number of days of inactivity before an Issue or Pull Request becomes stale
|
|
||||||
daysUntilStale: 90
|
|
||||||
|
|
||||||
# Number of days of inactivity before an Issue or Pull Request with the stale
|
|
||||||
# label is closed. Set to false to disable. If disabled, issues still need to be
|
|
||||||
# closed manually, but will remain marked as stale.
|
|
||||||
daysUntilClose: 30
|
|
||||||
|
|
||||||
# Only issues or pull requests with all of these labels are check if stale.
|
|
||||||
# Defaults to `[]` (disabled)
|
|
||||||
onlyLabels: []
|
|
||||||
# Issues or Pull Requests with these labels will never be considered stale. Set
|
|
||||||
# to `[]` to disable
|
|
||||||
exemptLabels:
|
|
||||||
- security
|
|
||||||
- planned
|
|
||||||
- priority/critical
|
|
||||||
- lifecycle/frozen
|
|
||||||
- verified
|
|
||||||
|
|
||||||
# Set to true to ignore issues in a project (defaults to false)
|
|
||||||
exemptProjects: false
|
|
||||||
|
|
||||||
# Set to true to ignore issues in a milestone (defaults to false)
|
|
||||||
exemptMilestones: true
|
|
||||||
|
|
||||||
# Set to true to ignore issues with an assignee (defaults to false)
|
|
||||||
exemptAssignees: false
|
|
||||||
|
|
||||||
# Label to use when marking as stale
|
|
||||||
staleLabel: lifecycle/stale
|
|
||||||
|
|
||||||
# Limit the number of actions per hour, from 1-30. Default is 30
|
|
||||||
limitPerRun: 30
|
|
||||||
|
|
||||||
pulls:
|
|
||||||
markComment: |-
|
|
||||||
PRs go stale after 90 days of inactivity.
|
|
||||||
If there is no further activity, the PR will be closed in another 30 days.
|
|
||||||
|
|
||||||
unmarkComment: >-
|
|
||||||
This pull request is no longer stale.
|
|
||||||
|
|
||||||
closeComment: >-
|
|
||||||
This pull request has been closed due to inactivity.
|
|
||||||
|
|
||||||
issues:
|
|
||||||
markComment: |-
|
|
||||||
Issues go stale after 90 days of inactivity.
|
|
||||||
If there is no further activity, the issue will be closed in another 30 days.
|
|
||||||
|
|
||||||
unmarkComment: >-
|
|
||||||
This issue is no longer stale.
|
|
||||||
|
|
||||||
closeComment: >-
|
|
||||||
This issue has been closed due to inactivity.
|
|
||||||
18
.github/workflows/integration-tests.yaml
vendored
18
.github/workflows/integration-tests.yaml
vendored
@@ -50,6 +50,7 @@ jobs:
|
|||||||
source: "./source"
|
source: "./source"
|
||||||
cloud_common: "./cloudcommon"
|
cloud_common: "./cloudcommon"
|
||||||
ansible_posix: "./ansible_posix"
|
ansible_posix: "./ansible_posix"
|
||||||
|
community_general: "./community_general"
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -61,7 +62,7 @@ jobs:
|
|||||||
- true
|
- true
|
||||||
- false
|
- false
|
||||||
workflow-id: ${{ fromJson(needs.splitter.outputs.test_jobs) }}
|
workflow-id: ${{ fromJson(needs.splitter.outputs.test_jobs) }}
|
||||||
name: "integration-py${{ matrix.python-version }}-${{ matrix.ansible-version }}-${{ matrix.workflow-id }}"
|
name: "integration-py${{ matrix.python-version }}-${{ matrix.ansible-version }}-${{ matrix.workflow-id }}-enable_turbo=${{ matrix.enable-turbo-mode }}"
|
||||||
steps:
|
steps:
|
||||||
- name: Read target
|
- name: Read target
|
||||||
id: read-targets
|
id: read-targets
|
||||||
@@ -118,6 +119,13 @@ jobs:
|
|||||||
path: ${{ env.ansible_posix }}
|
path: ${{ env.ansible_posix }}
|
||||||
ref: main
|
ref: main
|
||||||
|
|
||||||
|
- name: checkout ansible-collections/community.general
|
||||||
|
uses: ansible-network/github_actions/.github/actions/checkout_dependency@main
|
||||||
|
with:
|
||||||
|
repository: ansible-collections/community.general
|
||||||
|
path: ${{ env.community_general }}
|
||||||
|
ref: main
|
||||||
|
|
||||||
- name: install cloud.common collection
|
- name: install cloud.common collection
|
||||||
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
|
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
|
||||||
with:
|
with:
|
||||||
@@ -130,8 +138,16 @@ jobs:
|
|||||||
install_python_dependencies: true
|
install_python_dependencies: true
|
||||||
source_path: ${{ env.ansible_posix }}
|
source_path: ${{ env.ansible_posix }}
|
||||||
|
|
||||||
|
- name: install community.general collection
|
||||||
|
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
|
||||||
|
with:
|
||||||
|
install_python_dependencies: false
|
||||||
|
source_path: ${{ env.community_general }}
|
||||||
|
|
||||||
- name: create kubernetes cluster
|
- name: create kubernetes cluster
|
||||||
uses: helm/kind-action@v1.8.0
|
uses: helm/kind-action@v1.8.0
|
||||||
|
with:
|
||||||
|
node_image: "kindest/node:v1.29.2"
|
||||||
|
|
||||||
- name: Run integration tests
|
- name: Run integration tests
|
||||||
uses: ansible-network/github_actions/.github/actions/ansible_test_integration@main
|
uses: ansible-network/github_actions/.github/actions/ansible_test_integration@main
|
||||||
|
|||||||
7
.github/workflows/linters.yaml
vendored
7
.github/workflows/linters.yaml
vendored
@@ -10,7 +10,7 @@ on:
|
|||||||
- main
|
- main
|
||||||
- stable-*
|
- stable-*
|
||||||
tags:
|
tags:
|
||||||
- "*"
|
- '*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
linters:
|
linters:
|
||||||
@@ -19,6 +19,5 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
- name: run-ansible-lint
|
||||||
- name: Run ansible-lint
|
uses: ansible/ansible-lint@v25.1.2
|
||||||
uses: ansible/ansible-lint@v6.21.0
|
|
||||||
|
|||||||
1
.github/workflows/unit-tests.yaml
vendored
1
.github/workflows/unit-tests.yaml
vendored
@@ -1,4 +1,3 @@
|
|||||||
---
|
|
||||||
name: Unit tests
|
name: Unit tests
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -13,6 +13,7 @@ changelogs/.plugin-cache.yaml
|
|||||||
tests/output
|
tests/output
|
||||||
tests/integration/cloud-config-*
|
tests/integration/cloud-config-*
|
||||||
.cache
|
.cache
|
||||||
|
.ansible
|
||||||
|
|
||||||
# Helm charts
|
# Helm charts
|
||||||
tests/integration/*-chart-*.tgz
|
tests/integration/*-chart-*.tgz
|
||||||
|
|||||||
@@ -5,16 +5,24 @@ rules:
|
|||||||
braces:
|
braces:
|
||||||
max-spaces-inside: 1
|
max-spaces-inside: 1
|
||||||
level: error
|
level: error
|
||||||
|
|
||||||
brackets:
|
brackets:
|
||||||
max-spaces-inside: 1
|
max-spaces-inside: 1
|
||||||
level: error
|
level: error
|
||||||
|
comments:
|
||||||
|
min-spaces-from-content: 1
|
||||||
|
comments-indentation: false
|
||||||
document-start: disable
|
document-start: disable
|
||||||
line-length: disable
|
line-length: disable
|
||||||
truthy: disable
|
truthy: disable
|
||||||
indentation:
|
indentation:
|
||||||
spaces: 2
|
spaces: 2
|
||||||
indent-sequences: consistent
|
indent-sequences: consistent
|
||||||
|
octal-values:
|
||||||
|
forbid-implicit-octal: true
|
||||||
|
forbid-explicit-octal: true
|
||||||
ignore: |
|
ignore: |
|
||||||
.cache
|
.cache
|
||||||
.tox
|
.tox
|
||||||
|
.ansible
|
||||||
tests/output
|
tests/output
|
||||||
|
|||||||
116
CHANGELOG.rst
116
CHANGELOG.rst
@@ -4,14 +4,122 @@ Kubernetes Collection Release Notes
|
|||||||
|
|
||||||
.. contents:: Topics
|
.. contents:: Topics
|
||||||
|
|
||||||
|
v3.3.1
|
||||||
v2.4.1
|
|
||||||
======
|
======
|
||||||
|
|
||||||
Release Summary
|
Release Summary
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
The kubernetes.core 2.4.1 release includes several trivial bug fixes related to code sanity.
|
This release fixes the CI issues with the ``linters`` workflow.
|
||||||
|
|
||||||
|
v3.3.0
|
||||||
|
======
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- inventory/k8s.py - Defer removal of k8s inventory plugin to version 5.0 (https://github.com/ansible-collections/kubernetes.core/pull/723).
|
||||||
|
- inventory/k8s.py - Defer removal of k8s inventory plugin to version 6.0.0 (https://github.com/ansible-collections/kubernetes.core/pull/734).
|
||||||
|
- k8s_drain - Improve error message for pod disruption budget when draining a node (https://github.com/ansible-collections/kubernetes.core/issues/797).
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
--------
|
||||||
|
|
||||||
|
- helm - Helm version checks did not support RC versions. They now accept any version tags. (https://github.com/ansible-collections/kubernetes.core/pull/745).
|
||||||
|
- helm_pull - Apply no_log=True to pass_credentials to silence false positive warning.. (https://github.com/ansible-collections/kubernetes.core/pull/796).
|
||||||
|
- k8s_drain - Fix k8s_drain does not wait for single pod (https://github.com/ansible-collections/kubernetes.core/issues/769).
|
||||||
|
- k8s_drain - Fix k8s_drain runs into a timeout when evicting a pod which is part of a stateful set (https://github.com/ansible-collections/kubernetes.core/issues/792).
|
||||||
|
- kubeconfig option should not appear in module invocation log (https://github.com/ansible-collections/kubernetes.core/issues/782).
|
||||||
|
- kustomize - kustomize plugin fails with deprecation warnings (https://github.com/ansible-collections/kubernetes.core/issues/639).
|
||||||
|
- waiter - Fix waiting for daemonset when desired number of pods is 0. (https://github.com/ansible-collections/kubernetes.core/pull/756).
|
||||||
|
|
||||||
|
v3.2.0
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
This release comes with documentation updates.
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- connection/kubectl.py - Added an example of using the kubectl connection plugin to the documentation (https://github.com/ansible-collections/kubernetes.core/pull/741).
|
||||||
|
- inventory/k8s.py - Defer removal of k8s inventory plugin to version 6.0.0 (https://github.com/ansible-collections/kubernetes.core/pull/734).
|
||||||
|
|
||||||
|
v3.1.0
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
This release comes with some bugfixes and documentation updates. It also adds new features to the kubectl connection plugin and the kustomize lookup plugin.
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- kubectl - added support of local enviroment variable that will be used for kubectl and may be requried for establishing connections ifself (https://github.com/ansible-collections/kubernetes.core/pull/702)
|
||||||
|
- kustomize - new parameter added to --enable-helm (https://github.com/ansible-collections/kubernetes.core/issues/568)
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
--------
|
||||||
|
|
||||||
|
- helm - expand kubeconfig path with user's home directory for consistency with k8s
|
||||||
|
- k8s_json_patch - rename action symlink to ensure k8s action plugin is used (https://github.com/ansible-collections/kubernetes.core/pull/652).
|
||||||
|
|
||||||
|
v3.0.1
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
This release fixes issue with resources discovery when complex subresources are present, and fixes issues with `reuse-values` parameter for helm module.
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
--------
|
||||||
|
|
||||||
|
- Resolve Collections util resource discovery fails when complex subresources present (https://github.com/ansible-collections/kubernetes.core/pull/676).
|
||||||
|
- align `helmdiff_check()` function commandline rendering with the `deploy()` function (https://github.com/ansible-collections/kubernetes.core/pull/670).
|
||||||
|
- helm - use ``reuse-values`` when running ``helm diff`` command (https://github.com/ansible-collections/kubernetes.core/issues/680).
|
||||||
|
- integrations test helm_kubeconfig - set helm version to v3.10.3 to avoid incompatability with new bitnami charts (https://github.com/ansible-collections/kubernetes.core/pull/670).
|
||||||
|
|
||||||
|
v3.0.0
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
This major release drops support for ansible-core versions lower than 2.14, Python versions lower than 3.9 and updates python kubernetes library to 24.2.0, helm/kind-action to 1.8.0, kubernetes >= 1.24, along with bug fixes and minor changes.
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- helm - add ``reuse_values`` and ``reset_values`` support to helm module (https://github.com/ansible-collections/kubernetes.core/issues/394).
|
||||||
|
- k8s - add new option ``delete_all`` to support deletion of all resources when state is set to ``absent``. (https://github.com/ansible-collections/kubernetes.core/issues/504)
|
||||||
|
- k8s, k8s_info - add a hidden_fields option to allow fields to be hidden in the results of k8s and k8s_info
|
||||||
|
- k8s_drain - add ability to filter the list of pods to be drained by a pod label selector (https://github.com/ansible-collections/kubernetes.core/issues/474).
|
||||||
|
|
||||||
|
Breaking Changes / Porting Guide
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
- Remove support for ansible-core < 2.14
|
||||||
|
- Update python kubernetes library to 24.2.0, helm/kind-action to 1.8.0, kubernetes >= 1.24.
|
||||||
|
|
||||||
|
Deprecated Features
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
- k8s - the ``k8s`` inventory plugin has been deprecated and will be removed in release 4.0.0 (https://github.com/ansible-collections/kubernetes.core/issues/31).
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
--------
|
||||||
|
|
||||||
|
- helm - Put the chart_ref into quotes when running ``helm show chart``, ``helm upgrade`` and ``helm dependency update`` commands (https://github.com/ansible-collections/kubernetes.core/issues/653).
|
||||||
|
- helm - delete temporary file created when deploying chart with option ``release_values`` set (https://github.com/ansible-collections/kubernetes.core/issues/530).
|
||||||
|
- helm - fix issue occurring when uninstalling chart with statues others than ``deployed`` (https://github.com/ansible-collections/kubernetes.core/issues/319).
|
||||||
|
- helm - fix post_renderer argument breaking the helm deploy_command (https://github.com/ansible-collections/kubernetes.core/pull/586).
|
||||||
|
- helm - use post_renderer when checking ``changed`` status for a helm release (https://github.com/ansible-collections/kubernetes.core/pull/588).
|
||||||
|
- k8s_scale - clean handling of ResourceTimeout exception (https://github.com/ansible-collections/kubernetes.core/issues/583).
|
||||||
|
- k8s_scale - fix issue when scaling StatefulSets with ``updateStrategy=OnDelete`` (https://github.com/ansible-collections/kubernetes.core/issues/579).
|
||||||
|
|
||||||
v2.4.0
|
v2.4.0
|
||||||
======
|
======
|
||||||
@@ -104,7 +212,7 @@ v2.3.1
|
|||||||
Bugfixes
|
Bugfixes
|
||||||
--------
|
--------
|
||||||
|
|
||||||
- Catch exception raised when the process is waiting for resources (https://github.com/ansible-collections/kubernetes.core/issues/407).
|
- Catch expectation raised when the process is waiting for resources (https://github.com/ansible-collections/kubernetes.core/issues/407).
|
||||||
- Remove `omit` placeholder when defining resource using template parameter (https://github.com/ansible-collections/kubernetes.core/issues/431).
|
- Remove `omit` placeholder when defining resource using template parameter (https://github.com/ansible-collections/kubernetes.core/issues/431).
|
||||||
- k8s - fix the issue when trying to delete resources using label_selectors options (https://github.com/ansible-collections/kubernetes.core/issues/433).
|
- k8s - fix the issue when trying to delete resources using label_selectors options (https://github.com/ansible-collections/kubernetes.core/issues/433).
|
||||||
- k8s_cp - fix issue when using parameter local_path with file on managed node. (https://github.com/ansible-collections/kubernetes.core/issues/421).
|
- k8s_cp - fix issue when using parameter local_path with file on managed node. (https://github.com/ansible-collections/kubernetes.core/issues/421).
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -1,5 +1,5 @@
|
|||||||
# Also needs to be updated in galaxy.yml
|
# Also needs to be updated in galaxy.yml
|
||||||
VERSION = 2.4.1
|
VERSION = 3.3.1
|
||||||
|
|
||||||
TEST_ARGS ?= ""
|
TEST_ARGS ?= ""
|
||||||
PYTHON_VERSION ?= `python -c 'import platform; print(".".join(platform.python_version_tuple()[0:2]))'`
|
PYTHON_VERSION ?= `python -c 'import platform; print(".".join(platform.python_version_tuple()[0:2]))'`
|
||||||
|
|||||||
70
README.md
70
README.md
@@ -4,12 +4,16 @@
|
|||||||
|
|
||||||
This repository hosts the `kubernetes.core` (formerly known as `community.kubernetes`) Ansible Collection.
|
This repository hosts the `kubernetes.core` (formerly known as `community.kubernetes`) Ansible Collection.
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
<!--start requires_ansible-->
|
## Requirements
|
||||||
## Ansible version compatibility
|
|
||||||
|
|
||||||
This collection has been tested against following Ansible versions: **>=2.9.17**.
|
<!--start requires_ansible-->
|
||||||
|
### Ansible version compatibility
|
||||||
|
|
||||||
|
This collection has been tested against following Ansible versions: **>=2.14.0**.
|
||||||
|
|
||||||
For collections that support Ansible 2.9, please ensure you update your `network_os` to use the
|
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`).
|
fully qualified collection name (for example, `cisco.ios.ios`).
|
||||||
@@ -18,43 +22,43 @@ A collection may contain metadata that identifies these versions.
|
|||||||
PEP440 is the schema used to describe the versions of Ansible.
|
PEP440 is the schema used to describe the versions of Ansible.
|
||||||
<!--end requires_ansible-->
|
<!--end requires_ansible-->
|
||||||
|
|
||||||
## Python Support
|
### Python Support
|
||||||
|
|
||||||
* Collection supports 3.6+
|
* Collection supports 3.9+
|
||||||
|
|
||||||
Note: Python2 is deprecated from [1st January 2020](https://www.python.org/doc/sunset-python-2/). Please switch to Python3.
|
Note: Python2 is deprecated from [1st January 2020](https://www.python.org/doc/sunset-python-2/). Please switch to Python3.
|
||||||
|
|
||||||
## Kubernetes Version Support
|
### Kubernetes Version Support
|
||||||
|
|
||||||
This collection supports Kubernetes versions >=1.19.
|
This collection supports Kubernetes versions >= 1.24.
|
||||||
|
|
||||||
## Included content
|
### Included content
|
||||||
|
|
||||||
Click on the name of a plugin or module to view that content's documentation:
|
Click on the name of a plugin or module to view that content's documentation:
|
||||||
|
|
||||||
<!--start collection content-->
|
<!--start collection content-->
|
||||||
### Connection plugins
|
#### Connection plugins
|
||||||
Name | Description
|
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.
|
[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
|
#### K8s filter plugins
|
||||||
Name | Description
|
Name | Description
|
||||||
--- | ---
|
--- | ---
|
||||||
kubernetes.core.k8s_config_resource_name|Generate resource name for the given resource of type ConfigMap, Secret
|
kubernetes.core.k8s_config_resource_name|Generate resource name for the given resource of type ConfigMap, Secret
|
||||||
|
|
||||||
### Inventory plugins
|
#### Inventory plugins
|
||||||
Name | Description
|
Name | Description
|
||||||
--- | ---
|
--- | ---
|
||||||
[kubernetes.core.k8s](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_inventory.rst)|Kubernetes (K8s) inventory source
|
[kubernetes.core.k8s](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_inventory.rst)|Kubernetes (K8s) inventory source
|
||||||
|
|
||||||
### Lookup plugins
|
#### Lookup plugins
|
||||||
Name | Description
|
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.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.
|
[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
|
#### Modules
|
||||||
Name | Description
|
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](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.helm_module.rst)|Manages Kubernetes packages with the Helm package manager
|
||||||
@@ -79,9 +83,7 @@ Name | Description
|
|||||||
|
|
||||||
<!--end collection content-->
|
<!--end collection content-->
|
||||||
|
|
||||||
## Installation and Usage
|
## Installation
|
||||||
|
|
||||||
### Installing the Collection from Ansible Galaxy
|
|
||||||
|
|
||||||
Before using the Kubernetes collection, you need to install it with the Ansible Galaxy CLI:
|
Before using the Kubernetes collection, you need to install it with the Ansible Galaxy CLI:
|
||||||
|
|
||||||
@@ -93,7 +95,7 @@ You can also include it in a `requirements.yml` file and install it via `ansible
|
|||||||
---
|
---
|
||||||
collections:
|
collections:
|
||||||
- name: kubernetes.core
|
- name: kubernetes.core
|
||||||
version: 2.4.1
|
version: 3.3.1
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installing the Kubernetes Python Library
|
### Installing the Kubernetes Python Library
|
||||||
@@ -102,7 +104,7 @@ Content in this collection requires the [Kubernetes Python client](https://pypi.
|
|||||||
|
|
||||||
pip3 install kubernetes
|
pip3 install kubernetes
|
||||||
|
|
||||||
### Using modules from the Kubernetes Collection in your playbooks
|
## Use Cases
|
||||||
|
|
||||||
It's preferable to use content in this collection using their Fully Qualified Collection Namespace (FQCN), for example `kubernetes.core.k8s_info`:
|
It's preferable to use content in this collection using their Fully Qualified Collection Namespace (FQCN), for example `kubernetes.core.k8s_info`:
|
||||||
|
|
||||||
@@ -189,12 +191,16 @@ defined in the playbook using `environment` keyword as above, you must set it us
|
|||||||
|
|
||||||
Please read more about Ansible Turbo mode - [here](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/ansible_turbo_mode.rst).
|
Please read more about Ansible Turbo mode - [here](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/ansible_turbo_mode.rst).
|
||||||
|
|
||||||
## Testing and Development
|
## 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.
|
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).
|
See [Contributing to kubernetes.core](CONTRIBUTING.md).
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
[](https://github.com/ansible-collections/kubernetes.core/actions/workflows/linters.yaml) [](https://github.com/ansible-collections/kubernetes.core/actions/workflows/integration-tests.yaml) [](https://github.com/ansible-collections/kubernetes.core/actions/workflows/sanity-tests.yaml) [](https://github.com/ansible-collections/kubernetes.core/actions/workflows/unit-tests.yaml) [](https://app.codecov.io/gh/ansible-collections/kubernetes.core)
|
||||||
|
|
||||||
### Testing with `ansible-test`
|
### Testing with `ansible-test`
|
||||||
|
|
||||||
The `tests` directory contains configuration for running sanity and integration tests using [`ansible-test`](https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html).
|
The `tests` directory contains configuration for running sanity and integration tests using [`ansible-test`](https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html).
|
||||||
@@ -231,10 +237,36 @@ After the version is published, verify it exists on the [Kubernetes Collection G
|
|||||||
|
|
||||||
The process for uploading a supported release to Automation Hub is documented separately.
|
The process for uploading a supported release to Automation Hub is documented separately.
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
<!--List available communication channels. In addition to channels specific to your collection, we also recommend to use the following ones.-->
|
||||||
|
|
||||||
|
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).
|
||||||
|
|
||||||
## More Information
|
## More Information
|
||||||
|
|
||||||
For more information about Ansible's Kubernetes integration, join the `#ansible-kubernetes` channel on [libera.chat](https://libera.chat/) IRC, and browse the resources in the [Kubernetes Working Group](https://github.com/ansible/community/wiki/Kubernetes) Community wiki page.
|
For more information about Ansible's Kubernetes integration, join the `#ansible-kubernetes` channel on [libera.chat](https://libera.chat/) IRC, and browse the resources in the [Kubernetes Working Group](https://github.com/ansible/community/wiki/Kubernetes) Community wiki page.
|
||||||
|
|
||||||
|
## 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
|
||||||
|
|
||||||
GNU General Public License v3.0 or later
|
GNU General Public License v3.0 or later
|
||||||
|
|||||||
@@ -762,9 +762,146 @@ releases:
|
|||||||
name: helm_pull
|
name: helm_pull
|
||||||
namespace: ''
|
namespace: ''
|
||||||
release_date: '2023-01-24'
|
release_date: '2023-01-24'
|
||||||
2.4.1:
|
3.0.0:
|
||||||
changes:
|
changes:
|
||||||
release_summary: The kubernetes.core 2.4.1 release includes several trivial bug fixes related to sanity.
|
breaking_changes:
|
||||||
|
- Remove support for ansible-core < 2.14
|
||||||
|
- Update python kubernetes library to 24.2.0, helm/kind-action to 1.8.0, kubernetes
|
||||||
|
>= 1.24.
|
||||||
|
bugfixes:
|
||||||
|
- helm - Put the chart_ref into quotes when running ``helm show chart``, ``helm
|
||||||
|
upgrade`` and ``helm dependency update`` commands (https://github.com/ansible-collections/kubernetes.core/issues/653).
|
||||||
|
- helm - delete temporary file created when deploying chart with option ``release_values``
|
||||||
|
set (https://github.com/ansible-collections/kubernetes.core/issues/530).
|
||||||
|
- helm - fix issue occurring when uninstalling chart with statues others than
|
||||||
|
``deployed`` (https://github.com/ansible-collections/kubernetes.core/issues/319).
|
||||||
|
- helm - fix post_renderer argument breaking the helm deploy_command (https://github.com/ansible-collections/kubernetes.core/pull/586).
|
||||||
|
- helm - use post_renderer when checking ``changed`` status for a helm release
|
||||||
|
(https://github.com/ansible-collections/kubernetes.core/pull/588).
|
||||||
|
- k8s_scale - clean handling of ResourceTimeout exception (https://github.com/ansible-collections/kubernetes.core/issues/583).
|
||||||
|
- k8s_scale - fix issue when scaling StatefulSets with ``updateStrategy=OnDelete``
|
||||||
|
(https://github.com/ansible-collections/kubernetes.core/issues/579).
|
||||||
|
deprecated_features:
|
||||||
|
- k8s - the ``k8s`` inventory plugin has been deprecated and will be removed
|
||||||
|
in release 4.0.0 (https://github.com/ansible-collections/kubernetes.core/issues/31).
|
||||||
|
minor_changes:
|
||||||
|
- helm - add ``reuse_values`` and ``reset_values`` support to helm module (https://github.com/ansible-collections/kubernetes.core/issues/394).
|
||||||
|
- k8s - add new option ``delete_all`` to support deletion of all resources when
|
||||||
|
state is set to ``absent``. (https://github.com/ansible-collections/kubernetes.core/issues/504)
|
||||||
|
- k8s, k8s_info - add a hidden_fields option to allow fields to be hidden in
|
||||||
|
the results of k8s and k8s_info
|
||||||
|
- k8s_drain - add ability to filter the list of pods to be drained by a pod
|
||||||
|
label selector (https://github.com/ansible-collections/kubernetes.core/issues/474).
|
||||||
|
release_summary: This major release drops support for ansible-core versions
|
||||||
|
lower than 2.14, Python versions lower than 3.9 and updates python kubernetes
|
||||||
|
library to 24.2.0, helm/kind-action to 1.8.0, kubernetes >= 1.24, along with
|
||||||
|
bug fixes and minor changes.
|
||||||
fragments:
|
fragments:
|
||||||
- fix_sanity_errors.yml
|
- 20230206-deprecate-k8s-inventory.yml
|
||||||
release_date: '2024-02-06'
|
- 20231110-helm-quote-ref.yaml
|
||||||
|
- 517-k8s-make-name-optional.yaml
|
||||||
|
- 575-helm-add-support-for-reuse_values-and-reset_values.yml
|
||||||
|
- 579-k8s_scale-fix-issue-with-scaling-statefulsets.yml
|
||||||
|
- 583-k8s_scale-clean-handling-of-ResourceTimeout-exception.yaml
|
||||||
|
- 586-helm-fix-post-renderer-arg.yml
|
||||||
|
- 588-helm-use-post-renderer-for-helmdiff.yml
|
||||||
|
- 589-helm-uninstall-chart-releases-with-statuses-different-than-deployed.yaml
|
||||||
|
- 606-k8s_drain-add-pod_selectors-parameter.yaml
|
||||||
|
- 612-fix-helm-tests.yaml
|
||||||
|
- 629-add-hidden-fields-option.yaml
|
||||||
|
- gha-sanity-fixes.yaml
|
||||||
|
- helm-delete-temporary-file-created-when-using-option-release_values.yaml
|
||||||
|
- remove_ansible_2_13.yaml
|
||||||
|
- update_supported_versions.yaml
|
||||||
|
release_date: '2023-11-17'
|
||||||
|
3.0.1:
|
||||||
|
changes:
|
||||||
|
bugfixes:
|
||||||
|
- Resolve Collections util resource discovery fails when complex subresources
|
||||||
|
present (https://github.com/ansible-collections/kubernetes.core/pull/676).
|
||||||
|
- align `helmdiff_check()` function commandline rendering with the `deploy()`
|
||||||
|
function (https://github.com/ansible-collections/kubernetes.core/pull/670).
|
||||||
|
- helm - use ``reuse-values`` when running ``helm diff`` command (https://github.com/ansible-collections/kubernetes.core/issues/680).
|
||||||
|
- integrations test helm_kubeconfig - set helm version to v3.10.3 to avoid incompatability
|
||||||
|
with new bitnami charts (https://github.com/ansible-collections/kubernetes.core/pull/670).
|
||||||
|
release_summary: This release fixes issue with resources discovery when complex
|
||||||
|
subresources are present, and fixes issues with `reuse-values` parameter for
|
||||||
|
helm module.
|
||||||
|
fragments:
|
||||||
|
- 20240117-fix-helm-diff-cmd-line-rendering.yml
|
||||||
|
- 20240222-Collections-util-resource-discovery-fails-when-complex-subresources-present.yml
|
||||||
|
- 20240228-fix-helm-diff-with-reuse-values.yml
|
||||||
|
- 3.0.1.yml
|
||||||
|
release_date: '2024-03-01'
|
||||||
|
3.1.0:
|
||||||
|
changes:
|
||||||
|
bugfixes:
|
||||||
|
- helm - expand kubeconfig path with user's home directory for consistency with
|
||||||
|
k8s
|
||||||
|
- k8s_json_patch - rename action symlink to ensure k8s action plugin is used
|
||||||
|
(https://github.com/ansible-collections/kubernetes.core/pull/652).
|
||||||
|
minor_changes:
|
||||||
|
- kubectl - added support of local enviroment variable that will be used for
|
||||||
|
kubectl and may be requried for establishing connections ifself (https://github.com/ansible-collections/kubernetes.core/pull/702)
|
||||||
|
- kustomize - new parameter added to --enable-helm (https://github.com/ansible-collections/kubernetes.core/issues/568)
|
||||||
|
release_summary: This release comes with some bugfixes and documentation updates.
|
||||||
|
It also adds new features to the kubectl connection plugin and the kustomize
|
||||||
|
lookup plugin.
|
||||||
|
fragments:
|
||||||
|
- 20240426-add-support-of-kubectl-local-env-vars-for-connection-plugin.yml
|
||||||
|
- 3.1.0.yml
|
||||||
|
- 592-kustomize-helm-support.yml
|
||||||
|
- 652-fix-json-patch-action.yml
|
||||||
|
- 654-helm-expand-user.yml
|
||||||
|
release_date: '2024-05-16'
|
||||||
|
3.2.0:
|
||||||
|
changes:
|
||||||
|
minor_changes:
|
||||||
|
- connection/kubectl.py - Added an example of using the kubectl connection plugin
|
||||||
|
to the documentation (https://github.com/ansible-collections/kubernetes.core/pull/741).
|
||||||
|
- inventory/k8s.py - Defer removal of k8s inventory plugin to version 5.0 (https://github.com/ansible-collections/kubernetes.core/pull/723).
|
||||||
|
- inventory/k8s.py - Defer removal of k8s inventory plugin to version 6.0.0
|
||||||
|
(https://github.com/ansible-collections/kubernetes.core/pull/734).
|
||||||
|
release_summary: This release comes with documentation updates.
|
||||||
|
fragments:
|
||||||
|
- 20240530-defer-removal-and-ansible-core-support-update.yaml
|
||||||
|
- 20240601-doc-example-of-using-kubectl.yaml
|
||||||
|
- 3.2.0.yml
|
||||||
|
- inventory-update_removal_date.yml
|
||||||
|
release_date: '2024-06-14'
|
||||||
|
3.3.0:
|
||||||
|
changes:
|
||||||
|
bugfixes:
|
||||||
|
- helm - Helm version checks did not support RC versions. They now accept any
|
||||||
|
version tags. (https://github.com/ansible-collections/kubernetes.core/pull/745).
|
||||||
|
- helm_pull - Apply no_log=True to pass_credentials to silence false positive
|
||||||
|
warning. (https://github.com/ansible-collections/kubernetes.core/pull/796).
|
||||||
|
- k8s_drain - Fix k8s_drain does not wait for single pod (https://github.com/ansible-collections/kubernetes.core/issues/769).
|
||||||
|
- k8s_drain - Fix k8s_drain runs into a timeout when evicting a pod which is
|
||||||
|
part of a stateful set (https://github.com/ansible-collections/kubernetes.core/issues/792).
|
||||||
|
- kubeconfig option should not appear in module invocation log (https://github.com/ansible-collections/kubernetes.core/issues/782).
|
||||||
|
- kustomize - kustomize plugin fails with deprecation warnings (https://github.com/ansible-collections/kubernetes.core/issues/639).
|
||||||
|
- waiter - Fix waiting for daemonset when desired number of pods is 0. (https://github.com/ansible-collections/kubernetes.core/pull/756).
|
||||||
|
minor_changes:
|
||||||
|
- k8s_drain - Improve error message for pod disruption budget when draining
|
||||||
|
a node (https://github.com/ansible-collections/kubernetes.core/issues/797).
|
||||||
|
release_summary: This release comes with improvements to the error messages in the k8s_drain module and several bug fixes.
|
||||||
|
fragments:
|
||||||
|
- 20240530-ansible-core-support-update.yaml
|
||||||
|
- 20240611-helm-rc-version.yaml
|
||||||
|
- 20240620-fix-kustomize-plugin-fails-with-deprecation-warnings.yml
|
||||||
|
- 20241102-fix-ci-post-2.18-issue.yaml
|
||||||
|
- 20241213-kubeconfig-set-no_log-true.yaml
|
||||||
|
- 756-fix-daemonset-waiting.yaml
|
||||||
|
- 770-fix-k8s-drain-doesnt-wait-for-single-pod.yaml
|
||||||
|
- 793-fix-k8s-drain-runs-into-timeout.yaml
|
||||||
|
- 796-false-positive-helmull.yaml
|
||||||
|
- 798-drain-pdb-error-message.yaml
|
||||||
|
- readme_template_update.yml
|
||||||
|
release_date: '2025-01-22'
|
||||||
|
3.3.1:
|
||||||
|
changes:
|
||||||
|
release_summary: This release fixes the CI issues with the ``linters`` workflow.
|
||||||
|
fragments:
|
||||||
|
- release_summary.yml
|
||||||
|
release_date: '2025-03-26'
|
||||||
|
|||||||
@@ -10,21 +10,21 @@ notesdir: fragments
|
|||||||
prelude_section_name: release_summary
|
prelude_section_name: release_summary
|
||||||
prelude_section_title: Release Summary
|
prelude_section_title: Release Summary
|
||||||
sections:
|
sections:
|
||||||
- - major_changes
|
- - major_changes
|
||||||
- Major Changes
|
- Major Changes
|
||||||
- - minor_changes
|
- - minor_changes
|
||||||
- Minor Changes
|
- Minor Changes
|
||||||
- - breaking_changes
|
- - breaking_changes
|
||||||
- Breaking Changes / Porting Guide
|
- Breaking Changes / Porting Guide
|
||||||
- - deprecated_features
|
- - deprecated_features
|
||||||
- Deprecated Features
|
- Deprecated Features
|
||||||
- - removed_features
|
- - removed_features
|
||||||
- Removed Features (previously deprecated)
|
- Removed Features (previously deprecated)
|
||||||
- - security_fixes
|
- - security_fixes
|
||||||
- Security Fixes
|
- Security Fixes
|
||||||
- - bugfixes
|
- - bugfixes
|
||||||
- Bugfixes
|
- Bugfixes
|
||||||
- - known_issues
|
- - known_issues
|
||||||
- Known Issues
|
- Known Issues
|
||||||
title: Kubernetes Collection
|
title: Kubernetes Collection
|
||||||
trivial_section_name: trivial
|
trivial_section_name: trivial
|
||||||
|
|||||||
3
changelogs/fragments/20250324-k8s_info-templating.yaml
Normal file
3
changelogs/fragments/20250324-k8s_info-templating.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
minor_changes:
|
||||||
|
- action/k8s_info - update templating mechanism with changes from ``ansible-core 2.19`` (https://github.com/ansible-collections/kubernetes.core/pull/888).
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
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).
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
minor_changes:
|
||||||
|
- Bump version of ansible-lint to 25.1.2 (https://github.com/ansible-collections/kubernetes.core/pull/919).
|
||||||
@@ -105,6 +105,27 @@ Parameters
|
|||||||
<div style="font-size: small; color: darkgreen"><br/>aliases: kube_context</div>
|
<div style="font-size: small; color: darkgreen"><br/>aliases: kube_context</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>get_all_values</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">boolean</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
||||||
|
<li><div style="color: blue"><b>no</b> ←</div></li>
|
||||||
|
<li>yes</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Set to <code>True</code> if you want to get all (computed) values of the release.</div>
|
||||||
|
<div>When <code>False</code> (default), only user supplied values are returned.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="1">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -127,7 +148,7 @@ Parameters
|
|||||||
<b>kubeconfig</b>
|
<b>kubeconfig</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
<div style="font-size: small">
|
<div style="font-size: small">
|
||||||
<span style="color: purple">path</span>
|
<span style="color: purple">raw</span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -135,6 +156,7 @@ Parameters
|
|||||||
<td>
|
<td>
|
||||||
<div>Helm option to specify kubeconfig path to use.</div>
|
<div>Helm option to specify kubeconfig path to use.</div>
|
||||||
<div>If the value is not specified in the task, the value of environment variable <code>K8S_AUTH_KUBECONFIG</code> will be used instead.</div>
|
<div>If the value is not specified in the task, the value of environment variable <code>K8S_AUTH_KUBECONFIG</code> will be used instead.</div>
|
||||||
|
<div>The configuration can be provided as dictionary. Added in version 2.4.0.</div>
|
||||||
<div style="font-size: small; color: darkgreen"><br/>aliases: kubeconfig_path</div>
|
<div style="font-size: small; color: darkgreen"><br/>aliases: kubeconfig_path</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -172,6 +194,32 @@ Parameters
|
|||||||
<div style="font-size: small; color: darkgreen"><br/>aliases: namespace</div>
|
<div style="font-size: small; color: darkgreen"><br/>aliases: namespace</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>release_state</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">list</span>
|
||||||
|
/ <span style="color: purple">elements=string</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<b>Default:</b><br/><div style="color: blue">[]</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Show releases as per their states.</div>
|
||||||
|
<div>Default value is <code>deployed</code> and <code>failed</code>.</div>
|
||||||
|
<div>If set to <code>all</code>, show all releases without any filter applied.</div>
|
||||||
|
<div>If set to <code>deployed</code>, show deployed releases.</div>
|
||||||
|
<div>If set to <code>failed</code>, show failed releases.</div>
|
||||||
|
<div>If set to <code>pending</code>, show pending releases.</div>
|
||||||
|
<div>If set to <code>superseded</code>, show superseded releases.</div>
|
||||||
|
<div>If set to <code>uninstalled</code>, show uninstalled releases, if <code>helm uninstall --keep-history</code> was used.</div>
|
||||||
|
<div>If set to <code>uninstalling</code>, show releases that are currently being uninstalled.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="1">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -204,11 +252,18 @@ Examples
|
|||||||
|
|
||||||
.. code-block:: yaml
|
.. code-block:: yaml
|
||||||
|
|
||||||
- name: Deploy latest version of Grafana chart inside monitoring namespace
|
- name: Gather information of Grafana chart inside monitoring namespace
|
||||||
kubernetes.core.helm_info:
|
kubernetes.core.helm_info:
|
||||||
name: test
|
name: test
|
||||||
release_namespace: monitoring
|
release_namespace: monitoring
|
||||||
|
|
||||||
|
- name: Gather information about test-chart with pending state
|
||||||
|
kubernetes.core.helm_info:
|
||||||
|
name: test-chart
|
||||||
|
release_namespace: testenv
|
||||||
|
release_state:
|
||||||
|
- pending
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Return Values
|
Return Values
|
||||||
@@ -270,6 +325,42 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
|
|||||||
<br/>
|
<br/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"> </td>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="return-"></div>
|
||||||
|
<b>hooks</b>
|
||||||
|
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">list</span>
|
||||||
|
/ <span style="color: purple">elements=dictionary</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
|
||||||
|
</td>
|
||||||
|
<td>always</td>
|
||||||
|
<td>
|
||||||
|
<div>Hooks of the release</div>
|
||||||
|
<br/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"> </td>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="return-"></div>
|
||||||
|
<b>manifest</b>
|
||||||
|
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">list</span>
|
||||||
|
/ <span style="color: purple">elements=dictionary</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
|
||||||
|
</td>
|
||||||
|
<td>always</td>
|
||||||
|
<td>
|
||||||
|
<div>Manifest of the release</div>
|
||||||
|
<br/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="elbow-placeholder"> </td>
|
<td class="elbow-placeholder"> </td>
|
||||||
<td colspan="1">
|
<td colspan="1">
|
||||||
@@ -302,6 +393,23 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
|
|||||||
<br/>
|
<br/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"> </td>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="return-"></div>
|
||||||
|
<b>notes</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>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
|
||||||
|
</td>
|
||||||
|
<td>always</td>
|
||||||
|
<td>
|
||||||
|
<div>Notes of the release</div>
|
||||||
|
<br/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="elbow-placeholder"> </td>
|
<td class="elbow-placeholder"> </td>
|
||||||
<td colspan="1">
|
<td colspan="1">
|
||||||
|
|||||||
@@ -36,12 +36,12 @@ Parameters
|
|||||||
|
|
||||||
<table border=0 cellpadding=0 class="documentation-table">
|
<table border=0 cellpadding=0 class="documentation-table">
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="1">Parameter</th>
|
<th colspan="2">Parameter</th>
|
||||||
<th>Choices/<font color="blue">Defaults</font></th>
|
<th>Choices/<font color="blue">Defaults</font></th>
|
||||||
<th width="100%">Comments</th>
|
<th width="100%">Comments</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>api_key</b>
|
<b>api_key</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -57,7 +57,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>atomic</b>
|
<b>atomic</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -76,7 +76,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>binary_path</b>
|
<b>binary_path</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -91,7 +91,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>ca_cert</b>
|
<b>ca_cert</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -108,7 +108,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>chart_ref</b>
|
<b>chart_ref</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -127,7 +127,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>chart_repo_url</b>
|
<b>chart_repo_url</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -142,7 +142,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>chart_version</b>
|
<b>chart_version</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -157,7 +157,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>context</b>
|
<b>context</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -174,7 +174,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>create_namespace</b>
|
<b>create_namespace</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -194,13 +194,14 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>dependency_update</b>
|
<b>dependency_update</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
<div style="font-size: small">
|
<div style="font-size: small">
|
||||||
<span style="color: purple">boolean</span>
|
<span style="color: purple">boolean</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
||||||
@@ -209,7 +210,7 @@ Parameters
|
|||||||
</ul>
|
</ul>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>Run standelone <code>helm dependency update CHART</code> before the operation.</div>
|
<div>Run standalone <code>helm dependency update CHART</code> before the operation.</div>
|
||||||
<div>Run inline <code>--dependency-update</code> with <code>helm install</code> command. This feature is not supported yet with the <code>helm upgrade</code> command.</div>
|
<div>Run inline <code>--dependency-update</code> with <code>helm install</code> command. This feature is not supported yet with the <code>helm upgrade</code> command.</div>
|
||||||
<div>So we should consider to use <em>dependency_update</em> options with <em>replace</em> option enabled when specifying <em>chart_repo_url</em>.</div>
|
<div>So we should consider to use <em>dependency_update</em> options with <em>replace</em> option enabled when specifying <em>chart_repo_url</em>.</div>
|
||||||
<div>The <em>dependency_update</em> option require the add of <code>dependencies</code> block in <code>Chart.yaml/requirements.yaml</code> file.</div>
|
<div>The <em>dependency_update</em> option require the add of <code>dependencies</code> block in <code>Chart.yaml/requirements.yaml</code> file.</div>
|
||||||
@@ -218,7 +219,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>disable_hook</b>
|
<b>disable_hook</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -237,7 +238,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>force</b>
|
<b>force</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -256,7 +257,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>history_max</b>
|
<b>history_max</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -273,7 +274,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>host</b>
|
<b>host</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -289,12 +290,12 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>kubeconfig</b>
|
<b>kubeconfig</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
<div style="font-size: small">
|
<div style="font-size: small">
|
||||||
<span style="color: purple">path</span>
|
<span style="color: purple">raw</span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -302,11 +303,28 @@ Parameters
|
|||||||
<td>
|
<td>
|
||||||
<div>Helm option to specify kubeconfig path to use.</div>
|
<div>Helm option to specify kubeconfig path to use.</div>
|
||||||
<div>If the value is not specified in the task, the value of environment variable <code>K8S_AUTH_KUBECONFIG</code> will be used instead.</div>
|
<div>If the value is not specified in the task, the value of environment variable <code>K8S_AUTH_KUBECONFIG</code> will be used instead.</div>
|
||||||
|
<div>The configuration can be provided as dictionary. Added in version 2.4.0.</div>
|
||||||
<div style="font-size: small; color: darkgreen"><br/>aliases: kubeconfig_path</div>
|
<div style="font-size: small; color: darkgreen"><br/>aliases: kubeconfig_path</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>post_renderer</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Path to an executable to be used for post rendering.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>purge</b>
|
<b>purge</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -325,7 +343,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>release_name</b>
|
<b>release_name</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -342,7 +360,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>release_namespace</b>
|
<b>release_namespace</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -359,7 +377,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>release_state</b>
|
<b>release_state</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -379,7 +397,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>release_values</b>
|
<b>release_values</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -396,7 +414,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>replace</b>
|
<b>replace</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -418,7 +436,108 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>reset_values</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">boolean</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 3.0.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
||||||
|
<li>no</li>
|
||||||
|
<li><div style="color: blue"><b>yes</b> ←</div></li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>When upgrading package, reset the values to the ones built into the chart.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>reuse_values</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">boolean</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 3.0.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
||||||
|
<li>no</li>
|
||||||
|
<li>yes</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>When upgrading package, specifies wether to reuse the last release's values and merge in any overrides from parameters <em>release_values</em>, <em>values_files</em> or <em>set_values</em>.</div>
|
||||||
|
<div>If <em>reset_values</em> is set to <code>True</code>, this is ignored.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>set_values</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">list</span>
|
||||||
|
/ <span style="color: purple">elements=dictionary</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Values to pass to chart configuration</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
<td colspan="1">
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>value</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
/ <span style="color: red">required</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Value to pass to chart configuration (e.g phase=prod).</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>value_type</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">-</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
||||||
|
<li><div style="color: blue"><b>raw</b> ←</div></li>
|
||||||
|
<li>string</li>
|
||||||
|
<li>json</li>
|
||||||
|
<li>file</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Use <code>raw</code> set individual value.</div>
|
||||||
|
<div>Use <code>string</code> to force a string for an individual value.</div>
|
||||||
|
<div>Use <code>file</code> to set individual values from a file when the value itself is too long for the command line or is dynamically generated.</div>
|
||||||
|
<div>Use <code>json</code> to set json values (scalars/objects/arrays). This feature requires helm>=3.10.0.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>skip_crds</b>
|
<b>skip_crds</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -438,7 +557,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>timeout</b>
|
<b>timeout</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -456,7 +575,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>update_repo_cache</b>
|
<b>update_repo_cache</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -475,7 +594,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>validate_certs</b>
|
<b>validate_certs</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -496,7 +615,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>values_files</b>
|
<b>values_files</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -517,7 +636,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>wait</b>
|
<b>wait</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -537,7 +656,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>wait_timeout</b>
|
<b>wait_timeout</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -556,6 +675,12 @@ Parameters
|
|||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
|
||||||
|
Notes
|
||||||
|
-----
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
- The default idempotency check can fail to report changes when ``release_state`` is set to ``present`` and ``chart_repo_url`` is defined. Install helm diff >= 3.4.1 for better results.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
@@ -612,6 +737,15 @@ Examples
|
|||||||
state: absent
|
state: absent
|
||||||
update_repo_cache: true
|
update_repo_cache: true
|
||||||
|
|
||||||
|
- name: Deploy Grafana chart using set values on target
|
||||||
|
kubernetes.core.helm:
|
||||||
|
name: test
|
||||||
|
chart_ref: stable/grafana
|
||||||
|
release_namespace: monitoring
|
||||||
|
set_values:
|
||||||
|
- value: phase=prod
|
||||||
|
value_type: string
|
||||||
|
|
||||||
# From git
|
# From git
|
||||||
- name: Git clone stable repo on HEAD
|
- name: Git clone stable repo on HEAD
|
||||||
ansible.builtin.git:
|
ansible.builtin.git:
|
||||||
@@ -657,6 +791,17 @@ Examples
|
|||||||
logging:
|
logging:
|
||||||
enabled: True
|
enabled: True
|
||||||
|
|
||||||
|
# Deploy latest version
|
||||||
|
- name: Deploy latest version of Grafana chart using reuse_values
|
||||||
|
kubernetes.core.helm:
|
||||||
|
name: test
|
||||||
|
chart_ref: stable/grafana
|
||||||
|
release_namespace: monitoring
|
||||||
|
reuse_values: true
|
||||||
|
values:
|
||||||
|
replicas: 2
|
||||||
|
version: 3e8ec0b2dffa40fb97d5342e4af887de95faa8c61a62480dd7f8aa03dffcf533
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Return Values
|
Return Values
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ Parameters
|
|||||||
<b>kubeconfig</b>
|
<b>kubeconfig</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
<div style="font-size: small">
|
<div style="font-size: small">
|
||||||
<span style="color: purple">path</span>
|
<span style="color: purple">raw</span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -134,6 +134,7 @@ Parameters
|
|||||||
<td>
|
<td>
|
||||||
<div>Helm option to specify kubeconfig path to use.</div>
|
<div>Helm option to specify kubeconfig path to use.</div>
|
||||||
<div>If the value is not specified in the task, the value of environment variable <code>K8S_AUTH_KUBECONFIG</code> will be used instead.</div>
|
<div>If the value is not specified in the task, the value of environment variable <code>K8S_AUTH_KUBECONFIG</code> will be used instead.</div>
|
||||||
|
<div>The configuration can be provided as dictionary. Added in version 2.4.0.</div>
|
||||||
<div style="font-size: small; color: darkgreen"><br/>aliases: kubeconfig_path</div>
|
<div style="font-size: small; color: darkgreen"><br/>aliases: kubeconfig_path</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ Parameters
|
|||||||
<b>kubeconfig</b>
|
<b>kubeconfig</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
<div style="font-size: small">
|
<div style="font-size: small">
|
||||||
<span style="color: purple">path</span>
|
<span style="color: purple">raw</span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -134,6 +134,7 @@ Parameters
|
|||||||
<td>
|
<td>
|
||||||
<div>Helm option to specify kubeconfig path to use.</div>
|
<div>Helm option to specify kubeconfig path to use.</div>
|
||||||
<div>If the value is not specified in the task, the value of environment variable <code>K8S_AUTH_KUBECONFIG</code> will be used instead.</div>
|
<div>If the value is not specified in the task, the value of environment variable <code>K8S_AUTH_KUBECONFIG</code> will be used instead.</div>
|
||||||
|
<div>The configuration can be provided as dictionary. Added in version 2.4.0.</div>
|
||||||
<div style="font-size: small; color: darkgreen"><br/>aliases: kubeconfig_path</div>
|
<div style="font-size: small; color: darkgreen"><br/>aliases: kubeconfig_path</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -150,7 +151,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>Name of Helm plugin.</div>
|
<div>Name of Helm plugin.</div>
|
||||||
<div>Required only if <code>state=absent</code>.</div>
|
<div>Required only if <code>state=absent</code> or <code>state=latest</code>.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -170,6 +171,23 @@ Parameters
|
|||||||
<div>Required only if <code>state=present</code>.</div>
|
<div>Required only if <code>state=present</code>.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>plugin_version</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Plugin version to install. If this is not specified, the latest version is installed.</div>
|
||||||
|
<div>Ignored when <code>state=absent</code> or <code>state=latest</code>.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="1">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -183,10 +201,12 @@ Parameters
|
|||||||
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
||||||
<li>absent</li>
|
<li>absent</li>
|
||||||
<li><div style="color: blue"><b>present</b> ←</div></li>
|
<li><div style="color: blue"><b>present</b> ←</div></li>
|
||||||
|
<li>latest</li>
|
||||||
</ul>
|
</ul>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>If <code>state=present</code> the Helm plugin will be installed.</div>
|
<div>If <code>state=present</code> the Helm plugin will be installed.</div>
|
||||||
|
<div>If <code>state=latest</code> the Helm plugin will be updated. Added in version 2.3.0.</div>
|
||||||
<div>If <code>state=absent</code> the Helm plugin will be removed.</div>
|
<div>If <code>state=absent</code> the Helm plugin will be removed.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -237,6 +257,17 @@ Examples
|
|||||||
plugin_name: env
|
plugin_name: env
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
|
- name: Install Helm plugin with a specific version
|
||||||
|
kubernetes.core.helm_plugin:
|
||||||
|
plugin_version: 2.0.1
|
||||||
|
plugin_path: https://domain/path/to/plugin.tar.gz
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Update Helm plugin
|
||||||
|
kubernetes.core.helm_plugin:
|
||||||
|
plugin_name: secrets
|
||||||
|
state: latest
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Return Values
|
Return Values
|
||||||
|
|||||||
@@ -40,6 +40,22 @@ Parameters
|
|||||||
<th>Choices/<font color="blue">Defaults</font></th>
|
<th>Choices/<font color="blue">Defaults</font></th>
|
||||||
<th width="100%">Comments</th>
|
<th width="100%">Comments</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>api_key</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Token used to authenticate with the API. Can also be specified via <code>K8S_AUTH_API_KEY</code> environment variable.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="1">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -55,6 +71,117 @@ Parameters
|
|||||||
<div>The path of a helm binary to use.</div>
|
<div>The path of a helm binary to use.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>ca_cert</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">path</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Path to a CA certificate used to authenticate with the API. The full certificate chain must be provided to avoid certificate validation errors. Can also be specified via <code>K8S_AUTH_SSL_CA_CERT</code> environment variable.</div>
|
||||||
|
<div style="font-size: small; color: darkgreen"><br/>aliases: ssl_ca_cert</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>context</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Helm option to specify which kubeconfig context to use.</div>
|
||||||
|
<div>If the value is not specified in the task, the value of environment variable <code>K8S_AUTH_CONTEXT</code> will be used instead.</div>
|
||||||
|
<div style="font-size: small; color: darkgreen"><br/>aliases: kube_context</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>force_update</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">boolean</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
||||||
|
<li><div style="color: blue"><b>no</b> ←</div></li>
|
||||||
|
<li>yes</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Whether or not to replace (overwrite) the repo if it already exists.</div>
|
||||||
|
<div style="font-size: small; color: darkgreen"><br/>aliases: force</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>host</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Provide a URL for accessing the API. Can also be specified via <code>K8S_AUTH_HOST</code> environment variable.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>kubeconfig</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">raw</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Helm option to specify kubeconfig path to use.</div>
|
||||||
|
<div>If the value is not specified in the task, the value of environment variable <code>K8S_AUTH_KUBECONFIG</code> will be used instead.</div>
|
||||||
|
<div>The configuration can be provided as dictionary.</div>
|
||||||
|
<div style="font-size: small; color: darkgreen"><br/>aliases: kubeconfig_path</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>pass_credentials</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">boolean</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
||||||
|
<li><div style="color: blue"><b>no</b> ←</div></li>
|
||||||
|
<li>yes</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Pass credentials to all domains.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="1">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -142,6 +269,27 @@ Parameters
|
|||||||
<div style="font-size: small; color: darkgreen"><br/>aliases: username</div>
|
<div style="font-size: small; color: darkgreen"><br/>aliases: username</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>validate_certs</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">boolean</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
||||||
|
<li>no</li>
|
||||||
|
<li><div style="color: blue"><b>yes</b> ←</div></li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Whether or not to verify the API server's SSL certificates. Can also be specified via <code>K8S_AUTH_VERIFY_SSL</code> environment variable.</div>
|
||||||
|
<div style="font-size: small; color: darkgreen"><br/>aliases: verify_ssl</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
|||||||
@@ -28,12 +28,12 @@ Parameters
|
|||||||
|
|
||||||
<table border=0 cellpadding=0 class="documentation-table">
|
<table border=0 cellpadding=0 class="documentation-table">
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="1">Parameter</th>
|
<th colspan="2">Parameter</th>
|
||||||
<th>Choices/<font color="blue">Defaults</font></th>
|
<th>Choices/<font color="blue">Defaults</font></th>
|
||||||
<th width="100%">Comments</th>
|
<th width="100%">Comments</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>binary_path</b>
|
<b>binary_path</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -48,7 +48,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>chart_ref</b>
|
<b>chart_ref</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -67,7 +67,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>chart_repo_url</b>
|
<b>chart_repo_url</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -82,7 +82,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>chart_version</b>
|
<b>chart_version</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -97,13 +97,14 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>dependency_update</b>
|
<b>dependency_update</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
<div style="font-size: small">
|
<div style="font-size: small">
|
||||||
<span style="color: purple">boolean</span>
|
<span style="color: purple">boolean</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
||||||
@@ -119,7 +120,27 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>disable_hook</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">boolean</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
||||||
|
<li><div style="color: blue"><b>no</b> ←</div></li>
|
||||||
|
<li>yes</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Prevent hooks from running during install.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>include_crds</b>
|
<b>include_crds</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -138,7 +159,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>output_dir</b>
|
<b>output_dir</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -154,7 +175,40 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>release_name</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Release name to use in rendered templates.</div>
|
||||||
|
<div style="font-size: small; color: darkgreen"><br/>aliases: name</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>release_namespace</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>namespace scope for this request.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>release_values</b>
|
<b>release_values</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -171,7 +225,85 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>set_values</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">list</span>
|
||||||
|
/ <span style="color: purple">elements=dictionary</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Values to pass to chart configuration.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
<td colspan="1">
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>value</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
/ <span style="color: red">required</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Value to pass to chart configuration (e.g phase=prod).</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>value_type</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">-</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
||||||
|
<li><div style="color: blue"><b>raw</b> ←</div></li>
|
||||||
|
<li>string</li>
|
||||||
|
<li>json</li>
|
||||||
|
<li>file</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Use <code>raw</code> set individual value.</div>
|
||||||
|
<div>Use <code>string</code> to force a string for an individual value.</div>
|
||||||
|
<div>Use <code>file</code> to set individual values from a file when the value itself is too long for the command line or is dynamically generated.</div>
|
||||||
|
<div>Use <code>json</code> to set json values (scalars/objects/arrays). This feature requires helm>=3.10.0.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>show_only</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">list</span>
|
||||||
|
/ <span style="color: purple">elements=string</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<b>Default:</b><br/><div style="color: blue">[]</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Only show manifests rendered from the given templates.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>update_repo_cache</b>
|
<b>update_repo_cache</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -190,7 +322,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
<b>values_files</b>
|
<b>values_files</b>
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
@@ -235,6 +367,24 @@ Examples
|
|||||||
dest: myfile.yaml
|
dest: myfile.yaml
|
||||||
content: "{{ result.stdout }}"
|
content: "{{ result.stdout }}"
|
||||||
|
|
||||||
|
- name: Render MutatingWebhooksConfiguration for revision tag "canary", rev "1-13-0"
|
||||||
|
kubernetes.core.helm_template:
|
||||||
|
chart_ref: istio/istiod
|
||||||
|
chart_version: "1.13.0"
|
||||||
|
release_namespace: "istio-system"
|
||||||
|
show_only:
|
||||||
|
- "templates/revision-tags.yaml"
|
||||||
|
release_values:
|
||||||
|
revision: "1-13-0"
|
||||||
|
revisionTags:
|
||||||
|
- "canary"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: Write templates to file
|
||||||
|
copy:
|
||||||
|
dest: myfile.yaml
|
||||||
|
content: "{{ result.stdout }}"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Return Values
|
Return Values
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ Requirements
|
|||||||
------------
|
------------
|
||||||
The below requirements are needed on the host that executes this module.
|
The below requirements are needed on the host that executes this module.
|
||||||
|
|
||||||
- python >= 3.6
|
- python >= 3.9
|
||||||
- kubernetes >= 12.0.0
|
- kubernetes >= 24.2.0
|
||||||
- PyYAML >= 3.11
|
- PyYAML >= 3.11
|
||||||
|
|
||||||
|
|
||||||
@@ -203,9 +203,29 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
|
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
|
||||||
|
<div>Multiple Kubernetes config file can be provided using separator ';' for Windows platform or ':' for others platforms.</div>
|
||||||
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.</div>
|
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>no_proxy</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>The comma separated list of hosts/domains/IP/CIDR that shouldn'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>=19.15.0. When kubernetes library is less than 19.15.0, it fails even no_proxy set in correct.</div>
|
||||||
|
<div>example value is "localhost,.local,.example.com,127.0.0.1,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ Requirements
|
|||||||
------------
|
------------
|
||||||
The below requirements are needed on the host that executes this module.
|
The below requirements are needed on the host that executes this module.
|
||||||
|
|
||||||
- python >= 3.6
|
- python >= 3.9
|
||||||
- kubernetes >= 12.0.0
|
- kubernetes >= 24.2.0
|
||||||
|
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@@ -215,6 +215,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
|
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
|
||||||
|
<div>Multiple Kubernetes config file can be provided using separator ';' for Windows platform or ':' for others platforms.</div>
|
||||||
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.</div>
|
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -271,6 +272,25 @@ Parameters
|
|||||||
<div>This option is ignored when <em>content</em> is set or when <em>state</em> is set to <code>from_pod</code>.</div>
|
<div>This option is ignored when <em>content</em> is set or when <em>state</em> is set to <code>from_pod</code>.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>no_proxy</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>The comma separated list of hosts/domains/IP/CIDR that shouldn'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>=19.15.0. When kubernetes library is less than 19.15.0, it fails even no_proxy set in correct.</div>
|
||||||
|
<div>example value is "localhost,.local,.example.com,127.0.0.1,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -538,7 +558,7 @@ Examples
|
|||||||
state: from_pod
|
state: from_pod
|
||||||
|
|
||||||
# copy content into a file in the remote pod
|
# copy content into a file in the remote pod
|
||||||
- name: Copy /tmp/foo from a remote pod to /tmp/bar locally
|
- name: Copy content into a file in the remote pod
|
||||||
kubernetes.core.k8s_cp:
|
kubernetes.core.k8s_cp:
|
||||||
state: to_pod
|
state: to_pod
|
||||||
namespace: some-namespace
|
namespace: some-namespace
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ Requirements
|
|||||||
------------
|
------------
|
||||||
The below requirements are needed on the host that executes this module.
|
The below requirements are needed on the host that executes this module.
|
||||||
|
|
||||||
- python >= 3.6
|
- python >= 3.9
|
||||||
- kubernetes >= 12.0.0
|
- kubernetes >= 24.2.0
|
||||||
|
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@@ -132,6 +132,7 @@ Parameters
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
<b>Default:</b><br/><div style="color: blue">{}</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>Specify options to delete pods.</div>
|
<div>Specify options to delete pods.</div>
|
||||||
@@ -147,6 +148,7 @@ Parameters
|
|||||||
<div style="font-size: small">
|
<div style="font-size: small">
|
||||||
<span style="color: purple">boolean</span>
|
<span style="color: purple">boolean</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
||||||
@@ -155,7 +157,7 @@ Parameters
|
|||||||
</ul>
|
</ul>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>Continue even if there are pods using emptyDir (local data that will be deleted when the node is drained)</div>
|
<div>Continue even if there are pods using emptyDir (local data that will be deleted when the node is drained).</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -334,6 +336,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
|
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
|
||||||
|
<div>Multiple Kubernetes config file can be provided using separator ';' for Windows platform or ':' for others platforms.</div>
|
||||||
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.</div>
|
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -353,6 +356,25 @@ Parameters
|
|||||||
<div>The name of the node.</div>
|
<div>The name of the node.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>no_proxy</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>The comma separated list of hosts/domains/IP/CIDR that shouldn'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>=19.15.0. When kubernetes library is less than 19.15.0, it fails even no_proxy set in correct.</div>
|
||||||
|
<div>example value is "localhost,.local,.example.com,127.0.0.1,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -392,6 +414,25 @@ Parameters
|
|||||||
<div>The fix for this k8s python library is here: https://github.com/kubernetes-client/python-base/pull/169</div>
|
<div>The fix for this k8s python library is here: https://github.com/kubernetes-client/python-base/pull/169</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>pod_selectors</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">list</span>
|
||||||
|
/ <span style="color: purple">elements=string</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 3.0.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Label selector to filter pods on the node.</div>
|
||||||
|
<div>This option has effect only when <code>state</code> is set to <em>drain</em>.</div>
|
||||||
|
<div style="font-size: small; color: darkgreen"><br/>aliases: label_selectors</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -561,7 +602,7 @@ Examples
|
|||||||
state: drain
|
state: drain
|
||||||
name: foo
|
name: foo
|
||||||
delete_options:
|
delete_options:
|
||||||
terminate_grace_period: 900
|
terminate_grace_period: 900
|
||||||
|
|
||||||
- name: Mark node "foo" as schedulable.
|
- name: Mark node "foo" as schedulable.
|
||||||
kubernetes.core.k8s_drain:
|
kubernetes.core.k8s_drain:
|
||||||
@@ -573,6 +614,14 @@ Examples
|
|||||||
state: cordon
|
state: cordon
|
||||||
name: foo
|
name: foo
|
||||||
|
|
||||||
|
- name: Drain node "foo" using label selector to filter the list of pods to be drained.
|
||||||
|
kubernetes.core.k8s_drain:
|
||||||
|
state: drain
|
||||||
|
name: foo
|
||||||
|
pod_selectors:
|
||||||
|
- 'app!=csi-attacher'
|
||||||
|
- 'app!=csi-provisioner'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Return Values
|
Return Values
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ Requirements
|
|||||||
------------
|
------------
|
||||||
The below requirements are needed on the host that executes this module.
|
The below requirements are needed on the host that executes this module.
|
||||||
|
|
||||||
- python >= 3.6
|
- python >= 3.9
|
||||||
- kubernetes >= 12.0.0
|
- kubernetes >= 24.2.0
|
||||||
- PyYAML >= 3.11
|
- PyYAML >= 3.11
|
||||||
|
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ Parameters
|
|||||||
<td>
|
<td>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>The command to execute</div>
|
<div>The command to execute.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -134,6 +134,7 @@ Parameters
|
|||||||
<td>
|
<td>
|
||||||
<div>The name of the container in the pod to connect to.</div>
|
<div>The name of the container in the pod to connect to.</div>
|
||||||
<div>Defaults to only container if there is only one container in the pod.</div>
|
<div>Defaults to only container if there is only one container in the pod.</div>
|
||||||
|
<div>If not specified, will choose the first container from the given pod as kubectl cmdline does.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -214,6 +215,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
|
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
|
||||||
|
<div>Multiple Kubernetes config file can be provided using separator ';' for Windows platform or ':' for others platforms.</div>
|
||||||
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.</div>
|
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -230,7 +232,26 @@ Parameters
|
|||||||
<td>
|
<td>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>The pod namespace name</div>
|
<div>The pod namespace name.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>no_proxy</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>The comma separated list of hosts/domains/IP/CIDR that shouldn'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>=19.15.0. When kubernetes library is less than 19.15.0, it fails even no_proxy set in correct.</div>
|
||||||
|
<div>example value is "localhost,.local,.example.com,127.0.0.1,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -285,7 +306,7 @@ Parameters
|
|||||||
<td>
|
<td>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>The pod name</div>
|
<div>The pod name.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -302,7 +323,7 @@ Parameters
|
|||||||
<td>
|
<td>
|
||||||
<div>The URL of an HTTP proxy to use for the connection.</div>
|
<div>The URL of an HTTP proxy to use for the connection.</div>
|
||||||
<div>Can also be specified via <em>K8S_AUTH_PROXY</em> environment variable.</div>
|
<div>Can also be specified via <em>K8S_AUTH_PROXY</em> environment variable.</div>
|
||||||
<div>Please note that this module does not pick up typical proxy settings from the environment (e.g. HTTP_PROXY).</div>
|
<div>Please note that this module does not pick up typical proxy settings from the environment (for example, HTTP_PROXY).</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -449,6 +470,13 @@ Examples
|
|||||||
msg: "cmd failed"
|
msg: "cmd failed"
|
||||||
when: command_status.rc != 0
|
when: command_status.rc != 0
|
||||||
|
|
||||||
|
- name: Specify a container name to execute the command on
|
||||||
|
kubernetes.core.k8s_exec:
|
||||||
|
namespace: myproject
|
||||||
|
pod: busybox-test
|
||||||
|
container: manager
|
||||||
|
command: echo "hello"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Return Values
|
Return Values
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ Requirements
|
|||||||
------------
|
------------
|
||||||
The below requirements are needed on the host that executes this module.
|
The below requirements are needed on the host that executes this module.
|
||||||
|
|
||||||
- python >= 3.6
|
- python >= 3.9
|
||||||
- kubernetes >= 12.0.0
|
- kubernetes >= 24.2.0
|
||||||
- PyYAML >= 3.11
|
- PyYAML >= 3.11
|
||||||
|
|
||||||
|
|
||||||
@@ -153,11 +153,31 @@ Parameters
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
<b>Default:</b><br/><div style="color: blue">[]</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>List of field selectors to use to filter results</div>
|
<div>List of field selectors to use to filter results</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>hidden_fields</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">list</span>
|
||||||
|
/ <span style="color: purple">elements=string</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 3.0.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Hide fields matching any of the field definitions in the result</div>
|
||||||
|
<div>An example might be <code>hidden_fields=[metadata.managedFields]</code></div>
|
||||||
|
<div>Only field definitions that don't reference list items are supported (so V(spec.containers[0]) would not work)</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -240,6 +260,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
|
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
|
||||||
|
<div>Multiple Kubernetes config file can be provided using separator ';' for Windows platform or ':' for others platforms.</div>
|
||||||
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.</div>
|
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -254,6 +275,7 @@ Parameters
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
<b>Default:</b><br/><div style="color: blue">[]</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>List of label selectors to use to filter results</div>
|
<div>List of label selectors to use to filter results</div>
|
||||||
@@ -295,6 +317,25 @@ Parameters
|
|||||||
<div>If <em>resource definition</em> is provided, the <em>metadata.namespace</em> value from the <em>resource_definition</em> will override this option.</div>
|
<div>If <em>resource definition</em> is provided, the <em>metadata.namespace</em> value from the <em>resource_definition</em> will override this option.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>no_proxy</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>The comma separated list of hosts/domains/IP/CIDR that shouldn'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>=19.15.0. When kubernetes library is less than 19.15.0, it fails even no_proxy set in correct.</div>
|
||||||
|
<div>example value is "localhost,.local,.example.com,127.0.0.1,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
|||||||
@@ -13,6 +13,15 @@ kubernetes.core.k8s
|
|||||||
:local:
|
:local:
|
||||||
:depth: 1
|
:depth: 1
|
||||||
|
|
||||||
|
DEPRECATED
|
||||||
|
----------
|
||||||
|
:Removed in collection release after
|
||||||
|
:Why: As discussed in https://github.com/ansible-collections/kubernetes.core/issues/31, we decided to
|
||||||
|
remove the k8s inventory plugin in release 6.0.0.
|
||||||
|
|
||||||
|
:Alternative: Use :ref:`kubernetes.core.k8s_info <kubernetes.core.k8s_info_module>` and :ref:`ansible.builtin.add_host <ansible.builtin.add_host_module>` instead.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Synopsis
|
Synopsis
|
||||||
--------
|
--------
|
||||||
@@ -27,8 +36,8 @@ Requirements
|
|||||||
------------
|
------------
|
||||||
The below requirements are needed on the local Ansible controller node that executes this inventory.
|
The below requirements are needed on the local Ansible controller node that executes this inventory.
|
||||||
|
|
||||||
- python >= 3.6
|
- python >= 3.9
|
||||||
- kubernetes >= 12.0.0
|
- kubernetes >= 24.2.0
|
||||||
- PyYAML >= 3.11
|
- PyYAML >= 3.11
|
||||||
|
|
||||||
|
|
||||||
@@ -322,24 +331,24 @@ Examples
|
|||||||
|
|
||||||
# File must be named k8s.yaml or k8s.yml
|
# File must be named k8s.yaml or k8s.yml
|
||||||
|
|
||||||
# Authenticate with token, and return all pods and services for all namespaces
|
- name: Authenticate with token, and return all pods and services for all namespaces
|
||||||
plugin: kubernetes.core.k8s
|
plugin: kubernetes.core.k8s
|
||||||
connections:
|
connections:
|
||||||
- host: https://192.168.64.4:8443
|
- host: https://192.168.64.4:8443
|
||||||
api_key: xxxxxxxxxxxxxxxx
|
api_key: xxxxxxxxxxxxxxxx
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
|
|
||||||
# Use default config (~/.kube/config) file and active context, and return objects for a specific namespace
|
- name: Use default config (~/.kube/config) file and active context, and return objects for a specific namespace
|
||||||
plugin: kubernetes.core.k8s
|
plugin: kubernetes.core.k8s
|
||||||
connections:
|
connections:
|
||||||
- namespaces:
|
- namespaces:
|
||||||
- testing
|
- testing
|
||||||
|
|
||||||
# Use a custom config file, and a specific context.
|
- name: Use a custom config file, and a specific context.
|
||||||
plugin: kubernetes.core.k8s
|
plugin: kubernetes.core.k8s
|
||||||
connections:
|
connections:
|
||||||
- kubeconfig: /path/to/config
|
- kubeconfig: /path/to/config
|
||||||
context: 'awx/192-168-64-4:8443/developer'
|
context: 'awx/192-168-64-4:8443/developer'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -348,11 +357,15 @@ Status
|
|||||||
------
|
------
|
||||||
|
|
||||||
|
|
||||||
|
- This inventory will be removed in version 6.0.0. *[deprecated]*
|
||||||
|
- For more information see `DEPRECATED`_.
|
||||||
|
|
||||||
|
|
||||||
Authors
|
Authors
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
|
|
||||||
- Chris Houseknecht <@chouseknecht>
|
- Chris Houseknecht (@chouseknecht)
|
||||||
- Fabian von Feilitzsch <@fabianvf>
|
- Fabian von Feilitzsch (@fabianvf)
|
||||||
|
|
||||||
|
|
||||||
.. hint::
|
.. hint::
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ Requirements
|
|||||||
------------
|
------------
|
||||||
The below requirements are needed on the host that executes this module.
|
The below requirements are needed on the host that executes this module.
|
||||||
|
|
||||||
- python >= 3.6
|
- python >= 3.9
|
||||||
- kubernetes >= 12.0.0
|
- kubernetes >= 24.2.0
|
||||||
- PyYAML >= 3.11
|
- PyYAML >= 3.11
|
||||||
- jsonpatch
|
- jsonpatch
|
||||||
|
|
||||||
@@ -220,6 +220,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
|
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
|
||||||
|
<div>Multiple Kubernetes config file can be provided using separator ';' for Windows platform or ':' for others platforms.</div>
|
||||||
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.</div>
|
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -256,6 +257,25 @@ Parameters
|
|||||||
<div>Use in conjunction with <em>api_version</em>, <em>kind</em>, and <em>name</em> to identify a specific object.</div>
|
<div>Use in conjunction with <em>api_version</em>, <em>kind</em>, and <em>name</em> to identify a specific object.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>no_proxy</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>The comma separated list of hosts/domains/IP/CIDR that shouldn'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>=19.15.0. When kubernetes library is less than 19.15.0, it fails even no_proxy set in correct.</div>
|
||||||
|
<div>example value is "localhost,.local,.example.com,127.0.0.1,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -594,7 +614,7 @@ Examples
|
|||||||
path: /metadata/labels/app
|
path: /metadata/labels/app
|
||||||
value: myapp
|
value: myapp
|
||||||
- op: replace
|
- op: replace
|
||||||
patch: /spec/containers/0/image
|
path: /spec/containers/0/image
|
||||||
value: nginx
|
value: nginx
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ Requirements
|
|||||||
------------
|
------------
|
||||||
The below requirements are needed on the host that executes this module.
|
The below requirements are needed on the host that executes this module.
|
||||||
|
|
||||||
- python >= 3.6
|
- python >= 3.9
|
||||||
- kubernetes >= 12.0.0
|
- kubernetes >= 24.2.0
|
||||||
- PyYAML >= 3.11
|
- PyYAML >= 3.11
|
||||||
|
|
||||||
|
|
||||||
@@ -44,6 +44,27 @@ Parameters
|
|||||||
<th>Choices/<font color="blue">Defaults</font></th>
|
<th>Choices/<font color="blue">Defaults</font></th>
|
||||||
<th width="100%">Comments</th>
|
<th width="100%">Comments</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>all_containers</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">boolean</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
||||||
|
<li>no</li>
|
||||||
|
<li>yes</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>If set to <code>true</code>, retrieve all containers' logs in the pod(s).</div>
|
||||||
|
<div>mutually exclusive with <code>container</code>.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -141,7 +162,8 @@ Parameters
|
|||||||
<td>
|
<td>
|
||||||
<div>Use to specify the container within a pod to grab the log from.</div>
|
<div>Use to specify the container within a pod to grab the log from.</div>
|
||||||
<div>If there is only one container, this will default to that container.</div>
|
<div>If there is only one container, this will default to that container.</div>
|
||||||
<div>If there is more than one container, this option is required.</div>
|
<div>If there is more than one container, this option is required or set <em>all_containers</em> to <code>true</code>.</div>
|
||||||
|
<div>mutually exclusive with <code>all_containers</code>.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -240,6 +262,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
|
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
|
||||||
|
<div>Multiple Kubernetes config file can be provided using separator ';' for Windows platform or ':' for others platforms.</div>
|
||||||
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.</div>
|
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -254,6 +277,7 @@ Parameters
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
<b>Default:</b><br/><div style="color: blue">[]</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>List of label selectors to use to filter results</div>
|
<div>List of label selectors to use to filter results</div>
|
||||||
@@ -295,6 +319,25 @@ Parameters
|
|||||||
<div>If <em>resource definition</em> is provided, the <em>metadata.namespace</em> value from the <em>resource_definition</em> will override this option.</div>
|
<div>If <em>resource definition</em> is provided, the <em>metadata.namespace</em> value from the <em>resource_definition</em> will override this option.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>no_proxy</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>The comma separated list of hosts/domains/IP/CIDR that shouldn'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>=19.15.0. When kubernetes library is less than 19.15.0, it fails even no_proxy set in correct.</div>
|
||||||
|
<div>example value is "localhost,.local,.example.com,127.0.0.1,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -334,6 +377,26 @@ Parameters
|
|||||||
<div>The fix for this k8s python library is here: https://github.com/kubernetes-client/python-base/pull/169</div>
|
<div>The fix for this k8s python library is here: https://github.com/kubernetes-client/python-base/pull/169</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>previous</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">boolean</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
||||||
|
<li><div style="color: blue"><b>no</b> ←</div></li>
|
||||||
|
<li>yes</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>If <code>true</code>, print the logs for the previous instance of the container in a pod if it exists.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -435,6 +498,22 @@ Parameters
|
|||||||
<div>A relative time in seconds before the current time from which to show logs.</div>
|
<div>A relative time in seconds before the current time from which to show logs.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>tail_lines</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">integer</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.4.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>A number of lines from the end of the logs to retrieve.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -519,8 +598,16 @@ Examples
|
|||||||
kind: DeploymentConfig
|
kind: DeploymentConfig
|
||||||
namespace: testing
|
namespace: testing
|
||||||
name: example
|
name: example
|
||||||
|
tail_lines: 100
|
||||||
register: log
|
register: log
|
||||||
|
|
||||||
|
# This will get the logs from all containers in Pod
|
||||||
|
- name: Get the logs from all containers in pod
|
||||||
|
kubernetes.core.k8s_log:
|
||||||
|
namespace: testing
|
||||||
|
name: some-pod
|
||||||
|
all_containers: true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Return Values
|
Return Values
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ Requirements
|
|||||||
------------
|
------------
|
||||||
The below requirements are needed on the local Ansible controller node that executes this lookup.
|
The below requirements are needed on the local Ansible controller node that executes this lookup.
|
||||||
|
|
||||||
- python >= 3.6
|
- python >= 3.9
|
||||||
- kubernetes >= 12.0.0
|
- kubernetes >= 24.2.0
|
||||||
- PyYAML >= 3.11
|
- PyYAML >= 3.11
|
||||||
|
|
||||||
|
|
||||||
@@ -438,106 +438,28 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
|
|||||||
|
|
||||||
<table border=0 cellpadding=0 class="documentation-table">
|
<table border=0 cellpadding=0 class="documentation-table">
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="2">Key</th>
|
<th colspan="1">Key</th>
|
||||||
<th>Returned</th>
|
<th>Returned</th>
|
||||||
<th width="100%">Description</th>
|
<th width="100%">Description</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="1">
|
||||||
<div class="ansibleOptionAnchor" id="return-"></div>
|
<div class="ansibleOptionAnchor" id="return-"></div>
|
||||||
<b>_list</b>
|
<b>_list</b>
|
||||||
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
||||||
<div style="font-size: small">
|
<div style="font-size: small">
|
||||||
<span style="color: purple">complex</span>
|
<span style="color: purple">list</span>
|
||||||
|
/ <span style="color: purple">elements=dictionary</span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>
|
<td>
|
||||||
<div>One ore more object definitions returned from the API.</div>
|
<div>One ore more object definitions returned from the API.</div>
|
||||||
<br/>
|
<br/>
|
||||||
|
<div style="font-size: smaller"><b>Sample:</b></div>
|
||||||
|
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[{'kind': 'ConfigMap', 'apiVersion': 'v1', 'metadata': {'creationTimestamp': '2022-03-04T13:59:49Z', 'name': 'my-config-map', 'namespace': 'default', 'resourceVersion': '418', 'uid': '5714b011-d090-4eac-8272-a0ea82ec0abd'}, 'data': {'key1': 'val1'}}]</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td class="elbow-placeholder"> </td>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="return-"></div>
|
|
||||||
<b>api_version</b>
|
|
||||||
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
|
||||||
<div style="font-size: small">
|
|
||||||
<span style="color: purple">string</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>success</td>
|
|
||||||
<td>
|
|
||||||
<div>The versioned schema of this representation of an object.</div>
|
|
||||||
<br/>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="elbow-placeholder"> </td>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="return-"></div>
|
|
||||||
<b>kind</b>
|
|
||||||
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
|
||||||
<div style="font-size: small">
|
|
||||||
<span style="color: purple">string</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>success</td>
|
|
||||||
<td>
|
|
||||||
<div>Represents the REST resource this object represents.</div>
|
|
||||||
<br/>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="elbow-placeholder"> </td>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="return-"></div>
|
|
||||||
<b>metadata</b>
|
|
||||||
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
|
||||||
<div style="font-size: small">
|
|
||||||
<span style="color: purple">complex</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>success</td>
|
|
||||||
<td>
|
|
||||||
<div>Standard object metadata. Includes name, namespace, annotations, labels, etc.</div>
|
|
||||||
<br/>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="elbow-placeholder"> </td>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="return-"></div>
|
|
||||||
<b>spec</b>
|
|
||||||
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
|
||||||
<div style="font-size: small">
|
|
||||||
<span style="color: purple">complex</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>success</td>
|
|
||||||
<td>
|
|
||||||
<div>Specific attributes of the object. Will vary based on the <em>api_version</em> and <em>kind</em>.</div>
|
|
||||||
<br/>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="elbow-placeholder"> </td>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="return-"></div>
|
|
||||||
<b>status</b>
|
|
||||||
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
|
||||||
<div style="font-size: small">
|
|
||||||
<span style="color: purple">complex</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>success</td>
|
|
||||||
<td>
|
|
||||||
<div>Current status details for the object.</div>
|
|
||||||
<br/>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
|
|
||||||
@@ -549,8 +471,8 @@ Status
|
|||||||
Authors
|
Authors
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
|
|
||||||
- Chris Houseknecht <@chouseknecht>
|
- Chris Houseknecht (@chouseknecht)
|
||||||
- Fabian von Feilitzsch <@fabianvf>
|
- Fabian von Feilitzsch (@fabianvf)
|
||||||
|
|
||||||
|
|
||||||
.. hint::
|
.. hint::
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ Requirements
|
|||||||
------------
|
------------
|
||||||
The below requirements are needed on the host that executes this module.
|
The below requirements are needed on the host that executes this module.
|
||||||
|
|
||||||
- python >= 3.6
|
- python >= 3.9
|
||||||
- kubernetes >= 12.0.0
|
- kubernetes >= 24.2.0
|
||||||
- PyYAML >= 3.11
|
- PyYAML >= 3.11
|
||||||
- jsonpatch
|
- jsonpatch
|
||||||
|
|
||||||
@@ -208,6 +208,30 @@ Parameters
|
|||||||
<div>This has no effect on the validation step which is controlled by the <code>validate.fail_on_error</code> parameter.</div>
|
<div>This has no effect on the validation step which is controlled by the <code>validate.fail_on_error</code> parameter.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>delete_all</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">boolean</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 3.0.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
||||||
|
<li><div style="color: blue"><b>no</b> ←</div></li>
|
||||||
|
<li>yes</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>When this option is set to <em>true</em> and <em>state=absent</em>, module will delete all resources of the specified resource type in the requested namespace.</div>
|
||||||
|
<div>Ignored when <code>state</code> is not set to <em>absent</em> or when one of (src), <code>name</code> or <code>resource_definition</code> is provided.</div>
|
||||||
|
<div>Parameter <code>kind</code> is required to use this option.</div>
|
||||||
|
<div>This parameter can be used with <code>label_selectors</code> to restrict the resources to be deleted.</div>
|
||||||
|
<div style="font-size: small; color: darkgreen"><br/>aliases: all</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3">
|
<td colspan="3">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -336,6 +360,45 @@ Parameters
|
|||||||
<div>If set to <code>yes</code>, and <em>state</em> is <code>present</code>, an existing object will be replaced.</div>
|
<div>If set to <code>yes</code>, and <em>state</em> is <code>present</code>, an existing object will be replaced.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>generate_name</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Use to specify the basis of an object name and random characters will be added automatically on server to generate a unique name.</div>
|
||||||
|
<div>This option is ignored when <em>state</em> is not set to <code>present</code> or when <em>apply</em> is set to <code>yes</code>.</div>
|
||||||
|
<div>If <em>resource definition</em> is provided, the <em>metadata.generateName</em> value from the <em>resource_definition</em> will override this option.</div>
|
||||||
|
<div>If <em>resource definition</em> is provided, and contains <em>metadata.name</em>, this option is ignored.</div>
|
||||||
|
<div>mutually exclusive with <code>name</code>.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>hidden_fields</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">list</span>
|
||||||
|
/ <span style="color: purple">elements=string</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 3.0.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Hide fields matching this option in the result</div>
|
||||||
|
<div>An example might be <code>hidden_fields=[metadata.managedFields]</code></div>
|
||||||
|
<div>Only field definitions that don't reference list items are supported (so V(spec.containers[0]) would not work)</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3">
|
<td colspan="3">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -417,6 +480,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
|
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
|
||||||
|
<div>Multiple Kubernetes config file can be provided using separator ';' for Windows platform or ':' for others platforms.</div>
|
||||||
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.</div>
|
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -460,7 +524,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>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. This defaults to <code>['strategic-merge', 'merge']</code>, which is ideal for using the same parameters on resource kinds that combine Custom Resources and built-in resources.</div>
|
<div>If more than one <code>merge_type</code> is given, the merge_types will be tried in order. This defaults to <code>['strategic-merge', 'merge']</code>, which is ideal for using the same parameters on resource kinds that combine Custom Resources and built-in resources.</div>
|
||||||
<div>mutually exclusive with <code>apply</code></div>
|
<div>mutually exclusive with <code>apply</code></div>
|
||||||
<div><em>merge_type=json</em> is deprecated and will be removed in version 3.0.0. Please use <span class='module'>kubernetes.core.k8s_json_patch</span> instead.</div>
|
<div><em>merge_type=json</em> is deprecated and will be removed in version 4.0.0. Please use <span class='module'>kubernetes.core.k8s_json_patch</span> instead.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -499,6 +563,25 @@ Parameters
|
|||||||
<div>If <em>resource definition</em> is provided, the <em>metadata.namespace</em> value from the <em>resource_definition</em> will override this option.</div>
|
<div>If <em>resource definition</em> is provided, the <em>metadata.namespace</em> value from the <em>resource_definition</em> will override this option.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>no_proxy</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>The comma separated list of hosts/domains/IP/CIDR that shouldn'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>=19.15.0. When kubernetes library is less than 19.15.0, it fails even no_proxy set in correct.</div>
|
||||||
|
<div>example value is "localhost,.local,.example.com,127.0.0.1,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3">
|
<td colspan="3">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -640,6 +723,63 @@ Parameters
|
|||||||
<div style="font-size: small; color: darkgreen"><br/>aliases: definition, inline</div>
|
<div style="font-size: small; color: darkgreen"><br/>aliases: definition, inline</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>server_side_apply</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">dictionary</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>When this option is set, apply runs in the server instead of the client.</div>
|
||||||
|
<div>Ignored if <code>apply</code> is not set or is set to False.</div>
|
||||||
|
<div>This option requires "kubernetes >= 19.15.0".</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>field_manager</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
/ <span style="color: red">required</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Name of the manager used to track field ownership.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>force_conflicts</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">boolean</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
||||||
|
<li><div style="color: blue"><b>no</b> ←</div></li>
|
||||||
|
<li>yes</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>A conflict is a special status error that occurs when an Server Side Apply operation tries to change a field, which another user also claims to manage.</div>
|
||||||
|
<div>When set to True, server-side apply will force the changes against conflicts.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3">
|
<td colspan="3">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -654,7 +794,8 @@ Parameters
|
|||||||
<td>
|
<td>
|
||||||
<div>Provide a path to a file containing a valid YAML definition of an object or objects to be created or updated. Mutually exclusive with <em>resource_definition</em>. NOTE: <em>kind</em>, <em>api_version</em>, <em>name</em>, and <em>namespace</em> will be overwritten by corresponding values found in the configuration read in from the <em>src</em> file.</div>
|
<div>Provide a path to a file containing a valid YAML definition of an object or objects to be created or updated. Mutually exclusive with <em>resource_definition</em>. NOTE: <em>kind</em>, <em>api_version</em>, <em>name</em>, and <em>namespace</em> will be overwritten by corresponding values found in the configuration read in from the <em>src</em> file.</div>
|
||||||
<div>Reads from the local file system. To read from the Ansible controller's file system, including vaulted files, use the file lookup plugin or template lookup plugin, combined with the from_yaml filter, and pass the result to <em>resource_definition</em>. See Examples below.</div>
|
<div>Reads from the local file system. To read from the Ansible controller's file system, including vaulted files, use the file lookup plugin or template lookup plugin, combined with the from_yaml filter, and pass the result to <em>resource_definition</em>. See Examples below.</div>
|
||||||
<div>Mutually exclusive with <em>template</em> in case of <span class='module'>k8s</span> module.</div>
|
<div>The URL to manifest files that can be used to create the resource. Added in version 2.4.0.</div>
|
||||||
|
<div>Mutually exclusive with <em>template</em> in case of <span class='module'>kubernetes.core.k8s</span> module.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -1016,6 +1157,14 @@ Examples
|
|||||||
state: present
|
state: present
|
||||||
definition: "{{ lookup('file', '/testing/deployment.yml') | from_yaml }}"
|
definition: "{{ lookup('file', '/testing/deployment.yml') | from_yaml }}"
|
||||||
|
|
||||||
|
- name: >-
|
||||||
|
(Alternative) Read definition file from the Ansible controller file system.
|
||||||
|
In this case, the definition file contains multiple YAML documents, separated by ---.
|
||||||
|
If the definition file has been encrypted with Ansible Vault it will automatically be decrypted.
|
||||||
|
kubernetes.core.k8s:
|
||||||
|
state: present
|
||||||
|
definition: "{{ lookup('file', '/testing/deployment.yml') | from_yaml_all }}"
|
||||||
|
|
||||||
- name: Read definition template file from the Ansible controller file system
|
- name: Read definition template file from the Ansible controller file system
|
||||||
kubernetes.core.k8s:
|
kubernetes.core.k8s:
|
||||||
state: present
|
state: present
|
||||||
@@ -1033,10 +1182,10 @@ Examples
|
|||||||
kubernetes.core.k8s:
|
kubernetes.core.k8s:
|
||||||
state: present
|
state: present
|
||||||
template:
|
template:
|
||||||
- path: '/testing/deployment_one.j2'
|
- path: '/testing/deployment_one.j2'
|
||||||
- path: '/testing/deployment_two.j2'
|
- path: '/testing/deployment_two.j2'
|
||||||
variable_start_string: '[['
|
variable_start_string: '[['
|
||||||
variable_end_string: ']]'
|
variable_end_string: ']]'
|
||||||
|
|
||||||
- name: fail on validation errors
|
- name: fail on validation errors
|
||||||
kubernetes.core.k8s:
|
kubernetes.core.k8s:
|
||||||
@@ -1093,6 +1242,41 @@ Examples
|
|||||||
labels:
|
labels:
|
||||||
support: patch
|
support: patch
|
||||||
|
|
||||||
|
# Create object using generateName
|
||||||
|
- name: create resource using name generated by the server
|
||||||
|
kubernetes.core.k8s:
|
||||||
|
state: present
|
||||||
|
generate_name: pod-
|
||||||
|
definition:
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: py
|
||||||
|
image: python:3.7-alpine
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
|
||||||
|
# Server side apply
|
||||||
|
- name: Create configmap using server side apply
|
||||||
|
kubernetes.core.k8s:
|
||||||
|
namespace: testing
|
||||||
|
definition:
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: my-configmap
|
||||||
|
apply: yes
|
||||||
|
server_side_apply:
|
||||||
|
field_manager: ansible
|
||||||
|
|
||||||
|
# Delete all Deployment from specified namespace
|
||||||
|
- name: Delete all Deployment from specified namespace
|
||||||
|
kubernetes.core.k8s:
|
||||||
|
api_version: apps/v1
|
||||||
|
namespace: testing
|
||||||
|
kind: Deployment
|
||||||
|
delete_all: true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Return Values
|
Return Values
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ Requirements
|
|||||||
------------
|
------------
|
||||||
The below requirements are needed on the host that executes this module.
|
The below requirements are needed on the host that executes this module.
|
||||||
|
|
||||||
- python >= 3.6
|
- python >= 3.9
|
||||||
- kubernetes >= 12.0.0
|
- kubernetes >= 24.2.0
|
||||||
- PyYAML >= 3.11
|
- PyYAML >= 3.11
|
||||||
|
|
||||||
|
|
||||||
@@ -152,6 +152,7 @@ Parameters
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
<b>Default:</b><br/><div style="color: blue">[]</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>List of field selectors to use to filter results.</div>
|
<div>List of field selectors to use to filter results.</div>
|
||||||
@@ -238,6 +239,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
|
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
|
||||||
|
<div>Multiple Kubernetes config file can be provided using separator ';' for Windows platform or ':' for others platforms.</div>
|
||||||
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.</div>
|
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -252,6 +254,7 @@ Parameters
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
<b>Default:</b><br/><div style="color: blue">[]</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>List of label selectors to use to filter results.</div>
|
<div>List of label selectors to use to filter results.</div>
|
||||||
@@ -293,6 +296,25 @@ Parameters
|
|||||||
<div>If <em>resource definition</em> is provided, the <em>metadata.namespace</em> value from the <em>resource_definition</em> will override this option.</div>
|
<div>If <em>resource definition</em> is provided, the <em>metadata.namespace</em> value from the <em>resource_definition</em> will override this option.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>no_proxy</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>The comma separated list of hosts/domains/IP/CIDR that shouldn'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>=19.15.0. When kubernetes library is less than 19.15.0, it fails even no_proxy set in correct.</div>
|
||||||
|
<div>example value is "localhost,.local,.example.com,127.0.0.1,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ Requirements
|
|||||||
------------
|
------------
|
||||||
The below requirements are needed on the host that executes this module.
|
The below requirements are needed on the host that executes this module.
|
||||||
|
|
||||||
- python >= 3.6
|
- python >= 3.9
|
||||||
- kubernetes >= 12.0.0
|
- kubernetes >= 24.2.0
|
||||||
- PyYAML >= 3.11
|
- PyYAML >= 3.11
|
||||||
|
|
||||||
|
|
||||||
@@ -255,6 +255,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
|
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
|
||||||
|
<div>Multiple Kubernetes config file can be provided using separator ';' for Windows platform or ':' for others platforms.</div>
|
||||||
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.</div>
|
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -270,6 +271,7 @@ Parameters
|
|||||||
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.0.0</div>
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.0.0</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
<b>Default:</b><br/><div style="color: blue">[]</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>List of label selectors to use to filter results.</div>
|
<div>List of label selectors to use to filter results.</div>
|
||||||
@@ -311,6 +313,25 @@ Parameters
|
|||||||
<div>If <em>resource definition</em> is provided, the <em>metadata.namespace</em> value from the <em>resource_definition</em> will override this option.</div>
|
<div>If <em>resource definition</em> is provided, the <em>metadata.namespace</em> value from the <em>resource_definition</em> will override this option.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>no_proxy</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>The comma separated list of hosts/domains/IP/CIDR that shouldn'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>=19.15.0. When kubernetes library is less than 19.15.0, it fails even no_proxy set in correct.</div>
|
||||||
|
<div>example value is "localhost,.local,.example.com,127.0.0.1,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -497,7 +518,8 @@ Parameters
|
|||||||
<td>
|
<td>
|
||||||
<div>Provide a path to a file containing a valid YAML definition of an object or objects to be created or updated. Mutually exclusive with <em>resource_definition</em>. NOTE: <em>kind</em>, <em>api_version</em>, <em>name</em>, and <em>namespace</em> will be overwritten by corresponding values found in the configuration read in from the <em>src</em> file.</div>
|
<div>Provide a path to a file containing a valid YAML definition of an object or objects to be created or updated. Mutually exclusive with <em>resource_definition</em>. NOTE: <em>kind</em>, <em>api_version</em>, <em>name</em>, and <em>namespace</em> will be overwritten by corresponding values found in the configuration read in from the <em>src</em> file.</div>
|
||||||
<div>Reads from the local file system. To read from the Ansible controller's file system, including vaulted files, use the file lookup plugin or template lookup plugin, combined with the from_yaml filter, and pass the result to <em>resource_definition</em>. See Examples below.</div>
|
<div>Reads from the local file system. To read from the Ansible controller's file system, including vaulted files, use the file lookup plugin or template lookup plugin, combined with the from_yaml filter, and pass the result to <em>resource_definition</em>. See Examples below.</div>
|
||||||
<div>Mutually exclusive with <em>template</em> in case of <span class='module'>k8s</span> module.</div>
|
<div>The URL to manifest files that can be used to create the resource. Added in version 2.4.0.</div>
|
||||||
|
<div>Mutually exclusive with <em>template</em> in case of <span class='module'>kubernetes.core.k8s</span> module.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ Requirements
|
|||||||
------------
|
------------
|
||||||
The below requirements are needed on the host that executes this module.
|
The below requirements are needed on the host that executes this module.
|
||||||
|
|
||||||
- python >= 3.6
|
- python >= 3.9
|
||||||
- kubernetes >= 12.0.0
|
- kubernetes >= 24.2.0
|
||||||
|
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@@ -220,6 +220,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
|
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
|
||||||
|
<div>Multiple Kubernetes config file can be provided using separator ';' for Windows platform or ':' for others platforms.</div>
|
||||||
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.</div>
|
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -280,6 +281,25 @@ Parameters
|
|||||||
<div>Use to specify a Service object namespace.</div>
|
<div>Use to specify a Service object namespace.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>no_proxy</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">string</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>The comma separated list of hosts/domains/IP/CIDR that shouldn'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>=19.15.0. When kubernetes library is less than 19.15.0, it fails even no_proxy set in correct.</div>
|
||||||
|
<div>example value is "localhost,.local,.example.com,127.0.0.1,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -468,7 +488,8 @@ Parameters
|
|||||||
<td>
|
<td>
|
||||||
<div>Provide a path to a file containing a valid YAML definition of an object or objects to be created or updated. Mutually exclusive with <em>resource_definition</em>. NOTE: <em>kind</em>, <em>api_version</em>, <em>name</em>, and <em>namespace</em> will be overwritten by corresponding values found in the configuration read in from the <em>src</em> file.</div>
|
<div>Provide a path to a file containing a valid YAML definition of an object or objects to be created or updated. Mutually exclusive with <em>resource_definition</em>. NOTE: <em>kind</em>, <em>api_version</em>, <em>name</em>, and <em>namespace</em> will be overwritten by corresponding values found in the configuration read in from the <em>src</em> file.</div>
|
||||||
<div>Reads from the local file system. To read from the Ansible controller's file system, including vaulted files, use the file lookup plugin or template lookup plugin, combined with the from_yaml filter, and pass the result to <em>resource_definition</em>. See Examples below.</div>
|
<div>Reads from the local file system. To read from the Ansible controller's file system, including vaulted files, use the file lookup plugin or template lookup plugin, combined with the from_yaml filter, and pass the result to <em>resource_definition</em>. See Examples below.</div>
|
||||||
<div>Mutually exclusive with <em>template</em> in case of <span class='module'>k8s</span> module.</div>
|
<div>The URL to manifest files that can be used to create the resource. Added in version 2.4.0.</div>
|
||||||
|
<div>Mutually exclusive with <em>template</em> in case of <span class='module'>kubernetes.core.k8s</span> module.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ Requirements
|
|||||||
------------
|
------------
|
||||||
The below requirements are needed on the host that executes this module.
|
The below requirements are needed on the host that executes this module.
|
||||||
|
|
||||||
- python >= 3.6
|
- python >= 3.9
|
||||||
- kubernetes >= 12.0.0
|
- kubernetes >= 24.2.0
|
||||||
|
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@@ -182,6 +182,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
|
<div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
|
||||||
|
<div>Multiple Kubernetes config file can be provided using separator ';' for Windows platform or ':' for others platforms.</div>
|
||||||
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.</div>
|
<div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -208,6 +208,28 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>Path to a kubectl config file. Defaults to <em>~/.kube/config</em></div>
|
<div>Path to a kubectl config file. Defaults to <em>~/.kube/config</em></div>
|
||||||
|
<div>The configuration can be provided as dictionary. Added in version 2.4.0.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>kubectl_local_env_vars</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">dictionary</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 3.1.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<b>Default:</b><br/><div style="color: blue">{}</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>var: ansible_kubectl_local_env_vars</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Local enviromantal variable to be passed locally to the kubectl command line.</div>
|
||||||
|
<div>Please be aware that this passes information directly on the command line and it could expose sensitive data.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -343,6 +365,82 @@ Parameters
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Examples
|
||||||
|
--------
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
- name: Run a command in a pod using local kubectl with kubeconfig file ~/.kube/config
|
||||||
|
hosts: localhost
|
||||||
|
gather_facts: no
|
||||||
|
vars:
|
||||||
|
ansible_connection: kubernetes.core.kubectl
|
||||||
|
ansible_kubectl_namespace: my-namespace
|
||||||
|
ansible_kubectl_pod: my-pod
|
||||||
|
ansible_kubectl_container: my-container
|
||||||
|
tasks:
|
||||||
|
# be aware that the command is executed as the user that started the container
|
||||||
|
# and requires python to be installed in the image
|
||||||
|
- name: Run a command in a pod
|
||||||
|
ansible.builtin.command: echo "Hello, World!"
|
||||||
|
|
||||||
|
- name: Run a command in a pod using local kubectl with inventory variables
|
||||||
|
# Example inventory:
|
||||||
|
# k8s:
|
||||||
|
# hosts:
|
||||||
|
# foo.example.com:
|
||||||
|
# ansible_connection: kubernetes.core.kubectl
|
||||||
|
# ansible_kubectl_kubeconfig: /root/.kube/foo.example.com.config
|
||||||
|
# ansible_kubectl_pod: my-foo-pod
|
||||||
|
# ansible_kubectl_container: my-foo-container
|
||||||
|
# ansible_kubectl_namespace: my-foo-namespace
|
||||||
|
# bar.example.com:
|
||||||
|
# ansible_connection: kubernetes.core.kubectl
|
||||||
|
# ansible_kubectl_kubeconfig: /root/.kube/bar.example.com.config
|
||||||
|
# ansible_kubectl_pod: my-bar-pod
|
||||||
|
# ansible_kubectl_container: my-bar-container
|
||||||
|
# ansible_kubectl_namespace: my-bar-namespace
|
||||||
|
hosts: k8s
|
||||||
|
gather_facts: no
|
||||||
|
tasks:
|
||||||
|
# be aware that the command is executed as the user that started the container
|
||||||
|
# and requires python to be installed in the image
|
||||||
|
- name: Run a command in a pod
|
||||||
|
ansible.builtin.command: echo "Hello, World!"
|
||||||
|
|
||||||
|
- name: Run a command in a pod using dynamic inventory
|
||||||
|
hosts: localhost
|
||||||
|
gather_facts: no
|
||||||
|
vars:
|
||||||
|
kubeconfig: /root/.kube/config
|
||||||
|
namespace: my-namespace
|
||||||
|
my_app: my-app
|
||||||
|
tasks:
|
||||||
|
- name: Get My App pod info based on label
|
||||||
|
kubernetes.core.k8s_info:
|
||||||
|
kubeconfig: "{{ kubeconfig }}"
|
||||||
|
namespace: "{{ namespace }}"
|
||||||
|
kind: Pod
|
||||||
|
label_selectors: app.kubernetes.io/name = "{{ my_app }}"
|
||||||
|
register: my_app_pod
|
||||||
|
|
||||||
|
- name: Get My App pod name
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
my_app_pod_name: "{{ my_app_pod.resources[0].metadata.name }}"
|
||||||
|
|
||||||
|
- name: Add My App pod to inventory
|
||||||
|
ansible.builtin.add_host:
|
||||||
|
name: "{{ my_app_pod_name }}"
|
||||||
|
ansible_connection: kubernetes.core.kubectl
|
||||||
|
ansible_kubectl_kubeconfig: "{{ kubeconfig }}"
|
||||||
|
ansible_kubectl_pod: "{{ my_app_pod_name }}"
|
||||||
|
ansible_kubectl_namespace: "{{ namespace }}"
|
||||||
|
|
||||||
|
- name: Run a command in My App pod
|
||||||
|
# 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!"
|
||||||
|
delegate_to: "{{ my_app_pod_name }}"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -354,7 +452,7 @@ Status
|
|||||||
Authors
|
Authors
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
|
|
||||||
- xuxinkun
|
- xuxinkun (@xuxinkun)
|
||||||
|
|
||||||
|
|
||||||
.. hint::
|
.. hint::
|
||||||
|
|||||||
@@ -77,6 +77,24 @@ Parameters
|
|||||||
<div>If omitted, '.' is assumed.</div>
|
<div>If omitted, '.' is assumed.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>enable_helm</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">-</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<b>Default:</b><br/><div style="color: blue">"False"</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Enable the helm chart inflation generator</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="1">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -112,17 +130,21 @@ Examples
|
|||||||
.. code-block:: yaml
|
.. code-block:: yaml
|
||||||
|
|
||||||
- name: Run lookup using kustomize
|
- name: Run lookup using kustomize
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
resources: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kustomize') }}"
|
resources: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kustomize') }}"
|
||||||
|
|
||||||
- name: Run lookup using kubectl kustomize
|
- name: Run lookup using kubectl kustomize
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
resources: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kubectl') }}"
|
resources: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kubectl') }}"
|
||||||
|
|
||||||
- name: Create kubernetes resources for lookup output
|
- name: Create kubernetes resources for lookup output
|
||||||
k8s:
|
kubernetes.core.k8s:
|
||||||
definition: "{{ lookup('kubernetes.core.kustomize', dir='/path/to/kustomization') }}"
|
definition: "{{ lookup('kubernetes.core.kustomize', dir='/path/to/kustomization') }}"
|
||||||
|
|
||||||
|
- name: Create kubernetes resources for lookup output with `--enable-helm` set
|
||||||
|
kubernetes.core.k8s:
|
||||||
|
definition: "{{ lookup('kubernetes.core.kustomize', dir='/path/to/kustomization', enable_helm=True) }}"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Return Values
|
Return Values
|
||||||
@@ -133,106 +155,27 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
|
|||||||
|
|
||||||
<table border=0 cellpadding=0 class="documentation-table">
|
<table border=0 cellpadding=0 class="documentation-table">
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="2">Key</th>
|
<th colspan="1">Key</th>
|
||||||
<th>Returned</th>
|
<th>Returned</th>
|
||||||
<th width="100%">Description</th>
|
<th width="100%">Description</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="1">
|
||||||
<div class="ansibleOptionAnchor" id="return-"></div>
|
<div class="ansibleOptionAnchor" id="return-"></div>
|
||||||
<b>_list</b>
|
<b>_list</b>
|
||||||
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
||||||
<div style="font-size: small">
|
<div style="font-size: small">
|
||||||
<span style="color: purple">complex</span>
|
<span style="color: purple">string</span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>
|
<td>
|
||||||
<div>One ore more object definitions returned from the tool execution.</div>
|
<div>YAML string for the object definitions returned from the tool execution.</div>
|
||||||
<br/>
|
<br/>
|
||||||
|
<div style="font-size: smaller"><b>Sample:</b></div>
|
||||||
|
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">{'kind': 'ConfigMap', 'apiVersion': 'v1', 'metadata': {'name': 'my-config-map', 'namespace': 'default'}, 'data': {'key1': 'val1'}}</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td class="elbow-placeholder"> </td>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="return-"></div>
|
|
||||||
<b>api_version</b>
|
|
||||||
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
|
||||||
<div style="font-size: small">
|
|
||||||
<span style="color: purple">string</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>success</td>
|
|
||||||
<td>
|
|
||||||
<div>The versioned schema of this representation of an object.</div>
|
|
||||||
<br/>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="elbow-placeholder"> </td>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="return-"></div>
|
|
||||||
<b>kind</b>
|
|
||||||
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
|
||||||
<div style="font-size: small">
|
|
||||||
<span style="color: purple">string</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>success</td>
|
|
||||||
<td>
|
|
||||||
<div>Represents the REST resource this object represents.</div>
|
|
||||||
<br/>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="elbow-placeholder"> </td>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="return-"></div>
|
|
||||||
<b>metadata</b>
|
|
||||||
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
|
||||||
<div style="font-size: small">
|
|
||||||
<span style="color: purple">complex</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>success</td>
|
|
||||||
<td>
|
|
||||||
<div>Standard object metadata. Includes name, namespace, annotations, labels, etc.</div>
|
|
||||||
<br/>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="elbow-placeholder"> </td>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="return-"></div>
|
|
||||||
<b>spec</b>
|
|
||||||
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
|
||||||
<div style="font-size: small">
|
|
||||||
<span style="color: purple">complex</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>success</td>
|
|
||||||
<td>
|
|
||||||
<div>Specific attributes of the object. Will vary based on the <em>api_version</em> and <em>kind</em>.</div>
|
|
||||||
<br/>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="elbow-placeholder"> </td>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="return-"></div>
|
|
||||||
<b>status</b>
|
|
||||||
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
|
||||||
<div style="font-size: small">
|
|
||||||
<span style="color: purple">complex</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>success</td>
|
|
||||||
<td>
|
|
||||||
<div>Current status details for the object.</div>
|
|
||||||
<br/>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
|
|
||||||
@@ -244,7 +187,7 @@ Status
|
|||||||
Authors
|
Authors
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
|
|
||||||
- Aubin Bikouo <@abikouo>
|
- Aubin Bikouo (@abikouo)
|
||||||
|
|
||||||
|
|
||||||
.. hint::
|
.. hint::
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ tags:
|
|||||||
- openshift
|
- openshift
|
||||||
- okd
|
- okd
|
||||||
- cluster
|
- cluster
|
||||||
version: 2.4.1
|
version: 3.3.1
|
||||||
build_ignore:
|
build_ignore:
|
||||||
- .DS_Store
|
- .DS_Store
|
||||||
- "*.tar.gz"
|
- "*.tar.gz"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
requires_ansible: ">=2.9.17"
|
requires_ansible: '>=2.14.0'
|
||||||
|
|
||||||
action_groups:
|
action_groups:
|
||||||
helm:
|
helm:
|
||||||
@@ -20,6 +20,12 @@ plugin_routing:
|
|||||||
inventory:
|
inventory:
|
||||||
openshift:
|
openshift:
|
||||||
redirect: community.okd.openshift
|
redirect: community.okd.openshift
|
||||||
|
k8s:
|
||||||
|
deprecation:
|
||||||
|
removal_version: 6.0.0
|
||||||
|
warning_text: >-
|
||||||
|
The k8s inventory plugin has been deprecated and
|
||||||
|
will be removed in release 6.0.0.
|
||||||
modules:
|
modules:
|
||||||
k8s_auth:
|
k8s_auth:
|
||||||
redirect: community.okd.k8s_auth
|
redirect: community.okd.k8s_auth
|
||||||
@@ -29,18 +35,18 @@ plugin_routing:
|
|||||||
warning_text: Use kubernetes.core.k8s_info instead.
|
warning_text: Use kubernetes.core.k8s_info instead.
|
||||||
k8s_raw:
|
k8s_raw:
|
||||||
tombstone:
|
tombstone:
|
||||||
removal_version: "0.1.0"
|
removal_version: 0.1.0
|
||||||
warning_text: The k8s_raw module was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s instead.
|
warning_text: The k8s_raw module was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s instead.
|
||||||
openshift_raw:
|
openshift_raw:
|
||||||
tombstone:
|
tombstone:
|
||||||
removal_version: "0.1.0"
|
removal_version: 0.1.0
|
||||||
warning_text: The openshift_raw module was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s instead.
|
warning_text: The openshift_raw module was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s instead.
|
||||||
openshift_scale:
|
openshift_scale:
|
||||||
tombstone:
|
tombstone:
|
||||||
removal_version: "0.1.0"
|
removal_version: 0.1.0
|
||||||
warning_text: The openshift_scale module was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s_scale instead.
|
warning_text: The openshift_scale module was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s_scale instead.
|
||||||
lookup:
|
lookup:
|
||||||
openshift:
|
openshift:
|
||||||
tombstone:
|
tombstone:
|
||||||
removal_version: "0.1.0"
|
removal_version: 0.1.0
|
||||||
warning_text: The openshift lookup plugin was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s instead.
|
warning_text: The openshift lookup plugin was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s instead.
|
||||||
|
|||||||
@@ -8,54 +8,41 @@ from __future__ import absolute_import, division, print_function
|
|||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
import traceback
|
|
||||||
import os
|
import os
|
||||||
from contextlib import contextmanager
|
|
||||||
import platform
|
import platform
|
||||||
|
import traceback
|
||||||
|
from contextlib import contextmanager
|
||||||
|
|
||||||
from ansible.config.manager import ensure_type
|
from ansible.config.manager import ensure_type
|
||||||
from ansible.errors import (
|
from ansible.errors import (
|
||||||
AnsibleError,
|
|
||||||
AnsibleFileNotFound,
|
|
||||||
AnsibleAction,
|
AnsibleAction,
|
||||||
AnsibleActionFail,
|
AnsibleActionFail,
|
||||||
|
AnsibleError,
|
||||||
|
AnsibleFileNotFound,
|
||||||
)
|
)
|
||||||
|
from ansible.module_utils._text import to_bytes, to_native, to_text
|
||||||
from ansible.module_utils.parsing.convert_bool import boolean
|
from ansible.module_utils.parsing.convert_bool import boolean
|
||||||
from ansible.module_utils.six import string_types, iteritems
|
from ansible.module_utils.six import iteritems, string_types
|
||||||
from ansible.module_utils._text import to_text, to_bytes, to_native
|
|
||||||
from ansible.plugins.action import ActionBase
|
from ansible.plugins.action import ActionBase
|
||||||
|
|
||||||
|
try:
|
||||||
|
from ansible.template import trust_as_template
|
||||||
|
except ImportError:
|
||||||
|
trust_as_template = None
|
||||||
|
|
||||||
class RemoveOmit(object):
|
|
||||||
def __init__(self, buffer, omit_value):
|
|
||||||
try:
|
|
||||||
import yaml
|
|
||||||
except ImportError:
|
|
||||||
raise AnsibleError("Failed to import the required Python library (PyYAML).")
|
|
||||||
self.data = yaml.safe_load_all(buffer)
|
|
||||||
self.omit = omit_value
|
|
||||||
|
|
||||||
def remove_omit(self, data):
|
def _from_yaml_to_definition(buffer):
|
||||||
if isinstance(data, dict):
|
try:
|
||||||
result = dict()
|
import yaml
|
||||||
for key, value in iteritems(data):
|
except ImportError:
|
||||||
if value == self.omit:
|
raise AnsibleError("Failed to import the required Python library (PyYAML).")
|
||||||
continue
|
return list(yaml.safe_load_all(buffer))
|
||||||
result[key] = self.remove_omit(value)
|
|
||||||
return result
|
|
||||||
if isinstance(data, list):
|
|
||||||
return [self.remove_omit(v) for v in data if v != self.omit]
|
|
||||||
return data
|
|
||||||
|
|
||||||
def output(self):
|
|
||||||
return [self.remove_omit(d) for d in self.data]
|
|
||||||
|
|
||||||
|
|
||||||
ENV_KUBECONFIG_PATH_SEPARATOR = ";" if platform.system() == "Windows" else ":"
|
ENV_KUBECONFIG_PATH_SEPARATOR = ";" if platform.system() == "Windows" else ":"
|
||||||
|
|
||||||
|
|
||||||
class ActionModule(ActionBase):
|
class ActionModule(ActionBase):
|
||||||
|
|
||||||
TRANSFERS_FILES = True
|
TRANSFERS_FILES = True
|
||||||
DEFAULT_NEWLINE_SEQUENCE = "\n"
|
DEFAULT_NEWLINE_SEQUENCE = "\n"
|
||||||
|
|
||||||
@@ -208,7 +195,6 @@ class ActionModule(ActionBase):
|
|||||||
"'template' is only a supported parameter for the 'k8s' module."
|
"'template' is only a supported parameter for the 'k8s' module."
|
||||||
)
|
)
|
||||||
|
|
||||||
omit_value = task_vars.get("omit")
|
|
||||||
template_params = []
|
template_params = []
|
||||||
if isinstance(template, string_types) or isinstance(template, dict):
|
if isinstance(template, string_types) or isinstance(template, dict):
|
||||||
template_params.append(self.get_template_args(template))
|
template_params.append(self.get_template_args(template))
|
||||||
@@ -231,17 +217,18 @@ class ActionModule(ActionBase):
|
|||||||
old_vars = self._templar.available_variables
|
old_vars = self._templar.available_variables
|
||||||
|
|
||||||
default_environment = {}
|
default_environment = {}
|
||||||
for key in (
|
if trust_as_template is None:
|
||||||
"newline_sequence",
|
for key in (
|
||||||
"variable_start_string",
|
"newline_sequence",
|
||||||
"variable_end_string",
|
"variable_start_string",
|
||||||
"block_start_string",
|
"variable_end_string",
|
||||||
"block_end_string",
|
"block_start_string",
|
||||||
"trim_blocks",
|
"block_end_string",
|
||||||
"lstrip_blocks",
|
"trim_blocks",
|
||||||
):
|
"lstrip_blocks",
|
||||||
if hasattr(self._templar.environment, key):
|
):
|
||||||
default_environment[key] = getattr(self._templar.environment, key)
|
if hasattr(self._templar.environment, key):
|
||||||
|
default_environment[key] = getattr(self._templar.environment, key)
|
||||||
for template_item in template_params:
|
for template_item in template_params:
|
||||||
# We need to convert unescaped sequences to proper escaped sequences for Jinja2
|
# We need to convert unescaped sequences to proper escaped sequences for Jinja2
|
||||||
newline_sequence = template_item["newline_sequence"]
|
newline_sequence = template_item["newline_sequence"]
|
||||||
@@ -258,26 +245,35 @@ class ActionModule(ActionBase):
|
|||||||
with self.get_template_data(template_item["path"]) as template_data:
|
with self.get_template_data(template_item["path"]) as template_data:
|
||||||
# add ansible 'template' vars
|
# add ansible 'template' vars
|
||||||
temp_vars = copy.deepcopy(task_vars)
|
temp_vars = copy.deepcopy(task_vars)
|
||||||
|
overrides = {}
|
||||||
for key, value in iteritems(template_item):
|
for key, value in iteritems(template_item):
|
||||||
if hasattr(self._templar.environment, key):
|
if hasattr(self._templar.environment, key):
|
||||||
if value is not None:
|
if value is not None:
|
||||||
setattr(self._templar.environment, key, value)
|
overrides[key] = value
|
||||||
else:
|
if trust_as_template is None:
|
||||||
|
setattr(self._templar.environment, key, value)
|
||||||
|
elif trust_as_template is None:
|
||||||
setattr(
|
setattr(
|
||||||
self._templar.environment,
|
self._templar.environment,
|
||||||
key,
|
key,
|
||||||
default_environment.get(key),
|
default_environment.get(key),
|
||||||
)
|
)
|
||||||
self._templar.available_variables = temp_vars
|
self._templar.available_variables = temp_vars
|
||||||
result = self._templar.do_template(
|
if trust_as_template:
|
||||||
template_data,
|
template_data = trust_as_template(template_data)
|
||||||
preserve_trailing_newlines=True,
|
result = self._templar.template(
|
||||||
escape_backslashes=False,
|
template_data,
|
||||||
)
|
preserve_trailing_newlines=True,
|
||||||
if omit_value is not None:
|
escape_backslashes=False,
|
||||||
result_template.extend(RemoveOmit(result, omit_value).output())
|
overrides=overrides,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
result_template.append(result)
|
result = self._templar.do_template(
|
||||||
|
template_data,
|
||||||
|
preserve_trailing_newlines=True,
|
||||||
|
escape_backslashes=False,
|
||||||
|
)
|
||||||
|
result_template.extend(_from_yaml_to_definition(result))
|
||||||
self._templar.available_variables = old_vars
|
self._templar.available_variables = old_vars
|
||||||
resource_definition = self._task.args.get("definition", None)
|
resource_definition = self._task.args.get("definition", None)
|
||||||
if not resource_definition:
|
if not resource_definition:
|
||||||
|
|||||||
@@ -72,6 +72,15 @@ DOCUMENTATION = r"""
|
|||||||
- name: ansible_kubectl_extra_args
|
- name: ansible_kubectl_extra_args
|
||||||
env:
|
env:
|
||||||
- name: K8S_AUTH_EXTRA_ARGS
|
- name: K8S_AUTH_EXTRA_ARGS
|
||||||
|
kubectl_local_env_vars:
|
||||||
|
description:
|
||||||
|
- Local enviromantal variable to be passed locally to the kubectl command line.
|
||||||
|
- Please be aware that this passes information directly on the command line and it could expose sensitive data.
|
||||||
|
default: {}
|
||||||
|
type: dict
|
||||||
|
version_added: 3.1.0
|
||||||
|
vars:
|
||||||
|
- name: ansible_kubectl_local_env_vars
|
||||||
kubectl_kubeconfig:
|
kubectl_kubeconfig:
|
||||||
description:
|
description:
|
||||||
- Path to a kubectl config file. Defaults to I(~/.kube/config)
|
- Path to a kubectl config file. Defaults to I(~/.kube/config)
|
||||||
@@ -172,18 +181,93 @@ DOCUMENTATION = r"""
|
|||||||
aliases: [ kubectl_verify_ssl ]
|
aliases: [ kubectl_verify_ssl ]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
EXAMPLES = r"""
|
||||||
|
|
||||||
|
- name: Run a command in a pod using local kubectl with kubeconfig file ~/.kube/config
|
||||||
|
hosts: localhost
|
||||||
|
gather_facts: no
|
||||||
|
vars:
|
||||||
|
ansible_connection: kubernetes.core.kubectl
|
||||||
|
ansible_kubectl_namespace: my-namespace
|
||||||
|
ansible_kubectl_pod: my-pod
|
||||||
|
ansible_kubectl_container: my-container
|
||||||
|
tasks:
|
||||||
|
# be aware that the command is executed as the user that started the container
|
||||||
|
# and requires python to be installed in the image
|
||||||
|
- name: Run a command in a pod
|
||||||
|
ansible.builtin.command: echo "Hello, World!"
|
||||||
|
|
||||||
|
- name: Run a command in a pod using local kubectl with inventory variables
|
||||||
|
# Example inventory:
|
||||||
|
# k8s:
|
||||||
|
# hosts:
|
||||||
|
# foo.example.com:
|
||||||
|
# ansible_connection: kubernetes.core.kubectl
|
||||||
|
# ansible_kubectl_kubeconfig: /root/.kube/foo.example.com.config
|
||||||
|
# ansible_kubectl_pod: my-foo-pod
|
||||||
|
# ansible_kubectl_container: my-foo-container
|
||||||
|
# ansible_kubectl_namespace: my-foo-namespace
|
||||||
|
# bar.example.com:
|
||||||
|
# ansible_connection: kubernetes.core.kubectl
|
||||||
|
# ansible_kubectl_kubeconfig: /root/.kube/bar.example.com.config
|
||||||
|
# ansible_kubectl_pod: my-bar-pod
|
||||||
|
# ansible_kubectl_container: my-bar-container
|
||||||
|
# ansible_kubectl_namespace: my-bar-namespace
|
||||||
|
hosts: k8s
|
||||||
|
gather_facts: no
|
||||||
|
tasks:
|
||||||
|
# be aware that the command is executed as the user that started the container
|
||||||
|
# and requires python to be installed in the image
|
||||||
|
- name: Run a command in a pod
|
||||||
|
ansible.builtin.command: echo "Hello, World!"
|
||||||
|
|
||||||
|
- name: Run a command in a pod using dynamic inventory
|
||||||
|
hosts: localhost
|
||||||
|
gather_facts: no
|
||||||
|
vars:
|
||||||
|
kubeconfig: /root/.kube/config
|
||||||
|
namespace: my-namespace
|
||||||
|
my_app: my-app
|
||||||
|
tasks:
|
||||||
|
- name: Get My App pod info based on label
|
||||||
|
kubernetes.core.k8s_info:
|
||||||
|
kubeconfig: "{{ kubeconfig }}"
|
||||||
|
namespace: "{{ namespace }}"
|
||||||
|
kind: Pod
|
||||||
|
label_selectors: app.kubernetes.io/name = "{{ my_app }}"
|
||||||
|
register: my_app_pod
|
||||||
|
|
||||||
|
- name: Get My App pod name
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
my_app_pod_name: "{{ my_app_pod.resources[0].metadata.name }}"
|
||||||
|
|
||||||
|
- name: Add My App pod to inventory
|
||||||
|
ansible.builtin.add_host:
|
||||||
|
name: "{{ my_app_pod_name }}"
|
||||||
|
ansible_connection: kubernetes.core.kubectl
|
||||||
|
ansible_kubectl_kubeconfig: "{{ kubeconfig }}"
|
||||||
|
ansible_kubectl_pod: "{{ my_app_pod_name }}"
|
||||||
|
ansible_kubectl_namespace: "{{ namespace }}"
|
||||||
|
|
||||||
|
- name: Run a command in My App pod
|
||||||
|
# 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!"
|
||||||
|
delegate_to: "{{ my_app_pod_name }}"
|
||||||
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
import json
|
|
||||||
|
|
||||||
from ansible.parsing.yaml.loader import AnsibleLoader
|
|
||||||
from ansible.errors import AnsibleError, AnsibleFileNotFound
|
from ansible.errors import AnsibleError, AnsibleFileNotFound
|
||||||
from ansible.module_utils.six.moves import shlex_quote
|
|
||||||
from ansible.module_utils._text import to_bytes
|
from ansible.module_utils._text import to_bytes
|
||||||
from ansible.plugins.connection import ConnectionBase, BUFSIZE
|
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
|
from ansible.utils.display import Display
|
||||||
|
|
||||||
display = Display()
|
display = Display()
|
||||||
@@ -301,6 +385,19 @@ class Connection(ConnectionBase):
|
|||||||
|
|
||||||
return local_cmd, censored_local_cmd
|
return local_cmd, censored_local_cmd
|
||||||
|
|
||||||
|
def _local_env(self):
|
||||||
|
"""Return a dict of local environment variables to pass to the kubectl command"""
|
||||||
|
local_env = {}
|
||||||
|
local_local_env_vars_name = "{0}_local_env_vars".format(self.transport)
|
||||||
|
local_env_vars = self.get_option(local_local_env_vars_name)
|
||||||
|
if local_env_vars:
|
||||||
|
if isinstance(local_env_vars, dict):
|
||||||
|
local_env_vars = json.dumps(local_env_vars)
|
||||||
|
local_env = os.environ.copy()
|
||||||
|
local_env.update(json.loads(local_env_vars))
|
||||||
|
return local_env
|
||||||
|
return None
|
||||||
|
|
||||||
def _connect(self, port=None):
|
def _connect(self, port=None):
|
||||||
"""Connect to the container. Nothing to do"""
|
"""Connect to the container. Nothing to do"""
|
||||||
super(Connection, self)._connect()
|
super(Connection, self)._connect()
|
||||||
@@ -329,6 +426,7 @@ class Connection(ConnectionBase):
|
|||||||
stdin=subprocess.PIPE,
|
stdin=subprocess.PIPE,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
|
env=self._local_env(),
|
||||||
)
|
)
|
||||||
|
|
||||||
stdout, stderr = p.communicate(in_data)
|
stdout, stderr = p.communicate(in_data)
|
||||||
@@ -378,7 +476,11 @@ class Connection(ConnectionBase):
|
|||||||
args = [to_bytes(i, errors="surrogate_or_strict") for i in args]
|
args = [to_bytes(i, errors="surrogate_or_strict") for i in args]
|
||||||
try:
|
try:
|
||||||
p = subprocess.Popen(
|
p = subprocess.Popen(
|
||||||
args, stdin=in_file, stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
args,
|
||||||
|
stdin=in_file,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE,
|
||||||
|
env=self._local_env(),
|
||||||
)
|
)
|
||||||
except OSError:
|
except OSError:
|
||||||
raise AnsibleError(
|
raise AnsibleError(
|
||||||
@@ -415,7 +517,11 @@ class Connection(ConnectionBase):
|
|||||||
) as out_file:
|
) as out_file:
|
||||||
try:
|
try:
|
||||||
p = subprocess.Popen(
|
p = subprocess.Popen(
|
||||||
args, stdin=subprocess.PIPE, stdout=out_file, stderr=subprocess.PIPE
|
args,
|
||||||
|
stdin=subprocess.PIPE,
|
||||||
|
stdout=out_file,
|
||||||
|
stderr=subprocess.PIPE,
|
||||||
|
env=self._local_env(),
|
||||||
)
|
)
|
||||||
except OSError:
|
except OSError:
|
||||||
raise AnsibleError(
|
raise AnsibleError(
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ __metaclass__ = type
|
|||||||
|
|
||||||
|
|
||||||
class ModuleDocFragment(object):
|
class ModuleDocFragment(object):
|
||||||
|
|
||||||
DOCUMENTATION = r"""
|
DOCUMENTATION = r"""
|
||||||
options:
|
options:
|
||||||
binary_path:
|
binary_path:
|
||||||
@@ -37,12 +36,12 @@ options:
|
|||||||
description:
|
description:
|
||||||
- Provide a URL for accessing the API. Can also be specified via C(K8S_AUTH_HOST) environment variable.
|
- Provide a URL for accessing the API. Can also be specified via C(K8S_AUTH_HOST) environment variable.
|
||||||
type: str
|
type: str
|
||||||
version_added: "1.2.0"
|
version_added: 1.2.0
|
||||||
api_key:
|
api_key:
|
||||||
description:
|
description:
|
||||||
- Token used to authenticate with the API. Can also be specified via C(K8S_AUTH_API_KEY) environment variable.
|
- Token used to authenticate with the API. Can also be specified via C(K8S_AUTH_API_KEY) environment variable.
|
||||||
type: str
|
type: str
|
||||||
version_added: "1.2.0"
|
version_added: 1.2.0
|
||||||
validate_certs:
|
validate_certs:
|
||||||
description:
|
description:
|
||||||
- Whether or not to verify the API server's SSL certificates. Can also be specified via C(K8S_AUTH_VERIFY_SSL)
|
- Whether or not to verify the API server's SSL certificates. Can also be specified via C(K8S_AUTH_VERIFY_SSL)
|
||||||
@@ -50,12 +49,12 @@ options:
|
|||||||
type: bool
|
type: bool
|
||||||
aliases: [ verify_ssl ]
|
aliases: [ verify_ssl ]
|
||||||
default: True
|
default: True
|
||||||
version_added: "1.2.0"
|
version_added: 1.2.0
|
||||||
ca_cert:
|
ca_cert:
|
||||||
description:
|
description:
|
||||||
- Path to a CA certificate used to authenticate with the API. The full certificate chain must be provided to
|
- Path to a CA certificate used to authenticate with the API. The full certificate chain must be provided to
|
||||||
avoid certificate validation errors. Can also be specified via C(K8S_AUTH_SSL_CA_CERT) environment variable.
|
avoid certificate validation errors. Can also be specified via C(K8S_AUTH_SSL_CA_CERT) environment variable.
|
||||||
type: path
|
type: path
|
||||||
aliases: [ ssl_ca_cert ]
|
aliases: [ ssl_ca_cert ]
|
||||||
version_added: "1.2.0"
|
version_added: 1.2.0
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ __metaclass__ = type
|
|||||||
|
|
||||||
|
|
||||||
class ModuleDocFragment(object):
|
class ModuleDocFragment(object):
|
||||||
|
|
||||||
DOCUMENTATION = r"""
|
DOCUMENTATION = r"""
|
||||||
options:
|
options:
|
||||||
host:
|
host:
|
||||||
|
|||||||
@@ -11,12 +11,11 @@ __metaclass__ = type
|
|||||||
|
|
||||||
|
|
||||||
class ModuleDocFragment(object):
|
class ModuleDocFragment(object):
|
||||||
|
|
||||||
DOCUMENTATION = r"""
|
DOCUMENTATION = r"""
|
||||||
options:
|
options:
|
||||||
delete_options:
|
delete_options:
|
||||||
type: dict
|
type: dict
|
||||||
version_added: '1.2.0'
|
version_added: 1.2.0
|
||||||
description:
|
description:
|
||||||
- Configure behavior when deleting an object.
|
- Configure behavior when deleting an object.
|
||||||
- Only used when I(state=absent).
|
- Only used when I(state=absent).
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ __metaclass__ = type
|
|||||||
|
|
||||||
|
|
||||||
class ModuleDocFragment(object):
|
class ModuleDocFragment(object):
|
||||||
|
|
||||||
DOCUMENTATION = r"""
|
DOCUMENTATION = r"""
|
||||||
options:
|
options:
|
||||||
api_version:
|
api_version:
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ __metaclass__ = type
|
|||||||
|
|
||||||
|
|
||||||
class ModuleDocFragment(object):
|
class ModuleDocFragment(object):
|
||||||
|
|
||||||
DOCUMENTATION = r"""
|
DOCUMENTATION = r"""
|
||||||
options:
|
options:
|
||||||
resource_definition:
|
resource_definition:
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ __metaclass__ = type
|
|||||||
|
|
||||||
|
|
||||||
class ModuleDocFragment(object):
|
class ModuleDocFragment(object):
|
||||||
|
|
||||||
DOCUMENTATION = r"""
|
DOCUMENTATION = r"""
|
||||||
options:
|
options:
|
||||||
replicas:
|
replicas:
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ __metaclass__ = type
|
|||||||
|
|
||||||
|
|
||||||
class ModuleDocFragment(object):
|
class ModuleDocFragment(object):
|
||||||
|
|
||||||
DOCUMENTATION = r"""
|
DOCUMENTATION = r"""
|
||||||
options:
|
options:
|
||||||
state:
|
state:
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ __metaclass__ = type
|
|||||||
|
|
||||||
|
|
||||||
class ModuleDocFragment(object):
|
class ModuleDocFragment(object):
|
||||||
|
|
||||||
DOCUMENTATION = r"""
|
DOCUMENTATION = r"""
|
||||||
options:
|
options:
|
||||||
wait:
|
wait:
|
||||||
|
|||||||
@@ -1,50 +1,12 @@
|
|||||||
# Copyright (c) 2017 Ansible Project
|
# Copyright (c) 2017 Ansible Project
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = r"""
|
|
||||||
|
|
||||||
name: k8s_config_resource_name
|
|
||||||
short_description: Generate resource name for the given resource of type ConfigMap, Secret
|
|
||||||
description:
|
|
||||||
- Generate resource name for the given resource of type ConfigMap, Secret.
|
|
||||||
- Resource must have a C(metadata.name) key to generate a resource name
|
|
||||||
options:
|
|
||||||
_input:
|
|
||||||
description:
|
|
||||||
- A valid YAML definition for a ConfigMap or a Secret.
|
|
||||||
type: dict
|
|
||||||
required: true
|
|
||||||
author:
|
|
||||||
- ansible cloud team
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
EXAMPLES = r"""
|
|
||||||
# Dump generated name for a configmap into a variable
|
|
||||||
- set_fact:
|
|
||||||
generated_name: '{{ definition | kubernetes.core.k8s_config_resource_name }}'
|
|
||||||
vars:
|
|
||||||
definition:
|
|
||||||
apiVersion: v1
|
|
||||||
kind: ConfigMap
|
|
||||||
metadata:
|
|
||||||
name: myconfigmap
|
|
||||||
namespace: mynamespace
|
|
||||||
"""
|
|
||||||
|
|
||||||
RETURN = r"""
|
|
||||||
_value:
|
|
||||||
description: Generated resource name.
|
|
||||||
type: str
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
from ansible.errors import AnsibleFilterError
|
from ansible.errors import AnsibleFilterError
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.hashes import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.hashes import (
|
||||||
generate_hash,
|
generate_hash,
|
||||||
|
|||||||
@@ -19,6 +19,13 @@ DOCUMENTATION = """
|
|||||||
- Uses the kubectl connection plugin to access the Kubernetes cluster.
|
- Uses the kubectl connection plugin to access the Kubernetes cluster.
|
||||||
- Uses k8s.(yml|yaml) YAML configuration file to set parameter values.
|
- Uses k8s.(yml|yaml) YAML configuration file to set parameter values.
|
||||||
|
|
||||||
|
deprecated:
|
||||||
|
removed_in: 6.0.0
|
||||||
|
why: |
|
||||||
|
As discussed in U(https://github.com/ansible-collections/kubernetes.core/issues/31), we decided to
|
||||||
|
remove the k8s inventory plugin in release 6.0.0.
|
||||||
|
alternative: "Use M(kubernetes.core.k8s_info) and M(ansible.builtin.add_host) instead."
|
||||||
|
|
||||||
options:
|
options:
|
||||||
plugin:
|
plugin:
|
||||||
description: token that ensures this is a source file for the 'k8s' plugin.
|
description: token that ensures this is a source file for the 'k8s' plugin.
|
||||||
@@ -27,7 +34,7 @@ DOCUMENTATION = """
|
|||||||
connections:
|
connections:
|
||||||
description:
|
description:
|
||||||
- Optional list of cluster connection settings. If no connections are provided, the default
|
- Optional list of cluster connection settings. If no connections are provided, the default
|
||||||
'~/.kube/config' and active context will be used, and objects will be returned for all namespaces
|
I(~/.kube/config) and active context will be used, and objects will be returned for all namespaces
|
||||||
the active user is authorized to access.
|
the active user is authorized to access.
|
||||||
suboptions:
|
suboptions:
|
||||||
name:
|
name:
|
||||||
@@ -38,7 +45,7 @@ DOCUMENTATION = """
|
|||||||
description:
|
description:
|
||||||
- Path to an existing Kubernetes config file. If not provided, and no other connection
|
- Path to an existing Kubernetes config file. If not provided, and no other connection
|
||||||
options are provided, the Kubernetes client will attempt to load the default
|
options are provided, the Kubernetes client will attempt to load the default
|
||||||
configuration file from '~/.kube/config'. Can also be specified via K8S_AUTH_KUBECONFIG
|
configuration file from I(~/.kube/config). Can also be specified via K8S_AUTH_KUBECONFIG
|
||||||
environment variable.
|
environment variable.
|
||||||
context:
|
context:
|
||||||
description:
|
description:
|
||||||
@@ -86,12 +93,12 @@ DOCUMENTATION = """
|
|||||||
to access.
|
to access.
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "python >= 3.6"
|
- "python >= 3.9"
|
||||||
- "kubernetes >= 12.0.0"
|
- "kubernetes >= 24.2.0"
|
||||||
- "PyYAML >= 3.11"
|
- "PyYAML >= 3.11"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = r"""
|
||||||
# File must be named k8s.yaml or k8s.yml
|
# File must be named k8s.yaml or k8s.yml
|
||||||
|
|
||||||
- name: Authenticate with token, and return all pods and services for all namespaces
|
- name: Authenticate with token, and return all pods and services for all namespaces
|
||||||
@@ -117,6 +124,7 @@ EXAMPLES = """
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
from ansible.errors import AnsibleError
|
from ansible.errors import AnsibleError
|
||||||
|
from ansible.plugins.inventory import BaseInventoryPlugin, Cacheable, Constructable
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.common import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.common import (
|
||||||
HAS_K8S_MODULE_HELPER,
|
HAS_K8S_MODULE_HELPER,
|
||||||
k8s_import_exception,
|
k8s_import_exception,
|
||||||
@@ -124,7 +132,6 @@ from ansible_collections.kubernetes.core.plugins.module_utils.common import (
|
|||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
|
||||||
get_api_client,
|
get_api_client,
|
||||||
)
|
)
|
||||||
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from kubernetes.dynamic.exceptions import DynamicApiError
|
from kubernetes.dynamic.exceptions import DynamicApiError
|
||||||
@@ -155,6 +162,12 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
|||||||
|
|
||||||
def parse(self, inventory, loader, path, cache=True):
|
def parse(self, inventory, loader, path, cache=True):
|
||||||
super(InventoryModule, self).parse(inventory, loader, path)
|
super(InventoryModule, self).parse(inventory, loader, path)
|
||||||
|
|
||||||
|
self.display.deprecated(
|
||||||
|
"The 'k8s' inventory plugin has been deprecated and will be removed in release 6.0.0",
|
||||||
|
version="6.0.0",
|
||||||
|
collection_name="kubernetes.core",
|
||||||
|
)
|
||||||
cache_key = self._get_cache_prefix(path)
|
cache_key = self._get_cache_prefix(path)
|
||||||
config_data = self._read_config_data(path)
|
config_data = self._read_config_data(path)
|
||||||
self.setup(config_data, cache, cache_key)
|
self.setup(config_data, cache, cache_key)
|
||||||
@@ -180,7 +193,6 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
|||||||
self.fetch_objects(connections)
|
self.fetch_objects(connections)
|
||||||
|
|
||||||
def fetch_objects(self, connections):
|
def fetch_objects(self, connections):
|
||||||
|
|
||||||
if connections:
|
if connections:
|
||||||
if not isinstance(connections, list):
|
if not isinstance(connections, list):
|
||||||
raise K8sInventoryException("Expecting connections to be a list.")
|
raise K8sInventoryException("Expecting connections to be a list.")
|
||||||
|
|||||||
@@ -114,8 +114,8 @@ DOCUMENTATION = """
|
|||||||
aliases: [ verify_ssl ]
|
aliases: [ verify_ssl ]
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "python >= 3.6"
|
- "python >= 3.9"
|
||||||
- "kubernetes >= 12.0.0"
|
- "kubernetes >= 24.2.0"
|
||||||
- "PyYAML >= 3.11"
|
- "PyYAML >= 3.11"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -179,7 +179,6 @@ import os
|
|||||||
from ansible.errors import AnsibleError
|
from ansible.errors import AnsibleError
|
||||||
from ansible.module_utils.common._collections_compat import KeysView
|
from ansible.module_utils.common._collections_compat import KeysView
|
||||||
from ansible.module_utils.common.validation import check_type_bool
|
from ansible.module_utils.common.validation import check_type_bool
|
||||||
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
|
||||||
get_api_client,
|
get_api_client,
|
||||||
)
|
)
|
||||||
@@ -214,7 +213,6 @@ except ImportError as e:
|
|||||||
|
|
||||||
class KubernetesLookup(object):
|
class KubernetesLookup(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
if not HAS_K8S_MODULE_HELPER:
|
if not HAS_K8S_MODULE_HELPER:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
"Requires the Kubernetes Python client. Try `pip install kubernetes`. Detail: {0}".format(
|
"Requires the Kubernetes Python client. Try `pip install kubernetes`. Detail: {0}".format(
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ DOCUMENTATION = """
|
|||||||
|
|
||||||
short_description: Build a set of kubernetes resources using a 'kustomization.yaml' file.
|
short_description: Build a set of kubernetes resources using a 'kustomization.yaml' file.
|
||||||
|
|
||||||
version_added: "2.2.0"
|
version_added: 2.2.0
|
||||||
|
|
||||||
author:
|
author:
|
||||||
- Aubin Bikouo (@abikouo)
|
- Aubin Bikouo (@abikouo)
|
||||||
@@ -30,6 +30,10 @@ DOCUMENTATION = """
|
|||||||
opt_dirs:
|
opt_dirs:
|
||||||
description:
|
description:
|
||||||
- An optional list of directories to search for the executable in addition to PATH.
|
- An optional list of directories to search for the executable in addition to PATH.
|
||||||
|
enable_helm:
|
||||||
|
description:
|
||||||
|
- Enable the helm chart inflation generator
|
||||||
|
default: "False"
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "python >= 3.6"
|
- "python >= 3.6"
|
||||||
@@ -37,16 +41,20 @@ DOCUMENTATION = """
|
|||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
- name: Run lookup using kustomize
|
- name: Run lookup using kustomize
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
resources: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kustomize') }}"
|
resources: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kustomize') }}"
|
||||||
|
|
||||||
- name: Run lookup using kubectl kustomize
|
- name: Run lookup using kubectl kustomize
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
resources: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kubectl') }}"
|
resources: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kubectl') }}"
|
||||||
|
|
||||||
- name: Create kubernetes resources for lookup output
|
- name: Create kubernetes resources for lookup output
|
||||||
k8s:
|
kubernetes.core.k8s:
|
||||||
definition: "{{ lookup('kubernetes.core.kustomize', dir='/path/to/kustomization') }}"
|
definition: "{{ lookup('kubernetes.core.kustomize', dir='/path/to/kustomization') }}"
|
||||||
|
|
||||||
|
- name: Create kubernetes resources for lookup output with `--enable-helm` set
|
||||||
|
kubernetes.core.k8s:
|
||||||
|
definition: "{{ lookup('kubernetes.core.kustomize', dir='/path/to/kustomization', enable_helm=True) }}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
@@ -64,13 +72,12 @@ RETURN = """
|
|||||||
key1: val1
|
key1: val1
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ansible.errors import AnsibleLookupError
|
|
||||||
from ansible.plugins.lookup import LookupBase
|
|
||||||
from ansible.module_utils.common.process import get_bin_path
|
|
||||||
|
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
from ansible.errors import AnsibleLookupError
|
||||||
|
from ansible.module_utils.common.process import get_bin_path
|
||||||
|
from ansible.plugins.lookup import LookupBase
|
||||||
|
|
||||||
|
|
||||||
def get_binary_from_path(name, opt_dirs=None):
|
def get_binary_from_path(name, opt_dirs=None):
|
||||||
opt_arg = {}
|
opt_arg = {}
|
||||||
@@ -87,12 +94,20 @@ def get_binary_from_path(name, opt_dirs=None):
|
|||||||
|
|
||||||
def run_command(command):
|
def run_command(command):
|
||||||
cmd = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
cmd = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
return cmd.communicate()
|
stdout, stderr = cmd.communicate()
|
||||||
|
return cmd.returncode, stdout, stderr
|
||||||
|
|
||||||
|
|
||||||
class LookupModule(LookupBase):
|
class LookupModule(LookupBase):
|
||||||
def run(
|
def run(
|
||||||
self, terms, variables=None, dir=".", binary_path=None, opt_dirs=None, **kwargs
|
self,
|
||||||
|
terms,
|
||||||
|
variables=None,
|
||||||
|
dir=".",
|
||||||
|
binary_path=None,
|
||||||
|
opt_dirs=None,
|
||||||
|
enable_helm=False,
|
||||||
|
**kwargs
|
||||||
):
|
):
|
||||||
executable_path = binary_path
|
executable_path = binary_path
|
||||||
if executable_path is None:
|
if executable_path is None:
|
||||||
@@ -123,9 +138,21 @@ class LookupModule(LookupBase):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
(out, err) = run_command(command)
|
if enable_helm:
|
||||||
if err:
|
command += ["--enable-helm"]
|
||||||
raise AnsibleLookupError(
|
|
||||||
"kustomize command failed with: {0}".format(err.decode("utf-8"))
|
(ret, out, err) = run_command(command)
|
||||||
)
|
if ret != 0:
|
||||||
|
if err:
|
||||||
|
raise AnsibleLookupError(
|
||||||
|
"kustomize command failed. exit code: {0}, error: {1}".format(
|
||||||
|
ret, err.decode("utf-8")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
raise AnsibleLookupError(
|
||||||
|
"kustomize command failed with unknown error. exit code: {0}".format(
|
||||||
|
ret
|
||||||
|
)
|
||||||
|
)
|
||||||
return [out.decode("utf-8")]
|
return [out.decode("utf-8")]
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ except TypeError:
|
|||||||
|
|
||||||
if enable_turbo_mode:
|
if enable_turbo_mode:
|
||||||
try:
|
try:
|
||||||
from ansible_collections.cloud.common.plugins.module_utils.turbo.module import (
|
from ansible_collections.cloud.common.plugins.module_utils.turbo.module import ( # noqa: F401
|
||||||
AnsibleTurboModule as AnsibleModule,
|
AnsibleTurboModule as AnsibleModule,
|
||||||
) # noqa: F401
|
)
|
||||||
|
|
||||||
AnsibleModule.collection_name = "kubernetes.core"
|
AnsibleModule.collection_name = "kubernetes.core"
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ from __future__ import absolute_import, division, print_function
|
|||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
from collections import OrderedDict
|
|
||||||
import json
|
import json
|
||||||
|
from collections import OrderedDict
|
||||||
|
|
||||||
from ansible.module_utils.common.dict_transformations import dict_merge
|
from ansible.module_utils.common.dict_transformations import dict_merge
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.exceptions import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.exceptions import (
|
||||||
@@ -31,7 +31,6 @@ from ansible_collections.kubernetes.core.plugins.module_utils.version import (
|
|||||||
LooseVersion,
|
LooseVersion,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from kubernetes.dynamic.exceptions import NotFoundError
|
from kubernetes.dynamic.exceptions import NotFoundError
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ AUTH_PROXY_HEADERS_SPEC = dict(
|
|||||||
)
|
)
|
||||||
|
|
||||||
AUTH_ARG_SPEC = {
|
AUTH_ARG_SPEC = {
|
||||||
"kubeconfig": {"type": "raw"},
|
"kubeconfig": {"type": "raw", "no_log": True},
|
||||||
"context": {},
|
"context": {},
|
||||||
"host": {},
|
"host": {},
|
||||||
"api_key": {"no_log": True},
|
"api_key": {"no_log": True},
|
||||||
|
|||||||
@@ -13,15 +13,18 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
|
import hashlib
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from collections import defaultdict
|
|
||||||
import hashlib
|
|
||||||
import tempfile
|
import tempfile
|
||||||
|
from collections import defaultdict
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
import kubernetes.dynamic
|
import kubernetes.dynamic
|
||||||
import kubernetes.dynamic.discovery
|
import kubernetes.dynamic.discovery
|
||||||
|
from ansible_collections.kubernetes.core.plugins.module_utils.client.resource import (
|
||||||
|
ResourceList,
|
||||||
|
)
|
||||||
from kubernetes import __version__
|
from kubernetes import __version__
|
||||||
from kubernetes.dynamic.exceptions import (
|
from kubernetes.dynamic.exceptions import (
|
||||||
ResourceNotFoundError,
|
ResourceNotFoundError,
|
||||||
@@ -29,10 +32,6 @@ from kubernetes.dynamic.exceptions import (
|
|||||||
ServiceUnavailableError,
|
ServiceUnavailableError,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.client.resource import (
|
|
||||||
ResourceList,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Discoverer(kubernetes.dynamic.discovery.Discoverer):
|
class Discoverer(kubernetes.dynamic.discovery.Discoverer):
|
||||||
def __init__(self, client, cache_file):
|
def __init__(self, client, cache_file):
|
||||||
@@ -114,7 +113,7 @@ class Discoverer(kubernetes.dynamic.discovery.Discoverer):
|
|||||||
filter(lambda resource: "/" in resource["name"], resources_response)
|
filter(lambda resource: "/" in resource["name"], resources_response)
|
||||||
)
|
)
|
||||||
for subresource in subresources_raw:
|
for subresource in subresources_raw:
|
||||||
resource, name = subresource["name"].split("/")
|
resource, name = subresource["name"].split("/", 1)
|
||||||
subresources[resource][name] = subresource
|
subresources[resource][name] = subresource
|
||||||
|
|
||||||
for resource in resources_raw:
|
for resource in resources_raw:
|
||||||
|
|||||||
@@ -20,17 +20,20 @@ from __future__ import absolute_import, division, print_function
|
|||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import time
|
|
||||||
import os
|
|
||||||
import traceback
|
|
||||||
import sys
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import traceback
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from tempfile import NamedTemporaryFile
|
from tempfile import NamedTemporaryFile
|
||||||
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.version import (
|
from ansible.module_utils._text import to_bytes, to_native, to_text
|
||||||
LooseVersion,
|
from ansible.module_utils.basic import missing_required_lib
|
||||||
)
|
from ansible.module_utils.common.dict_transformations import dict_merge
|
||||||
|
from ansible.module_utils.parsing.convert_bool import boolean
|
||||||
|
from ansible.module_utils.six import iteritems, string_types
|
||||||
|
from ansible.module_utils.urls import Request
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
|
||||||
AUTH_ARG_MAP,
|
AUTH_ARG_MAP,
|
||||||
AUTH_ARG_SPEC,
|
AUTH_ARG_SPEC,
|
||||||
@@ -42,27 +45,23 @@ from ansible_collections.kubernetes.core.plugins.module_utils.hashes import (
|
|||||||
from ansible_collections.kubernetes.core.plugins.module_utils.selector import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.selector import (
|
||||||
LabelSelectorFilter,
|
LabelSelectorFilter,
|
||||||
)
|
)
|
||||||
|
from ansible_collections.kubernetes.core.plugins.module_utils.version import (
|
||||||
from ansible.module_utils.basic import missing_required_lib
|
LooseVersion,
|
||||||
from ansible.module_utils.six import iteritems, string_types
|
)
|
||||||
from ansible.module_utils._text import to_native, to_bytes, to_text
|
|
||||||
from ansible.module_utils.common.dict_transformations import dict_merge
|
|
||||||
from ansible.module_utils.parsing.convert_bool import boolean
|
|
||||||
from ansible.module_utils.urls import Request
|
|
||||||
|
|
||||||
K8S_IMP_ERR = None
|
K8S_IMP_ERR = None
|
||||||
try:
|
try:
|
||||||
import kubernetes
|
import kubernetes
|
||||||
from kubernetes.dynamic.exceptions import (
|
from kubernetes.dynamic.exceptions import (
|
||||||
|
BadRequestError,
|
||||||
|
ConflictError,
|
||||||
|
DynamicApiError,
|
||||||
|
ForbiddenError,
|
||||||
|
KubernetesValidateMissing,
|
||||||
|
MethodNotAllowedError,
|
||||||
NotFoundError,
|
NotFoundError,
|
||||||
ResourceNotFoundError,
|
ResourceNotFoundError,
|
||||||
ResourceNotUniqueError,
|
ResourceNotUniqueError,
|
||||||
DynamicApiError,
|
|
||||||
ConflictError,
|
|
||||||
ForbiddenError,
|
|
||||||
MethodNotAllowedError,
|
|
||||||
BadRequestError,
|
|
||||||
KubernetesValidateMissing,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
HAS_K8S_MODULE_HELPER = True
|
HAS_K8S_MODULE_HELPER = True
|
||||||
@@ -797,8 +796,8 @@ class K8sAnsibleMixin(object):
|
|||||||
self.resource_definitions = [implicit_definition]
|
self.resource_definitions = [implicit_definition]
|
||||||
|
|
||||||
def check_library_version(self):
|
def check_library_version(self):
|
||||||
if LooseVersion(self.kubernetes_version) < LooseVersion("12.0.0"):
|
if LooseVersion(self.kubernetes_version) < LooseVersion("24.2.0"):
|
||||||
self.fail_json(msg="kubernetes >= 12.0.0 is required")
|
self.fail_json(msg="kubernetes >= 24.2.0 is required")
|
||||||
|
|
||||||
def flatten_list_kind(self, list_resource, definitions):
|
def flatten_list_kind(self, list_resource, definitions):
|
||||||
flattened = []
|
flattened = []
|
||||||
@@ -819,7 +818,7 @@ class K8sAnsibleMixin(object):
|
|||||||
try:
|
try:
|
||||||
self.client = get_api_client(self.module)
|
self.client = get_api_client(self.module)
|
||||||
# Hopefully the kubernetes client will provide its own exception class one day
|
# Hopefully the kubernetes client will provide its own exception class one day
|
||||||
except (urllib3.exceptions.RequestError) as e:
|
except urllib3.exceptions.RequestError as e:
|
||||||
self.fail_json(msg="Couldn't connect to Kubernetes: %s" % str(e))
|
self.fail_json(msg="Couldn't connect to Kubernetes: %s" % str(e))
|
||||||
|
|
||||||
flattened_definitions = []
|
flattened_definitions = []
|
||||||
@@ -837,7 +836,7 @@ class K8sAnsibleMixin(object):
|
|||||||
resource = self.find_resource(kind, api_version, fail=True)
|
resource = self.find_resource(kind, api_version, fail=True)
|
||||||
flattened_definitions.append((resource, definition))
|
flattened_definitions.append((resource, definition))
|
||||||
|
|
||||||
for (resource, definition) in flattened_definitions:
|
for resource, definition in flattened_definitions:
|
||||||
kind = definition.get("kind", self.kind)
|
kind = definition.get("kind", self.kind)
|
||||||
api_version = definition.get("apiVersion", self.api_version)
|
api_version = definition.get("apiVersion", self.api_version)
|
||||||
definition = self.set_defaults(resource, definition)
|
definition = self.set_defaults(resource, definition)
|
||||||
@@ -1436,7 +1435,7 @@ class K8sAnsibleMixin(object):
|
|||||||
if merge_type == "json":
|
if merge_type == "json":
|
||||||
self.module.deprecate(
|
self.module.deprecate(
|
||||||
msg="json as a merge_type value is deprecated. Please use the k8s_json_patch module instead.",
|
msg="json as a merge_type value is deprecated. Please use the k8s_json_patch module instead.",
|
||||||
version="3.0.0",
|
version="4.0.0",
|
||||||
collection_name="kubernetes.core",
|
collection_name="kubernetes.core",
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -18,25 +18,26 @@ from __future__ import absolute_import, division, print_function
|
|||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from tempfile import TemporaryFile, NamedTemporaryFile
|
|
||||||
from select import select
|
|
||||||
from abc import ABCMeta, abstractmethod
|
|
||||||
import tarfile
|
import tarfile
|
||||||
|
from abc import ABCMeta, abstractmethod
|
||||||
|
from select import select
|
||||||
|
from tempfile import NamedTemporaryFile, TemporaryFile
|
||||||
|
|
||||||
|
from ansible.module_utils._text import to_native
|
||||||
|
|
||||||
# from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import AnsibleModule
|
# from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import AnsibleModule
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
|
||||||
CoreException,
|
CoreException,
|
||||||
)
|
)
|
||||||
from ansible.module_utils._text import to_native
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from kubernetes.client.api import core_v1_api
|
from kubernetes.client.api import core_v1_api
|
||||||
from kubernetes.stream import stream
|
from kubernetes.stream import stream
|
||||||
from kubernetes.stream.ws_client import (
|
from kubernetes.stream.ws_client import (
|
||||||
STDOUT_CHANNEL,
|
|
||||||
STDERR_CHANNEL,
|
|
||||||
ERROR_CHANNEL,
|
|
||||||
ABNF,
|
ABNF,
|
||||||
|
ERROR_CHANNEL,
|
||||||
|
STDERR_CHANNEL,
|
||||||
|
STDOUT_CHANNEL,
|
||||||
)
|
)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ from __future__ import absolute_import, division, print_function
|
|||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
import json
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import json
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import string
|
import string
|
||||||
@@ -37,7 +37,7 @@ except ImportError:
|
|||||||
|
|
||||||
def sorted_dict(unsorted_dict):
|
def sorted_dict(unsorted_dict):
|
||||||
result = OrderedDict()
|
result = OrderedDict()
|
||||||
for (k, v) in sorted(unsorted_dict.items()):
|
for k, v in sorted(unsorted_dict.items()):
|
||||||
if isinstance(v, dict):
|
if isinstance(v, dict):
|
||||||
v = sorted_dict(v)
|
v = sorted_dict(v)
|
||||||
result[k] = v
|
result[k] = v
|
||||||
|
|||||||
@@ -7,19 +7,18 @@ from __future__ import absolute_import, division, print_function
|
|||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
|
import copy
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import tempfile
|
import tempfile
|
||||||
import traceback
|
import traceback
|
||||||
import re
|
|
||||||
import json
|
|
||||||
import copy
|
|
||||||
|
|
||||||
from ansible.module_utils.basic import missing_required_lib
|
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||||
from ansible.module_utils.six import string_types
|
from ansible.module_utils.six import string_types
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.version import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.version import (
|
||||||
LooseVersion,
|
LooseVersion,
|
||||||
)
|
)
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import yaml
|
import yaml
|
||||||
@@ -78,13 +77,11 @@ def write_temp_kubeconfig(server, validate_certs=True, ca_cert=None, kubeconfig=
|
|||||||
|
|
||||||
|
|
||||||
class AnsibleHelmModule(object):
|
class AnsibleHelmModule(object):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
An Ansible module class for Kubernetes.core helm modules
|
An Ansible module class for Kubernetes.core helm modules
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
|
||||||
self._module = None
|
self._module = None
|
||||||
if "module" in kwargs:
|
if "module" in kwargs:
|
||||||
self._module = kwargs.get("module")
|
self._module = kwargs.get("module")
|
||||||
@@ -117,7 +114,7 @@ class AnsibleHelmModule(object):
|
|||||||
kubeconfig = self.params.get("kubeconfig")
|
kubeconfig = self.params.get("kubeconfig")
|
||||||
if kubeconfig:
|
if kubeconfig:
|
||||||
if isinstance(kubeconfig, string_types):
|
if isinstance(kubeconfig, string_types):
|
||||||
with open(kubeconfig) as fd:
|
with open(os.path.expanduser(kubeconfig)) as fd:
|
||||||
kubeconfig_content = yaml.safe_load(fd)
|
kubeconfig_content = yaml.safe_load(fd)
|
||||||
elif isinstance(kubeconfig, dict):
|
elif isinstance(kubeconfig, dict):
|
||||||
kubeconfig_content = kubeconfig
|
kubeconfig_content = kubeconfig
|
||||||
@@ -184,13 +181,12 @@ class AnsibleHelmModule(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def get_helm_version(self):
|
def get_helm_version(self):
|
||||||
|
|
||||||
command = self.get_helm_binary() + " version"
|
command = self.get_helm_binary() + " version"
|
||||||
rc, out, err = self.run_command(command)
|
rc, out, err = self.run_command(command)
|
||||||
m = re.match(r'version.BuildInfo{Version:"v([0-9\.]*)",', out)
|
m = re.match(r'version.BuildInfo{Version:"v(.*?)",', out)
|
||||||
if m:
|
if m:
|
||||||
return m.group(1)
|
return m.group(1)
|
||||||
m = re.match(r'Client: &version.Version{SemVer:"v([0-9\.]*)", ', out)
|
m = re.match(r'Client: &version.Version{SemVer:"v(.*?)", ', out)
|
||||||
if m:
|
if m:
|
||||||
return m.group(1)
|
return m.group(1)
|
||||||
return None
|
return None
|
||||||
@@ -216,7 +212,6 @@ class AnsibleHelmModule(object):
|
|||||||
return yaml.safe_load(out)
|
return yaml.safe_load(out)
|
||||||
|
|
||||||
def parse_yaml_content(self, content):
|
def parse_yaml_content(self, content):
|
||||||
|
|
||||||
if not HAS_YAML:
|
if not HAS_YAML:
|
||||||
self.fail_json(msg=missing_required_lib("yaml"), exception=HAS_YAML)
|
self.fail_json(msg=missing_required_lib("yaml"), exception=HAS_YAML)
|
||||||
|
|
||||||
@@ -228,7 +223,6 @@ class AnsibleHelmModule(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def get_manifest(self, release_name):
|
def get_manifest(self, release_name):
|
||||||
|
|
||||||
command = [
|
command = [
|
||||||
self.get_helm_binary(),
|
self.get_helm_binary(),
|
||||||
"get",
|
"get",
|
||||||
@@ -241,7 +235,6 @@ class AnsibleHelmModule(object):
|
|||||||
return self.parse_yaml_content(out)
|
return self.parse_yaml_content(out)
|
||||||
|
|
||||||
def get_notes(self, release_name):
|
def get_notes(self, release_name):
|
||||||
|
|
||||||
command = [
|
command = [
|
||||||
self.get_helm_binary(),
|
self.get_helm_binary(),
|
||||||
"get",
|
"get",
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ HELM_AUTH_ARG_SPEC = dict(
|
|||||||
type="raw",
|
type="raw",
|
||||||
aliases=["kubeconfig_path"],
|
aliases=["kubeconfig_path"],
|
||||||
fallback=(env_fallback, ["K8S_AUTH_KUBECONFIG"]),
|
fallback=(env_fallback, ["K8S_AUTH_KUBECONFIG"]),
|
||||||
|
no_log=True,
|
||||||
),
|
),
|
||||||
host=dict(type="str", fallback=(env_fallback, ["K8S_AUTH_HOST"])),
|
host=dict(type="str", fallback=(env_fallback, ["K8S_AUTH_HOST"])),
|
||||||
ca_cert=dict(
|
ca_cert=dict(
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
# Copyright: (c) 2021, Red Hat | Ansible
|
# Copyright: (c) 2021, Red Hat | Ansible
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
import os
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import os
|
||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
from ansible.module_utils.six import iteritems, string_types
|
from ansible.module_utils.six import iteritems, string_types
|
||||||
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
|
||||||
AUTH_ARG_MAP,
|
AUTH_ARG_MAP,
|
||||||
AUTH_ARG_SPEC,
|
AUTH_ARG_SPEC,
|
||||||
|
|||||||
@@ -1,15 +1,12 @@
|
|||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||||
|
from ansible.module_utils.common.text.converters import to_text
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.version import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.version import (
|
||||||
LooseVersion,
|
LooseVersion,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
|
||||||
from ansible.module_utils.basic import missing_required_lib
|
|
||||||
from ansible.module_utils.common.text.converters import to_text
|
|
||||||
|
|
||||||
|
|
||||||
class AnsibleK8SModule:
|
class AnsibleK8SModule:
|
||||||
"""A base module class for K8S modules.
|
"""A base module class for K8S modules.
|
||||||
@@ -38,7 +35,7 @@ class AnsibleK8SModule:
|
|||||||
|
|
||||||
if self.settings["check_k8s"]:
|
if self.settings["check_k8s"]:
|
||||||
self.requires("kubernetes")
|
self.requires("kubernetes")
|
||||||
self.has_at_least("kubernetes", "12.0.0", warn=True)
|
self.has_at_least("kubernetes", "24.2.0", warn=True)
|
||||||
|
|
||||||
if self.settings["check_pyyaml"]:
|
if self.settings["check_pyyaml"]:
|
||||||
self.requires("pyyaml")
|
self.requires("pyyaml")
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from typing import cast, Dict, Iterable, List, Optional, Union
|
from typing import Dict, Iterable, List, Optional, Union, cast
|
||||||
|
|
||||||
from ansible.module_utils.six import string_types
|
from ansible.module_utils.six import string_types
|
||||||
from ansible.module_utils.urls import Request
|
from ansible.module_utils.urls import Request
|
||||||
|
|||||||
@@ -4,12 +4,12 @@
|
|||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
from ansible.module_utils._text import to_native
|
from ansible.module_utils._text import to_native
|
||||||
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
|
||||||
get_api_client,
|
get_api_client,
|
||||||
)
|
)
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
|
||||||
CoreException,
|
CoreException,
|
||||||
|
ResourceTimeout,
|
||||||
)
|
)
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.resource import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.resource import (
|
||||||
create_definitions,
|
create_definitions,
|
||||||
@@ -17,9 +17,7 @@ from ansible_collections.kubernetes.core.plugins.module_utils.k8s.resource impor
|
|||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.service import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.service import (
|
||||||
K8sService,
|
K8sService,
|
||||||
diff_objects,
|
diff_objects,
|
||||||
)
|
hide_fields,
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
|
|
||||||
ResourceTimeout,
|
|
||||||
)
|
)
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.waiter import exists
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.waiter import exists
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.selector import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.selector import (
|
||||||
@@ -46,16 +44,51 @@ def validate(client, module, resource):
|
|||||||
return [_prepend_resource_info(resource, msg) for msg in warnings + errors]
|
return [_prepend_resource_info(resource, msg) for msg in warnings + errors]
|
||||||
|
|
||||||
|
|
||||||
|
def get_definitions(svc, params):
|
||||||
|
try:
|
||||||
|
definitions = create_definitions(params)
|
||||||
|
except Exception as e:
|
||||||
|
msg = "Failed to load resource definition: {0}".format(e)
|
||||||
|
raise CoreException(msg) from e
|
||||||
|
|
||||||
|
delete_all = params.get("delete_all")
|
||||||
|
src = params.get("src")
|
||||||
|
resource_definition = params.get("resource_definition")
|
||||||
|
name = params.get("name")
|
||||||
|
state = params.get("state")
|
||||||
|
|
||||||
|
if (
|
||||||
|
delete_all
|
||||||
|
and state == "absent"
|
||||||
|
and name is None
|
||||||
|
and resource_definition is None
|
||||||
|
and src is None
|
||||||
|
):
|
||||||
|
# Delete all resources in the namespace for the specified resource type
|
||||||
|
if params.get("kind") is None:
|
||||||
|
raise CoreException(
|
||||||
|
"'kind' option is required to specify the resource type."
|
||||||
|
)
|
||||||
|
|
||||||
|
resource = svc.find_resource(
|
||||||
|
params.get("kind"), params.get("api_version"), fail=True
|
||||||
|
)
|
||||||
|
definitions = svc.retrieve_all(
|
||||||
|
resource,
|
||||||
|
params.get("namespace"),
|
||||||
|
params.get("label_selectors"),
|
||||||
|
)
|
||||||
|
|
||||||
|
return definitions
|
||||||
|
|
||||||
|
|
||||||
def run_module(module) -> None:
|
def run_module(module) -> None:
|
||||||
results = []
|
results = []
|
||||||
changed = False
|
changed = False
|
||||||
client = get_api_client(module)
|
client = get_api_client(module)
|
||||||
svc = K8sService(client, module)
|
svc = K8sService(client, module)
|
||||||
try:
|
|
||||||
definitions = create_definitions(module.params)
|
definitions = get_definitions(svc, module.params)
|
||||||
except Exception as e:
|
|
||||||
msg = "Failed to load resource definition: {0}".format(e)
|
|
||||||
raise CoreException(msg) from e
|
|
||||||
|
|
||||||
for definition in definitions:
|
for definition in definitions:
|
||||||
result = {"changed": False, "result": {}}
|
result = {"changed": False, "result": {}}
|
||||||
@@ -102,6 +135,7 @@ def perform_action(svc, definition: Dict, params: Dict) -> Dict:
|
|||||||
state = params.get("state", None)
|
state = params.get("state", None)
|
||||||
kind = definition.get("kind")
|
kind = definition.get("kind")
|
||||||
api_version = definition.get("apiVersion")
|
api_version = definition.get("apiVersion")
|
||||||
|
hidden_fields = params.get("hidden_fields")
|
||||||
|
|
||||||
result = {"changed": False, "result": {}}
|
result = {"changed": False, "result": {}}
|
||||||
instance = {}
|
instance = {}
|
||||||
@@ -177,7 +211,7 @@ def perform_action(svc, definition: Dict, params: Dict) -> Dict:
|
|||||||
existing = existing.to_dict()
|
existing = existing.to_dict()
|
||||||
else:
|
else:
|
||||||
existing = {}
|
existing = {}
|
||||||
match, diffs = diff_objects(existing, instance)
|
match, diffs = diff_objects(existing, instance, hidden_fields)
|
||||||
if match and diffs:
|
if match and diffs:
|
||||||
result.setdefault("warnings", []).append(
|
result.setdefault("warnings", []).append(
|
||||||
"No meaningful diff was generated, but the API may not be idempotent "
|
"No meaningful diff was generated, but the API may not be idempotent "
|
||||||
@@ -187,7 +221,7 @@ def perform_action(svc, definition: Dict, params: Dict) -> Dict:
|
|||||||
if svc.module._diff:
|
if svc.module._diff:
|
||||||
result["diff"] = diffs
|
result["diff"] = diffs
|
||||||
|
|
||||||
result["result"] = instance
|
result["result"] = hide_fields(instance, hidden_fields)
|
||||||
if not success:
|
if not success:
|
||||||
raise ResourceTimeout(
|
raise ResourceTimeout(
|
||||||
'"{0}" "{1}": Timed out waiting on resource'.format(
|
'"{0}" "{1}": Timed out waiting on resource'.format(
|
||||||
|
|||||||
@@ -1,38 +1,33 @@
|
|||||||
# Copyright: (c) 2021, Red Hat | Ansible
|
# Copyright: (c) 2021, Red Hat | Ansible
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
import copy
|
||||||
from typing import Any, Dict, List, Optional, Tuple
|
from typing import Any, Dict, List, Optional, Tuple
|
||||||
|
|
||||||
|
from ansible.module_utils.common.dict_transformations import dict_merge
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.hashes import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.hashes import (
|
||||||
generate_hash,
|
generate_hash,
|
||||||
)
|
)
|
||||||
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import requires
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.waiter import (
|
|
||||||
Waiter,
|
|
||||||
exists,
|
|
||||||
resource_absent,
|
|
||||||
get_waiter,
|
|
||||||
)
|
|
||||||
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import (
|
|
||||||
requires,
|
|
||||||
)
|
|
||||||
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
|
||||||
CoreException,
|
CoreException,
|
||||||
)
|
)
|
||||||
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.waiter import (
|
||||||
from ansible.module_utils.common.dict_transformations import dict_merge
|
Waiter,
|
||||||
|
exists,
|
||||||
|
get_waiter,
|
||||||
|
resource_absent,
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from kubernetes.dynamic.exceptions import (
|
from kubernetes.dynamic.exceptions import (
|
||||||
NotFoundError,
|
BadRequestError,
|
||||||
ResourceNotFoundError,
|
|
||||||
ResourceNotUniqueError,
|
|
||||||
ConflictError,
|
ConflictError,
|
||||||
ForbiddenError,
|
ForbiddenError,
|
||||||
MethodNotAllowedError,
|
MethodNotAllowedError,
|
||||||
BadRequestError,
|
NotFoundError,
|
||||||
|
ResourceNotFoundError,
|
||||||
|
ResourceNotUniqueError,
|
||||||
)
|
)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# Handled in module setup
|
# Handled in module setup
|
||||||
@@ -151,7 +146,7 @@ class K8sService:
|
|||||||
if merge_type == "json":
|
if merge_type == "json":
|
||||||
self.module.deprecate(
|
self.module.deprecate(
|
||||||
msg="json as a merge_type value is deprecated. Please use the k8s_json_patch module instead.",
|
msg="json as a merge_type value is deprecated. Please use the k8s_json_patch module instead.",
|
||||||
version="3.0.0",
|
version="4.0.0",
|
||||||
collection_name="kubernetes.core",
|
collection_name="kubernetes.core",
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
@@ -211,6 +206,30 @@ class K8sService:
|
|||||||
|
|
||||||
return existing
|
return existing
|
||||||
|
|
||||||
|
def retrieve_all(
|
||||||
|
self, resource: Resource, namespace: str, label_selectors: List[str] = None
|
||||||
|
) -> List[Dict]:
|
||||||
|
definitions: List[ResourceInstance] = []
|
||||||
|
|
||||||
|
try:
|
||||||
|
params = dict(namespace=namespace)
|
||||||
|
if label_selectors:
|
||||||
|
params["label_selector"] = ",".join(label_selectors)
|
||||||
|
resource_list = self.client.get(resource, **params)
|
||||||
|
for item in resource_list.items:
|
||||||
|
existing = self.client.get(
|
||||||
|
resource, name=item.metadata.name, namespace=namespace
|
||||||
|
)
|
||||||
|
definitions.append(existing.to_dict())
|
||||||
|
except (NotFoundError, MethodNotAllowedError):
|
||||||
|
pass
|
||||||
|
except Exception as e:
|
||||||
|
reason = e.body if hasattr(e, "body") else e
|
||||||
|
msg = "Failed to retrieve requested object: {0}".format(reason)
|
||||||
|
raise CoreException(msg) from e
|
||||||
|
|
||||||
|
return definitions
|
||||||
|
|
||||||
def find(
|
def find(
|
||||||
self,
|
self,
|
||||||
kind: str,
|
kind: str,
|
||||||
@@ -224,6 +243,7 @@ class K8sService:
|
|||||||
wait_timeout: Optional[int] = 120,
|
wait_timeout: Optional[int] = 120,
|
||||||
state: Optional[str] = "present",
|
state: Optional[str] = "present",
|
||||||
condition: Optional[Dict] = None,
|
condition: Optional[Dict] = None,
|
||||||
|
hidden_fields: Optional[List] = None,
|
||||||
) -> Dict:
|
) -> Dict:
|
||||||
resource = self.find_resource(kind, api_version)
|
resource = self.find_resource(kind, api_version)
|
||||||
api_found = bool(resource)
|
api_found = bool(resource)
|
||||||
@@ -286,7 +306,9 @@ class K8sService:
|
|||||||
instances = resources.get("items") or [resources]
|
instances = resources.get("items") or [resources]
|
||||||
|
|
||||||
if not wait:
|
if not wait:
|
||||||
result["resources"] = instances
|
result["resources"] = [
|
||||||
|
hide_fields(instance, hidden_fields) for instance in instances
|
||||||
|
]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# Now wait for the specified state of any resource instances we have found.
|
# Now wait for the specified state of any resource instances we have found.
|
||||||
@@ -305,7 +327,7 @@ class K8sService:
|
|||||||
"Failed to gather information about %s(s) even"
|
"Failed to gather information about %s(s) even"
|
||||||
" after waiting for %s seconds" % (res.get("kind"), duration)
|
" after waiting for %s seconds" % (res.get("kind"), duration)
|
||||||
)
|
)
|
||||||
result["resources"].append(res)
|
result["resources"].append(hide_fields(res, hidden_fields))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def create(self, resource: Resource, definition: Dict) -> Dict:
|
def create(self, resource: Resource, definition: Dict) -> Dict:
|
||||||
@@ -454,7 +476,7 @@ class K8sService:
|
|||||||
if label_selectors:
|
if label_selectors:
|
||||||
params["label_selector"] = ",".join(label_selectors)
|
params["label_selector"] = ",".join(label_selectors)
|
||||||
|
|
||||||
if delete_options:
|
if delete_options and not self.module.check_mode:
|
||||||
body = {
|
body = {
|
||||||
"apiVersion": "v1",
|
"apiVersion": "v1",
|
||||||
"kind": "DeleteOptions",
|
"kind": "DeleteOptions",
|
||||||
@@ -471,7 +493,9 @@ class K8sService:
|
|||||||
return k8s_obj
|
return k8s_obj
|
||||||
|
|
||||||
|
|
||||||
def diff_objects(existing: Dict, new: Dict) -> Tuple[bool, Dict]:
|
def diff_objects(
|
||||||
|
existing: Dict, new: Dict, hidden_fields: Optional[list] = None
|
||||||
|
) -> Tuple[bool, Dict]:
|
||||||
result = {}
|
result = {}
|
||||||
diff = recursive_diff(existing, new)
|
diff = recursive_diff(existing, new)
|
||||||
if not diff:
|
if not diff:
|
||||||
@@ -493,4 +517,29 @@ def diff_objects(existing: Dict, new: Dict) -> Tuple[bool, Dict]:
|
|||||||
if not set(result["before"]["metadata"].keys()).issubset(ignored_keys):
|
if not set(result["before"]["metadata"].keys()).issubset(ignored_keys):
|
||||||
return False, result
|
return False, result
|
||||||
|
|
||||||
|
result["before"] = hide_fields(result["before"], hidden_fields)
|
||||||
|
result["after"] = hide_fields(result["after"], hidden_fields)
|
||||||
|
|
||||||
return True, result
|
return True, result
|
||||||
|
|
||||||
|
|
||||||
|
def hide_fields(definition: dict, hidden_fields: Optional[list]) -> dict:
|
||||||
|
if not hidden_fields:
|
||||||
|
return definition
|
||||||
|
result = copy.deepcopy(definition)
|
||||||
|
for hidden_field in hidden_fields:
|
||||||
|
result = hide_field(result, hidden_field)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
# hide_field is not hugely sophisticated and designed to cope
|
||||||
|
# with e.g. status or metadata.managedFields rather than e.g.
|
||||||
|
# spec.template.spec.containers[0].env[3].value
|
||||||
|
def hide_field(definition: dict, hidden_field: str) -> dict:
|
||||||
|
split = hidden_field.split(".", 1)
|
||||||
|
if split[0] in definition:
|
||||||
|
if len(split) == 2:
|
||||||
|
definition[split[0]] = hide_field(definition[split[0]], split[1])
|
||||||
|
else:
|
||||||
|
del definition[split[0]]
|
||||||
|
return definition
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ from functools import partial
|
|||||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union
|
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union
|
||||||
|
|
||||||
from ansible.module_utils.parsing.convert_bool import boolean
|
from ansible.module_utils.parsing.convert_bool import boolean
|
||||||
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
|
||||||
CoreException,
|
CoreException,
|
||||||
)
|
)
|
||||||
@@ -52,7 +51,7 @@ def daemonset_ready(daemonset: ResourceInstance) -> bool:
|
|||||||
return bool(
|
return bool(
|
||||||
daemonset.status
|
daemonset.status
|
||||||
and daemonset.status.desiredNumberScheduled is not None
|
and daemonset.status.desiredNumberScheduled is not None
|
||||||
and daemonset.status.updatedNumberScheduled
|
and (daemonset.status.updatedNumberScheduled or 0)
|
||||||
== daemonset.status.desiredNumberScheduled
|
== daemonset.status.desiredNumberScheduled
|
||||||
and daemonset.status.numberReady == daemonset.status.desiredNumberScheduled
|
and daemonset.status.numberReady == daemonset.status.desiredNumberScheduled
|
||||||
and daemonset.status.observedGeneration == daemonset.metadata.generation
|
and daemonset.status.observedGeneration == daemonset.metadata.generation
|
||||||
@@ -61,6 +60,13 @@ def daemonset_ready(daemonset: ResourceInstance) -> bool:
|
|||||||
|
|
||||||
|
|
||||||
def statefulset_ready(statefulset: ResourceInstance) -> bool:
|
def statefulset_ready(statefulset: ResourceInstance) -> bool:
|
||||||
|
if statefulset.spec.updateStrategy.type == "OnDelete":
|
||||||
|
return bool(
|
||||||
|
statefulset.status
|
||||||
|
and statefulset.status.observedGeneration
|
||||||
|
== (statefulset.metadata.generation or 0)
|
||||||
|
and statefulset.status.replicas == statefulset.spec.replicas
|
||||||
|
)
|
||||||
# These may be None
|
# These may be None
|
||||||
updated_replicas = statefulset.status.updatedReplicas or 0
|
updated_replicas = statefulset.status.updatedReplicas or 0
|
||||||
ready_replicas = statefulset.status.readyReplicas or 0
|
ready_replicas = statefulset.status.readyReplicas or 0
|
||||||
|
|||||||
@@ -18,12 +18,11 @@ from __future__ import absolute_import, division, print_function
|
|||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
from kubernetes.dynamic import DynamicClient
|
|
||||||
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.apply import k8s_apply
|
from ansible_collections.kubernetes.core.plugins.module_utils.apply import k8s_apply
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.exceptions import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.exceptions import (
|
||||||
ApplyException,
|
ApplyException,
|
||||||
)
|
)
|
||||||
|
from kubernetes.dynamic import DynamicClient
|
||||||
|
|
||||||
|
|
||||||
class K8SDynamicClient(DynamicClient):
|
class K8SDynamicClient(DynamicClient):
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import re
|
|||||||
|
|
||||||
|
|
||||||
class Selector(object):
|
class Selector(object):
|
||||||
|
|
||||||
equality_based_operators = ("==", "!=", "=")
|
equality_based_operators = ("==", "!=", "=")
|
||||||
|
|
||||||
def __init__(self, data):
|
def __init__(self, data):
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ module: helm
|
|||||||
|
|
||||||
short_description: Manages Kubernetes packages with the Helm package manager
|
short_description: Manages Kubernetes packages with the Helm package manager
|
||||||
|
|
||||||
version_added: "0.11.0"
|
version_added: 0.11.0
|
||||||
|
|
||||||
author:
|
author:
|
||||||
- Lucas Boisserie (@LucasBoisserie)
|
- Lucas Boisserie (@LucasBoisserie)
|
||||||
@@ -61,7 +61,7 @@ options:
|
|||||||
default: false
|
default: false
|
||||||
type: bool
|
type: bool
|
||||||
aliases: [ dep_up ]
|
aliases: [ dep_up ]
|
||||||
version_added: "2.4.0"
|
version_added: 2.4.0
|
||||||
release_name:
|
release_name:
|
||||||
description:
|
description:
|
||||||
- Release name to manage.
|
- Release name to manage.
|
||||||
@@ -99,7 +99,7 @@ options:
|
|||||||
default: []
|
default: []
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
version_added: '1.1.0'
|
version_added: 1.1.0
|
||||||
update_repo_cache:
|
update_repo_cache:
|
||||||
description:
|
description:
|
||||||
- Run C(helm repo update) before the operation. Can be run as part of the package installation or as a separate step (see Examples).
|
- Run C(helm repo update) before the operation. Can be run as part of the package installation or as a separate step (see Examples).
|
||||||
@@ -129,7 +129,22 @@ options:
|
|||||||
- string
|
- string
|
||||||
- json
|
- json
|
||||||
- file
|
- file
|
||||||
version_added: '2.4.0'
|
version_added: 2.4.0
|
||||||
|
reuse_values:
|
||||||
|
description:
|
||||||
|
- When upgrading package, specifies wether to reuse the last release's values and merge in any overrides from parameters I(release_values),
|
||||||
|
I(values_files) or I(set_values).
|
||||||
|
- If I(reset_values) is set to C(True), this is ignored.
|
||||||
|
type: bool
|
||||||
|
required: false
|
||||||
|
version_added: 3.0.0
|
||||||
|
reset_values:
|
||||||
|
description:
|
||||||
|
- When upgrading package, reset the values to the ones built into the chart.
|
||||||
|
type: bool
|
||||||
|
required: false
|
||||||
|
default: True
|
||||||
|
version_added: 3.0.0
|
||||||
|
|
||||||
#Helm options
|
#Helm options
|
||||||
disable_hook:
|
disable_hook:
|
||||||
@@ -166,7 +181,7 @@ options:
|
|||||||
- similar to C(wait_timeout) but does not required C(wait) to be activated.
|
- similar to C(wait_timeout) but does not required C(wait) to be activated.
|
||||||
- Mutually exclusive with C(wait_timeout).
|
- Mutually exclusive with C(wait_timeout).
|
||||||
type: str
|
type: str
|
||||||
version_added: "2.3.0"
|
version_added: 2.3.0
|
||||||
atomic:
|
atomic:
|
||||||
description:
|
description:
|
||||||
- If set, the installation process deletes the installation on failure.
|
- If set, the installation process deletes the installation on failure.
|
||||||
@@ -177,12 +192,12 @@ options:
|
|||||||
- Create the release namespace if not present.
|
- Create the release namespace if not present.
|
||||||
type: bool
|
type: bool
|
||||||
default: False
|
default: False
|
||||||
version_added: "0.11.1"
|
version_added: 0.11.1
|
||||||
post_renderer:
|
post_renderer:
|
||||||
description:
|
description:
|
||||||
- Path to an executable to be used for post rendering.
|
- Path to an executable to be used for post rendering.
|
||||||
type: str
|
type: str
|
||||||
version_added: "2.4.0"
|
version_added: 2.4.0
|
||||||
replace:
|
replace:
|
||||||
description:
|
description:
|
||||||
- Reuse the given name, only if that name is a deleted release which remains in the history.
|
- Reuse the given name, only if that name is a deleted release which remains in the history.
|
||||||
@@ -190,19 +205,19 @@ options:
|
|||||||
- mutually exclusive with with C(history_max).
|
- mutually exclusive with with C(history_max).
|
||||||
type: bool
|
type: bool
|
||||||
default: False
|
default: False
|
||||||
version_added: "1.11.0"
|
version_added: 1.11.0
|
||||||
skip_crds:
|
skip_crds:
|
||||||
description:
|
description:
|
||||||
- Skip custom resource definitions when installing or upgrading.
|
- Skip custom resource definitions when installing or upgrading.
|
||||||
type: bool
|
type: bool
|
||||||
default: False
|
default: False
|
||||||
version_added: "1.2.0"
|
version_added: 1.2.0
|
||||||
history_max:
|
history_max:
|
||||||
description:
|
description:
|
||||||
- Limit the maximum number of revisions saved per release.
|
- Limit the maximum number of revisions saved per release.
|
||||||
- mutually exclusive with with C(replace).
|
- mutually exclusive with with C(replace).
|
||||||
type: int
|
type: int
|
||||||
version_added: "2.2.0"
|
version_added: 2.2.0
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- kubernetes.core.helm_common_options
|
- kubernetes.core.helm_common_options
|
||||||
"""
|
"""
|
||||||
@@ -310,6 +325,17 @@ EXAMPLES = r"""
|
|||||||
enabled: True
|
enabled: True
|
||||||
logging:
|
logging:
|
||||||
enabled: True
|
enabled: True
|
||||||
|
|
||||||
|
# Deploy latest version
|
||||||
|
- name: Deploy latest version of Grafana chart using reuse_values
|
||||||
|
kubernetes.core.helm:
|
||||||
|
name: test
|
||||||
|
chart_ref: stable/grafana
|
||||||
|
release_namespace: monitoring
|
||||||
|
reuse_values: true
|
||||||
|
values:
|
||||||
|
replicas: 2
|
||||||
|
version: 3e8ec0b2dffa40fb97d5342e4af887de95faa8c61a62480dd7f8aa03dffcf533
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = r"""
|
RETURN = r"""
|
||||||
@@ -367,10 +393,11 @@ command:
|
|||||||
sample: helm upgrade ...
|
sample: helm upgrade ...
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import copy
|
||||||
import re
|
import re
|
||||||
import tempfile
|
import tempfile
|
||||||
import traceback
|
import traceback
|
||||||
import copy
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.version import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.version import (
|
||||||
LooseVersion,
|
LooseVersion,
|
||||||
)
|
)
|
||||||
@@ -406,14 +433,20 @@ def get_release(state, release_name):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_release_status(module, release_name):
|
def get_release_status(module, release_name, all_status=False):
|
||||||
"""
|
"""
|
||||||
Get Release state from deployed release
|
Get Release state from all release status (deployed, failed, pending-install, etc)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
list_command = (
|
list_command = [
|
||||||
module.get_helm_binary() + " list --output=yaml --filter " + release_name
|
module.get_helm_binary(),
|
||||||
)
|
"list",
|
||||||
|
"--output=yaml",
|
||||||
|
"--filter",
|
||||||
|
release_name,
|
||||||
|
]
|
||||||
|
if all_status:
|
||||||
|
list_command.append("--all")
|
||||||
|
|
||||||
rc, out, err = module.run_helm_command(list_command)
|
rc, out, err = module.run_helm_command(list_command)
|
||||||
|
|
||||||
@@ -439,7 +472,7 @@ def run_dep_update(module, chart_ref):
|
|||||||
"""
|
"""
|
||||||
Run dependency update
|
Run dependency update
|
||||||
"""
|
"""
|
||||||
dep_update = module.get_helm_binary() + " dependency update " + chart_ref
|
dep_update = module.get_helm_binary() + f" dependency update '{chart_ref}'"
|
||||||
rc, out, err = module.run_helm_command(dep_update)
|
rc, out, err = module.run_helm_command(dep_update)
|
||||||
|
|
||||||
|
|
||||||
@@ -447,7 +480,7 @@ def fetch_chart_info(module, command, chart_ref):
|
|||||||
"""
|
"""
|
||||||
Get chart info
|
Get chart info
|
||||||
"""
|
"""
|
||||||
inspect_command = command + " show chart " + chart_ref
|
inspect_command = command + f" show chart '{chart_ref}'"
|
||||||
|
|
||||||
rc, out, err = module.run_helm_command(inspect_command)
|
rc, out, err = module.run_helm_command(inspect_command)
|
||||||
|
|
||||||
@@ -455,6 +488,7 @@ def fetch_chart_info(module, command, chart_ref):
|
|||||||
|
|
||||||
|
|
||||||
def deploy(
|
def deploy(
|
||||||
|
module,
|
||||||
command,
|
command,
|
||||||
release_name,
|
release_name,
|
||||||
release_values,
|
release_values,
|
||||||
@@ -473,6 +507,8 @@ def deploy(
|
|||||||
timeout=None,
|
timeout=None,
|
||||||
dependency_update=None,
|
dependency_update=None,
|
||||||
set_value_args=None,
|
set_value_args=None,
|
||||||
|
reuse_values=None,
|
||||||
|
reset_values=True,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Install/upgrade/rollback release chart
|
Install/upgrade/rollback release chart
|
||||||
@@ -484,9 +520,11 @@ def deploy(
|
|||||||
deploy_command += " --dependency-update"
|
deploy_command += " --dependency-update"
|
||||||
else:
|
else:
|
||||||
deploy_command = command + " upgrade -i" # install/upgrade
|
deploy_command = command + " upgrade -i" # install/upgrade
|
||||||
|
if reset_values:
|
||||||
|
deploy_command += " --reset-values"
|
||||||
|
|
||||||
# Always reset values to keep release_values equal to values released
|
if reuse_values is not None:
|
||||||
deploy_command += " --reset-values"
|
deploy_command += " --reuse-values=" + str(reuse_values)
|
||||||
|
|
||||||
if wait:
|
if wait:
|
||||||
deploy_command += " --wait"
|
deploy_command += " --wait"
|
||||||
@@ -520,9 +558,10 @@ def deploy(
|
|||||||
with open(path, "w") as yaml_file:
|
with open(path, "w") as yaml_file:
|
||||||
yaml.dump(release_values, yaml_file, default_flow_style=False)
|
yaml.dump(release_values, yaml_file, default_flow_style=False)
|
||||||
deploy_command += " -f=" + path
|
deploy_command += " -f=" + path
|
||||||
|
module.add_cleanup_file(path)
|
||||||
|
|
||||||
if post_renderer:
|
if post_renderer:
|
||||||
deploy_command = " --post-renderer=" + post_renderer
|
deploy_command += " --post-renderer=" + post_renderer
|
||||||
|
|
||||||
if skip_crds:
|
if skip_crds:
|
||||||
deploy_command += " --skip-crds"
|
deploy_command += " --skip-crds"
|
||||||
@@ -533,7 +572,7 @@ def deploy(
|
|||||||
if set_value_args:
|
if set_value_args:
|
||||||
deploy_command += " " + set_value_args
|
deploy_command += " " + set_value_args
|
||||||
|
|
||||||
deploy_command += " " + release_name + " " + chart_name
|
deploy_command += " " + release_name + f" '{chart_name}'"
|
||||||
return deploy_command
|
return deploy_command
|
||||||
|
|
||||||
|
|
||||||
@@ -599,6 +638,10 @@ def helmdiff_check(
|
|||||||
chart_version=None,
|
chart_version=None,
|
||||||
replace=False,
|
replace=False,
|
||||||
chart_repo_url=None,
|
chart_repo_url=None,
|
||||||
|
post_renderer=False,
|
||||||
|
set_value_args=None,
|
||||||
|
reuse_values=None,
|
||||||
|
reset_values=True,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Use helm diff to determine if a release would change by upgrading a chart.
|
Use helm diff to determine if a release would change by upgrading a chart.
|
||||||
@@ -612,7 +655,13 @@ def helmdiff_check(
|
|||||||
if chart_version is not None:
|
if chart_version is not None:
|
||||||
cmd += " " + "--version=" + chart_version
|
cmd += " " + "--version=" + chart_version
|
||||||
if not replace:
|
if not replace:
|
||||||
cmd += " " + "--reset-values"
|
cmd += " " + "--reset-values=" + str(reset_values)
|
||||||
|
if post_renderer:
|
||||||
|
cmd += " --post-renderer=" + post_renderer
|
||||||
|
|
||||||
|
if values_files:
|
||||||
|
for value_file in values_files:
|
||||||
|
cmd += " --values=" + value_file
|
||||||
|
|
||||||
if release_values != {}:
|
if release_values != {}:
|
||||||
fd, path = tempfile.mkstemp(suffix=".yml")
|
fd, path = tempfile.mkstemp(suffix=".yml")
|
||||||
@@ -621,9 +670,11 @@ def helmdiff_check(
|
|||||||
cmd += " -f=" + path
|
cmd += " -f=" + path
|
||||||
module.add_cleanup_file(path)
|
module.add_cleanup_file(path)
|
||||||
|
|
||||||
if values_files:
|
if set_value_args:
|
||||||
for values_file in values_files:
|
cmd += " " + set_value_args
|
||||||
cmd += " -f=" + values_file
|
|
||||||
|
if reuse_values:
|
||||||
|
cmd += " --reuse-values"
|
||||||
|
|
||||||
rc, out, err = module.run_helm_command(cmd)
|
rc, out, err = module.run_helm_command(cmd)
|
||||||
return (len(out.strip()) > 0, out.strip())
|
return (len(out.strip()) > 0, out.strip())
|
||||||
@@ -682,6 +733,8 @@ def argument_spec():
|
|||||||
skip_crds=dict(type="bool", default=False),
|
skip_crds=dict(type="bool", default=False),
|
||||||
history_max=dict(type="int"),
|
history_max=dict(type="int"),
|
||||||
set_values=dict(type="list", elements="dict"),
|
set_values=dict(type="list", elements="dict"),
|
||||||
|
reuse_values=dict(type="bool"),
|
||||||
|
reset_values=dict(type="bool", default=True),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return arg_spec
|
return arg_spec
|
||||||
@@ -732,34 +785,38 @@ def main():
|
|||||||
history_max = module.params.get("history_max")
|
history_max = module.params.get("history_max")
|
||||||
timeout = module.params.get("timeout")
|
timeout = module.params.get("timeout")
|
||||||
set_values = module.params.get("set_values")
|
set_values = module.params.get("set_values")
|
||||||
|
reuse_values = module.params.get("reuse_values")
|
||||||
|
reset_values = module.params.get("reset_values")
|
||||||
|
|
||||||
if update_repo_cache:
|
if update_repo_cache:
|
||||||
run_repo_update(module)
|
run_repo_update(module)
|
||||||
|
|
||||||
# Get real/deployed release status
|
# Get real/deployed release status
|
||||||
release_status = get_release_status(module, release_name)
|
all_status = release_state == "absent"
|
||||||
|
release_status = get_release_status(module, release_name, all_status=all_status)
|
||||||
|
|
||||||
helm_cmd = module.get_helm_binary()
|
helm_cmd = module.get_helm_binary()
|
||||||
opt_result = {}
|
opt_result = {}
|
||||||
if release_state == "absent" and release_status is not None:
|
if release_state == "absent" and release_status is not None:
|
||||||
if replace:
|
# skip release statuses 'uninstalled' and 'uninstalling'
|
||||||
module.fail_json(msg="replace is not applicable when state is absent")
|
if not release_status["status"].startswith("uninstall"):
|
||||||
|
if replace:
|
||||||
|
module.fail_json(msg="replace is not applicable when state is absent")
|
||||||
|
|
||||||
if wait:
|
if wait:
|
||||||
helm_version = module.get_helm_version()
|
helm_version = module.get_helm_version()
|
||||||
if LooseVersion(helm_version) < LooseVersion("3.7.0"):
|
if LooseVersion(helm_version) < LooseVersion("3.7.0"):
|
||||||
opt_result["warnings"] = []
|
opt_result["warnings"] = []
|
||||||
opt_result["warnings"].append(
|
opt_result["warnings"].append(
|
||||||
"helm uninstall support option --wait for helm release >= 3.7.0"
|
"helm uninstall support option --wait for helm release >= 3.7.0"
|
||||||
)
|
)
|
||||||
wait = False
|
wait = False
|
||||||
|
|
||||||
helm_cmd = delete(
|
helm_cmd = delete(
|
||||||
helm_cmd, release_name, purge, disable_hook, wait, wait_timeout
|
helm_cmd, release_name, purge, disable_hook, wait, wait_timeout
|
||||||
)
|
)
|
||||||
changed = True
|
changed = True
|
||||||
elif release_state == "present":
|
elif release_state == "present":
|
||||||
|
|
||||||
if chart_version is not None:
|
if chart_version is not None:
|
||||||
helm_cmd += " --version=" + chart_version
|
helm_cmd += " --version=" + chart_version
|
||||||
|
|
||||||
@@ -799,12 +856,13 @@ def main():
|
|||||||
"Please consider add dependencies block or disable dependency_update to remove this warning."
|
"Please consider add dependencies block or disable dependency_update to remove this warning."
|
||||||
)
|
)
|
||||||
|
|
||||||
if release_status is None: # Not installed
|
set_value_args = None
|
||||||
set_value_args = None
|
if set_values:
|
||||||
if set_values:
|
set_value_args = module.get_helm_set_values_args(set_values)
|
||||||
set_value_args = module.get_helm_set_values_args(set_values)
|
|
||||||
|
|
||||||
|
if release_status is None: # Not installed
|
||||||
helm_cmd = deploy(
|
helm_cmd = deploy(
|
||||||
|
module,
|
||||||
helm_cmd,
|
helm_cmd,
|
||||||
release_name,
|
release_name,
|
||||||
release_values,
|
release_values,
|
||||||
@@ -823,11 +881,12 @@ def main():
|
|||||||
history_max=history_max,
|
history_max=history_max,
|
||||||
timeout=timeout,
|
timeout=timeout,
|
||||||
set_value_args=set_value_args,
|
set_value_args=set_value_args,
|
||||||
|
reuse_values=reuse_values,
|
||||||
|
reset_values=reset_values,
|
||||||
)
|
)
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
helm_diff_version = get_plugin_version("diff")
|
helm_diff_version = get_plugin_version("diff")
|
||||||
if helm_diff_version and (
|
if helm_diff_version and (
|
||||||
not chart_repo_url
|
not chart_repo_url
|
||||||
@@ -845,6 +904,10 @@ def main():
|
|||||||
chart_version,
|
chart_version,
|
||||||
replace,
|
replace,
|
||||||
chart_repo_url,
|
chart_repo_url,
|
||||||
|
post_renderer,
|
||||||
|
set_value_args,
|
||||||
|
reuse_values=reuse_values,
|
||||||
|
reset_values=reset_values,
|
||||||
)
|
)
|
||||||
if would_change and module._diff:
|
if would_change and module._diff:
|
||||||
opt_result["diff"] = {"prepared": prepared}
|
opt_result["diff"] = {"prepared": prepared}
|
||||||
@@ -858,11 +921,8 @@ def main():
|
|||||||
)
|
)
|
||||||
|
|
||||||
if force or would_change:
|
if force or would_change:
|
||||||
set_value_args = None
|
|
||||||
if set_values:
|
|
||||||
set_value_args = module.get_helm_set_values_args(set_values)
|
|
||||||
|
|
||||||
helm_cmd = deploy(
|
helm_cmd = deploy(
|
||||||
|
module,
|
||||||
helm_cmd,
|
helm_cmd,
|
||||||
release_name,
|
release_name,
|
||||||
release_values,
|
release_values,
|
||||||
@@ -881,6 +941,8 @@ def main():
|
|||||||
timeout=timeout,
|
timeout=timeout,
|
||||||
dependency_update=dependency_update,
|
dependency_update=dependency_update,
|
||||||
set_value_args=set_value_args,
|
set_value_args=set_value_args,
|
||||||
|
reuse_values=reuse_values,
|
||||||
|
reset_values=reset_values,
|
||||||
)
|
)
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
@@ -914,7 +976,7 @@ def main():
|
|||||||
changed=changed,
|
changed=changed,
|
||||||
stdout=out,
|
stdout=out,
|
||||||
stderr=err,
|
stderr=err,
|
||||||
status=get_release_status(module, release_name),
|
status=get_release_status(module, release_name, all_status=True),
|
||||||
command=helm_cmd,
|
command=helm_cmd,
|
||||||
**opt_result,
|
**opt_result,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ module: helm_info
|
|||||||
|
|
||||||
short_description: Get information from Helm package deployed inside the cluster
|
short_description: Get information from Helm package deployed inside the cluster
|
||||||
|
|
||||||
version_added: "0.11.0"
|
version_added: 0.11.0
|
||||||
|
|
||||||
author:
|
author:
|
||||||
- Lucas Boisserie (@LucasBoisserie)
|
- Lucas Boisserie (@LucasBoisserie)
|
||||||
@@ -53,7 +53,7 @@ options:
|
|||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
default: []
|
default: []
|
||||||
version_added: "2.3.0"
|
version_added: 2.3.0
|
||||||
get_all_values:
|
get_all_values:
|
||||||
description:
|
description:
|
||||||
- Set to C(True) if you want to get all (computed) values of the release.
|
- Set to C(True) if you want to get all (computed) values of the release.
|
||||||
@@ -61,7 +61,7 @@ options:
|
|||||||
required: false
|
required: false
|
||||||
default: false
|
default: false
|
||||||
type: bool
|
type: bool
|
||||||
version_added: "2.4.0"
|
version_added: 2.4.0
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- kubernetes.core.helm_common_options
|
- kubernetes.core.helm_common_options
|
||||||
"""
|
"""
|
||||||
@@ -123,22 +123,22 @@ status:
|
|||||||
elements: dict
|
elements: dict
|
||||||
description: Hooks of the release
|
description: Hooks of the release
|
||||||
returned: always
|
returned: always
|
||||||
version_added: "2.4.0"
|
version_added: 2.4.0
|
||||||
notes:
|
notes:
|
||||||
type: str
|
type: str
|
||||||
description: Notes of the release
|
description: Notes of the release
|
||||||
returned: always
|
returned: always
|
||||||
version_added: "2.4.0"
|
version_added: 2.4.0
|
||||||
manifest:
|
manifest:
|
||||||
type: list
|
type: list
|
||||||
elements: dict
|
elements: dict
|
||||||
description: Manifest of the release
|
description: Manifest of the release
|
||||||
returned: always
|
returned: always
|
||||||
version_added: "2.4.0"
|
version_added: 2.4.0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import traceback
|
|
||||||
import copy
|
import copy
|
||||||
|
import traceback
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import yaml
|
import yaml
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ DOCUMENTATION = r"""
|
|||||||
---
|
---
|
||||||
module: helm_plugin
|
module: helm_plugin
|
||||||
short_description: Manage Helm plugins
|
short_description: Manage Helm plugins
|
||||||
version_added: "1.0.0"
|
version_added: 1.0.0
|
||||||
author:
|
author:
|
||||||
- Abhijeet Kasurde (@Akasurde)
|
- Abhijeet Kasurde (@Akasurde)
|
||||||
requirements:
|
requirements:
|
||||||
@@ -47,7 +47,7 @@ options:
|
|||||||
- Ignored when C(state=absent) or C(state=latest).
|
- Ignored when C(state=absent) or C(state=latest).
|
||||||
required: false
|
required: false
|
||||||
type: str
|
type: str
|
||||||
version_added: "2.3.0"
|
version_added: 2.3.0
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- kubernetes.core.helm_common_options
|
- kubernetes.core.helm_common_options
|
||||||
"""
|
"""
|
||||||
@@ -109,6 +109,7 @@ rc:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.helm import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.helm import (
|
||||||
AnsibleHelmModule,
|
AnsibleHelmModule,
|
||||||
parse_helm_plugin_list,
|
parse_helm_plugin_list,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ DOCUMENTATION = r"""
|
|||||||
---
|
---
|
||||||
module: helm_plugin_info
|
module: helm_plugin_info
|
||||||
short_description: Gather information about Helm plugins
|
short_description: Gather information about Helm plugins
|
||||||
version_added: "1.0.0"
|
version_added: 1.0.0
|
||||||
author:
|
author:
|
||||||
- Abhijeet Kasurde (@Akasurde)
|
- Abhijeet Kasurde (@Akasurde)
|
||||||
requirements:
|
requirements:
|
||||||
@@ -71,9 +71,10 @@ rc:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.helm import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.helm import (
|
||||||
parse_helm_plugin_list,
|
|
||||||
AnsibleHelmModule,
|
AnsibleHelmModule,
|
||||||
|
parse_helm_plugin_list,
|
||||||
)
|
)
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.helm_args_common import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.helm_args_common import (
|
||||||
HELM_AUTH_ARG_SPEC,
|
HELM_AUTH_ARG_SPEC,
|
||||||
@@ -82,7 +83,6 @@ from ansible_collections.kubernetes.core.plugins.module_utils.helm_args_common i
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
argument_spec = copy.deepcopy(HELM_AUTH_ARG_SPEC)
|
argument_spec = copy.deepcopy(HELM_AUTH_ARG_SPEC)
|
||||||
argument_spec.update(
|
argument_spec.update(
|
||||||
dict(
|
dict(
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ DOCUMENTATION = r"""
|
|||||||
---
|
---
|
||||||
module: helm_pull
|
module: helm_pull
|
||||||
short_description: download a chart from a repository and (optionally) unpack it in local directory.
|
short_description: download a chart from a repository and (optionally) unpack it in local directory.
|
||||||
version_added: "2.4.0"
|
version_added: 2.4.0
|
||||||
author:
|
author:
|
||||||
- Aubin Bikouo (@abikouo)
|
- Aubin Bikouo (@abikouo)
|
||||||
description:
|
description:
|
||||||
@@ -189,7 +189,7 @@ def main():
|
|||||||
repo_password=dict(
|
repo_password=dict(
|
||||||
type="str", no_log=True, aliases=["password", "chart_repo_password"]
|
type="str", no_log=True, aliases=["password", "chart_repo_password"]
|
||||||
),
|
),
|
||||||
pass_credentials=dict(type="bool", default=False),
|
pass_credentials=dict(type="bool", default=False, no_log=False),
|
||||||
skip_tls_certs_check=dict(type="bool", default=False),
|
skip_tls_certs_check=dict(type="bool", default=False),
|
||||||
chart_devel=dict(type="bool"),
|
chart_devel=dict(type="bool"),
|
||||||
untar_chart=dict(type="bool", default=False),
|
untar_chart=dict(type="bool", default=False),
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ module: helm_repository
|
|||||||
|
|
||||||
short_description: Manage Helm repositories.
|
short_description: Manage Helm repositories.
|
||||||
|
|
||||||
version_added: "0.11.0"
|
version_added: 0.11.0
|
||||||
|
|
||||||
author:
|
author:
|
||||||
- Lucas Boisserie (@LucasBoisserie)
|
- Lucas Boisserie (@LucasBoisserie)
|
||||||
@@ -76,12 +76,12 @@ options:
|
|||||||
description:
|
description:
|
||||||
- Provide a URL for accessing the API. Can also be specified via C(K8S_AUTH_HOST) environment variable.
|
- Provide a URL for accessing the API. Can also be specified via C(K8S_AUTH_HOST) environment variable.
|
||||||
type: str
|
type: str
|
||||||
version_added: "2.3.0"
|
version_added: 2.3.0
|
||||||
api_key:
|
api_key:
|
||||||
description:
|
description:
|
||||||
- Token used to authenticate with the API. Can also be specified via C(K8S_AUTH_API_KEY) environment variable.
|
- Token used to authenticate with the API. Can also be specified via C(K8S_AUTH_API_KEY) environment variable.
|
||||||
type: str
|
type: str
|
||||||
version_added: "2.3.0"
|
version_added: 2.3.0
|
||||||
validate_certs:
|
validate_certs:
|
||||||
description:
|
description:
|
||||||
- Whether or not to verify the API server's SSL certificates. Can also be specified via C(K8S_AUTH_VERIFY_SSL)
|
- Whether or not to verify the API server's SSL certificates. Can also be specified via C(K8S_AUTH_VERIFY_SSL)
|
||||||
@@ -89,21 +89,21 @@ options:
|
|||||||
type: bool
|
type: bool
|
||||||
aliases: [ verify_ssl ]
|
aliases: [ verify_ssl ]
|
||||||
default: True
|
default: True
|
||||||
version_added: "2.3.0"
|
version_added: 2.3.0
|
||||||
ca_cert:
|
ca_cert:
|
||||||
description:
|
description:
|
||||||
- Path to a CA certificate used to authenticate with the API. The full certificate chain must be provided to
|
- Path to a CA certificate used to authenticate with the API. The full certificate chain must be provided to
|
||||||
avoid certificate validation errors. Can also be specified via C(K8S_AUTH_SSL_CA_CERT) environment variable.
|
avoid certificate validation errors. Can also be specified via C(K8S_AUTH_SSL_CA_CERT) environment variable.
|
||||||
type: path
|
type: path
|
||||||
aliases: [ ssl_ca_cert ]
|
aliases: [ ssl_ca_cert ]
|
||||||
version_added: "2.3.0"
|
version_added: 2.3.0
|
||||||
context:
|
context:
|
||||||
description:
|
description:
|
||||||
- Helm option to specify which kubeconfig context to use.
|
- Helm option to specify which kubeconfig context to use.
|
||||||
- If the value is not specified in the task, the value of environment variable C(K8S_AUTH_CONTEXT) will be used instead.
|
- If the value is not specified in the task, the value of environment variable C(K8S_AUTH_CONTEXT) will be used instead.
|
||||||
type: str
|
type: str
|
||||||
aliases: [ kube_context ]
|
aliases: [ kube_context ]
|
||||||
version_added: "2.4.0"
|
version_added: 2.4.0
|
||||||
kubeconfig:
|
kubeconfig:
|
||||||
description:
|
description:
|
||||||
- Helm option to specify kubeconfig path to use.
|
- Helm option to specify kubeconfig path to use.
|
||||||
@@ -111,14 +111,14 @@ options:
|
|||||||
- The configuration can be provided as dictionary.
|
- The configuration can be provided as dictionary.
|
||||||
type: raw
|
type: raw
|
||||||
aliases: [ kubeconfig_path ]
|
aliases: [ kubeconfig_path ]
|
||||||
version_added: "2.4.0"
|
version_added: 2.4.0
|
||||||
force_update:
|
force_update:
|
||||||
description:
|
description:
|
||||||
- Whether or not to replace (overwrite) the repo if it already exists.
|
- Whether or not to replace (overwrite) the repo if it already exists.
|
||||||
type: bool
|
type: bool
|
||||||
aliases: [ force ]
|
aliases: [ force ]
|
||||||
default: False
|
default: False
|
||||||
version_added: "2.4.0"
|
version_added: 2.4.0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = r"""
|
EXAMPLES = r"""
|
||||||
@@ -166,8 +166,8 @@ msg:
|
|||||||
sample: 'Repository already have a repository named bitnami'
|
sample: 'Repository already have a repository named bitnami'
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import traceback
|
|
||||||
import copy
|
import copy
|
||||||
|
import traceback
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import yaml
|
import yaml
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ options:
|
|||||||
default: false
|
default: false
|
||||||
type: bool
|
type: bool
|
||||||
aliases: [ dep_up ]
|
aliases: [ dep_up ]
|
||||||
version_added: "2.4.0"
|
version_added: 2.4.0
|
||||||
disable_hook:
|
disable_hook:
|
||||||
description:
|
description:
|
||||||
- Prevent hooks from running during install.
|
- Prevent hooks from running during install.
|
||||||
@@ -139,7 +139,7 @@ options:
|
|||||||
- string
|
- string
|
||||||
- json
|
- json
|
||||||
- file
|
- file
|
||||||
version_added: '2.4.0'
|
version_added: 2.4.0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = r"""
|
EXAMPLES = r"""
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ options:
|
|||||||
C(['strategic-merge', 'merge']), which is ideal for using the same parameters on resource kinds that
|
C(['strategic-merge', 'merge']), which is ideal for using the same parameters on resource kinds that
|
||||||
combine Custom Resources and built-in resources.
|
combine Custom Resources and built-in resources.
|
||||||
- mutually exclusive with C(apply)
|
- mutually exclusive with C(apply)
|
||||||
- I(merge_type=json) is deprecated and will be removed in version 3.0.0. Please use M(kubernetes.core.k8s_json_patch) instead.
|
- I(merge_type=json) is deprecated and will be removed in version 4.0.0. Please use M(kubernetes.core.k8s_json_patch) instead.
|
||||||
choices:
|
choices:
|
||||||
- json
|
- json
|
||||||
- merge
|
- merge
|
||||||
@@ -172,10 +172,31 @@ options:
|
|||||||
- When set to True, server-side apply will force the changes against conflicts.
|
- When set to True, server-side apply will force the changes against conflicts.
|
||||||
type: bool
|
type: bool
|
||||||
default: False
|
default: False
|
||||||
|
delete_all:
|
||||||
|
description:
|
||||||
|
- When this option is set to I(true) and I(state=absent),
|
||||||
|
module will delete all resources of the specified resource type in the requested namespace.
|
||||||
|
- Ignored when C(state) is not set to I(absent) or when one of (src),
|
||||||
|
C(name) or C(resource_definition) is provided.
|
||||||
|
- Parameter C(kind) is required to use this option.
|
||||||
|
- This parameter can be used with C(label_selectors) to restrict the resources to be deleted.
|
||||||
|
type: bool
|
||||||
|
default: false
|
||||||
|
version_added: 3.0.0
|
||||||
|
aliases:
|
||||||
|
- all
|
||||||
|
hidden_fields:
|
||||||
|
description:
|
||||||
|
- Hide fields matching this option in the result
|
||||||
|
- An example might be C(hidden_fields=[metadata.managedFields])
|
||||||
|
- Only field definitions that don't reference list items are supported (so V(spec.containers[0]) would not work)
|
||||||
|
type: list
|
||||||
|
elements: str
|
||||||
|
version_added: 3.0.0
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "python >= 3.6"
|
- "python >= 3.9"
|
||||||
- "kubernetes >= 12.0.0"
|
- "kubernetes >= 24.2.0"
|
||||||
- "PyYAML >= 3.11"
|
- "PyYAML >= 3.11"
|
||||||
- "jsonpatch"
|
- "jsonpatch"
|
||||||
"""
|
"""
|
||||||
@@ -343,6 +364,14 @@ EXAMPLES = r"""
|
|||||||
apply: yes
|
apply: yes
|
||||||
server_side_apply:
|
server_side_apply:
|
||||||
field_manager: ansible
|
field_manager: ansible
|
||||||
|
|
||||||
|
# Delete all Deployment from specified namespace
|
||||||
|
- name: Delete all Deployment from specified namespace
|
||||||
|
kubernetes.core.k8s:
|
||||||
|
api_version: apps/v1
|
||||||
|
namespace: testing
|
||||||
|
kind: Deployment
|
||||||
|
delete_all: true
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = r"""
|
RETURN = r"""
|
||||||
@@ -394,10 +423,10 @@ from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule impo
|
|||||||
)
|
)
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
|
||||||
AUTH_ARG_SPEC,
|
AUTH_ARG_SPEC,
|
||||||
WAIT_ARG_SPEC,
|
DELETE_OPTS_ARG_SPEC,
|
||||||
NAME_ARG_SPEC,
|
NAME_ARG_SPEC,
|
||||||
RESOURCE_ARG_SPEC,
|
RESOURCE_ARG_SPEC,
|
||||||
DELETE_OPTS_ARG_SPEC,
|
WAIT_ARG_SPEC,
|
||||||
)
|
)
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import (
|
||||||
AnsibleK8SModule,
|
AnsibleK8SModule,
|
||||||
@@ -450,6 +479,8 @@ def argspec():
|
|||||||
argument_spec["server_side_apply"] = dict(
|
argument_spec["server_side_apply"] = dict(
|
||||||
type="dict", default=None, options=server_apply_spec()
|
type="dict", default=None, options=server_apply_spec()
|
||||||
)
|
)
|
||||||
|
argument_spec["delete_all"] = dict(type="bool", default=False, aliases=["all"])
|
||||||
|
argument_spec["hidden_fields"] = dict(type="list", elements="str")
|
||||||
|
|
||||||
return argument_spec
|
return argument_spec
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ __metaclass__ = type
|
|||||||
DOCUMENTATION = r"""
|
DOCUMENTATION = r"""
|
||||||
module: k8s_cluster_info
|
module: k8s_cluster_info
|
||||||
|
|
||||||
version_added: "0.11.1"
|
version_added: 0.11.1
|
||||||
|
|
||||||
short_description: Describe Kubernetes (K8s) cluster, APIs available and their respective versions
|
short_description: Describe Kubernetes (K8s) cluster, APIs available and their respective versions
|
||||||
|
|
||||||
@@ -34,8 +34,8 @@ extends_documentation_fragment:
|
|||||||
- kubernetes.core.k8s_auth_options
|
- kubernetes.core.k8s_auth_options
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "python >= 3.6"
|
- "python >= 3.9"
|
||||||
- "kubernetes >= 12.0.0"
|
- "kubernetes >= 24.2.0"
|
||||||
- "PyYAML >= 3.11"
|
- "PyYAML >= 3.11"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -154,15 +154,15 @@ except ImportError:
|
|||||||
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
|
||||||
AnsibleModule,
|
AnsibleModule,
|
||||||
)
|
)
|
||||||
|
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
|
||||||
|
AUTH_ARG_SPEC,
|
||||||
|
)
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import (
|
||||||
AnsibleK8SModule,
|
AnsibleK8SModule,
|
||||||
)
|
)
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
|
||||||
CoreException,
|
CoreException,
|
||||||
)
|
)
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
|
|
||||||
AUTH_ARG_SPEC,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def execute_module(module, client):
|
def execute_module(module, client):
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ module: k8s_cp
|
|||||||
|
|
||||||
short_description: Copy files and directories to and from pod.
|
short_description: Copy files and directories to and from pod.
|
||||||
|
|
||||||
version_added: "2.2.0"
|
version_added: 2.2.0
|
||||||
|
|
||||||
author:
|
author:
|
||||||
- Aubin Bikouo (@abikouo)
|
- Aubin Bikouo (@abikouo)
|
||||||
@@ -26,8 +26,8 @@ extends_documentation_fragment:
|
|||||||
- kubernetes.core.k8s_auth_options
|
- kubernetes.core.k8s_auth_options
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "python >= 3.6"
|
- "python >= 3.9"
|
||||||
- "kubernetes >= 12.0.0"
|
- "kubernetes >= 24.2.0"
|
||||||
|
|
||||||
options:
|
options:
|
||||||
namespace:
|
namespace:
|
||||||
@@ -139,9 +139,18 @@ result:
|
|||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
|
from ansible.module_utils._text import to_native
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
|
||||||
AnsibleModule,
|
AnsibleModule,
|
||||||
)
|
)
|
||||||
|
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
|
||||||
|
AUTH_ARG_SPEC,
|
||||||
|
)
|
||||||
|
from ansible_collections.kubernetes.core.plugins.module_utils.copy import (
|
||||||
|
K8SCopyFromPod,
|
||||||
|
K8SCopyToPod,
|
||||||
|
check_pod,
|
||||||
|
)
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
|
||||||
get_api_client,
|
get_api_client,
|
||||||
)
|
)
|
||||||
@@ -155,16 +164,6 @@ from ansible_collections.kubernetes.core.plugins.module_utils.k8s.service import
|
|||||||
K8sService,
|
K8sService,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
|
|
||||||
AUTH_ARG_SPEC,
|
|
||||||
)
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.copy import (
|
|
||||||
K8SCopyFromPod,
|
|
||||||
K8SCopyToPod,
|
|
||||||
check_pod,
|
|
||||||
)
|
|
||||||
from ansible.module_utils._text import to_native
|
|
||||||
|
|
||||||
|
|
||||||
def argspec():
|
def argspec():
|
||||||
argument_spec = copy.deepcopy(AUTH_ARG_SPEC)
|
argument_spec = copy.deepcopy(AUTH_ARG_SPEC)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ module: k8s_drain
|
|||||||
|
|
||||||
short_description: Drain, Cordon, or Uncordon node in k8s cluster
|
short_description: Drain, Cordon, or Uncordon node in k8s cluster
|
||||||
|
|
||||||
version_added: "2.2.0"
|
version_added: 2.2.0
|
||||||
|
|
||||||
author: Aubin Bikouo (@abikouo)
|
author: Aubin Bikouo (@abikouo)
|
||||||
|
|
||||||
@@ -41,12 +41,21 @@ options:
|
|||||||
- The name of the node.
|
- The name of the node.
|
||||||
required: true
|
required: true
|
||||||
type: str
|
type: str
|
||||||
|
pod_selectors:
|
||||||
|
description:
|
||||||
|
- Label selector to filter pods on the node.
|
||||||
|
- This option has effect only when C(state) is set to I(drain).
|
||||||
|
type: list
|
||||||
|
elements: str
|
||||||
|
version_added: 3.0.0
|
||||||
|
aliases:
|
||||||
|
- label_selectors
|
||||||
delete_options:
|
delete_options:
|
||||||
type: dict
|
type: dict
|
||||||
|
default: {}
|
||||||
description:
|
description:
|
||||||
- Specify options to delete pods.
|
- Specify options to delete pods.
|
||||||
- This option has effect only when C(state) is set to I(drain).
|
- This option has effect only when C(state) is set to I(drain).
|
||||||
default: {}
|
|
||||||
suboptions:
|
suboptions:
|
||||||
terminate_grace_period:
|
terminate_grace_period:
|
||||||
description:
|
description:
|
||||||
@@ -88,8 +97,8 @@ options:
|
|||||||
type: int
|
type: int
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- python >= 3.6
|
- python >= 3.9
|
||||||
- kubernetes >= 12.0.0
|
- kubernetes >= 24.2.0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = r"""
|
EXAMPLES = r"""
|
||||||
@@ -115,6 +124,14 @@ EXAMPLES = r"""
|
|||||||
kubernetes.core.k8s_drain:
|
kubernetes.core.k8s_drain:
|
||||||
state: cordon
|
state: cordon
|
||||||
name: foo
|
name: foo
|
||||||
|
|
||||||
|
- name: Drain node "foo" using label selector to filter the list of pods to be drained.
|
||||||
|
kubernetes.core.k8s_drain:
|
||||||
|
state: drain
|
||||||
|
name: foo
|
||||||
|
pod_selectors:
|
||||||
|
- 'app!=csi-attacher'
|
||||||
|
- 'app!=csi-provisioner'
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = r"""
|
RETURN = r"""
|
||||||
@@ -126,10 +143,12 @@ result:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
import json
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
from ansible.module_utils._text import to_native
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
|
||||||
AnsibleModule,
|
AnsibleModule,
|
||||||
)
|
)
|
||||||
@@ -146,12 +165,10 @@ from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions imp
|
|||||||
CoreException,
|
CoreException,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ansible.module_utils._text import to_native
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from kubernetes.client.api import core_v1_api
|
from kubernetes.client.api import core_v1_api
|
||||||
from kubernetes.client.models import V1DeleteOptions, V1ObjectMeta
|
|
||||||
from kubernetes.client.exceptions import ApiException
|
from kubernetes.client.exceptions import ApiException
|
||||||
|
from kubernetes.client.models import V1DeleteOptions, V1ObjectMeta
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# ImportError are managed by the common module already.
|
# ImportError are managed by the common module already.
|
||||||
pass
|
pass
|
||||||
@@ -171,6 +188,17 @@ except ImportError:
|
|||||||
HAS_EVICTION_API = False
|
HAS_EVICTION_API = False
|
||||||
|
|
||||||
|
|
||||||
|
def format_dynamic_api_exc(exc):
|
||||||
|
if exc.body:
|
||||||
|
if exc.headers and exc.headers.get("Content-Type") == "application/json":
|
||||||
|
message = json.loads(exc.body).get("message")
|
||||||
|
if message:
|
||||||
|
return message
|
||||||
|
return exc.body
|
||||||
|
else:
|
||||||
|
return "%s Reason: %s" % (exc.status, exc.reason)
|
||||||
|
|
||||||
|
|
||||||
def filter_pods(pods, force, ignore_daemonset, delete_emptydir_data):
|
def filter_pods(pods, force, ignore_daemonset, delete_emptydir_data):
|
||||||
k8s_kind_mirror = "kubernetes.io/config.mirror"
|
k8s_kind_mirror = "kubernetes.io/config.mirror"
|
||||||
daemonSet, unmanaged, mirror, localStorage, to_delete = [], [], [], [], []
|
daemonSet, unmanaged, mirror, localStorage, to_delete = [], [], [], [], []
|
||||||
@@ -275,16 +303,19 @@ class K8sDrainAnsible(object):
|
|||||||
return (datetime.now() - start).seconds
|
return (datetime.now() - start).seconds
|
||||||
|
|
||||||
response = None
|
response = None
|
||||||
pod = pods.pop()
|
pod = None
|
||||||
while (_elapsed_time() < wait_timeout or wait_timeout == 0) and pods:
|
while (_elapsed_time() < wait_timeout or wait_timeout == 0) and pods:
|
||||||
if not pod:
|
if not pod:
|
||||||
pod = pods.pop()
|
pod = pods[-1]
|
||||||
try:
|
try:
|
||||||
response = self._api_instance.read_namespaced_pod(
|
response = self._api_instance.read_namespaced_pod(
|
||||||
namespace=pod[0], name=pod[1]
|
namespace=pod[0], name=pod[1]
|
||||||
)
|
)
|
||||||
if not response:
|
if not response or response.spec.node_name != self._module.params.get(
|
||||||
|
"name"
|
||||||
|
):
|
||||||
pod = None
|
pod = None
|
||||||
|
del pods[-1]
|
||||||
time.sleep(wait_sleep)
|
time.sleep(wait_sleep)
|
||||||
except ApiException as exc:
|
except ApiException as exc:
|
||||||
if exc.reason != "Not Found":
|
if exc.reason != "Not Found":
|
||||||
@@ -292,6 +323,7 @@ class K8sDrainAnsible(object):
|
|||||||
msg="Exception raised: {0}".format(exc.reason)
|
msg="Exception raised: {0}".format(exc.reason)
|
||||||
)
|
)
|
||||||
pod = None
|
pod = None
|
||||||
|
del pods[-1]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._module.fail_json(msg="Exception raised: {0}".format(to_native(e)))
|
self._module.fail_json(msg="Exception raised: {0}".format(to_native(e)))
|
||||||
if not pods:
|
if not pods:
|
||||||
@@ -318,7 +350,7 @@ class K8sDrainAnsible(object):
|
|||||||
if exc.reason != "Not Found":
|
if exc.reason != "Not Found":
|
||||||
self._module.fail_json(
|
self._module.fail_json(
|
||||||
msg="Failed to delete pod {0}/{1} due to: {2}".format(
|
msg="Failed to delete pod {0}/{1} due to: {2}".format(
|
||||||
namespace, name, exc.reason
|
namespace, name, to_native(format_dynamic_api_exc(exc))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
@@ -328,6 +360,17 @@ class K8sDrainAnsible(object):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def list_pods(self):
|
||||||
|
params = {
|
||||||
|
"field_selector": "spec.nodeName={name}".format(
|
||||||
|
name=self._module.params.get("name")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
pod_selectors = self._module.params.get("pod_selectors")
|
||||||
|
if pod_selectors:
|
||||||
|
params["label_selector"] = ",".join(pod_selectors)
|
||||||
|
return self._api_instance.list_pod_for_all_namespaces(**params)
|
||||||
|
|
||||||
def delete_or_evict_pods(self, node_unschedulable):
|
def delete_or_evict_pods(self, node_unschedulable):
|
||||||
# Mark node as unschedulable
|
# Mark node as unschedulable
|
||||||
result = []
|
result = []
|
||||||
@@ -350,12 +393,7 @@ class K8sDrainAnsible(object):
|
|||||||
self.patch_node(unschedulable=False)
|
self.patch_node(unschedulable=False)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
field_selector = "spec.nodeName={name}".format(
|
pod_list = self.list_pods()
|
||||||
name=self._module.params.get("name")
|
|
||||||
)
|
|
||||||
pod_list = self._api_instance.list_pod_for_all_namespaces(
|
|
||||||
field_selector=field_selector
|
|
||||||
)
|
|
||||||
# Filter pods
|
# Filter pods
|
||||||
force = self._drain_options.get("force", False)
|
force = self._drain_options.get("force", False)
|
||||||
ignore_daemonset = self._drain_options.get("ignore_daemonsets", False)
|
ignore_daemonset = self._drain_options.get("ignore_daemonsets", False)
|
||||||
@@ -406,7 +444,6 @@ class K8sDrainAnsible(object):
|
|||||||
return dict(result=" ".join(result))
|
return dict(result=" ".join(result))
|
||||||
|
|
||||||
def patch_node(self, unschedulable):
|
def patch_node(self, unschedulable):
|
||||||
|
|
||||||
body = {"spec": {"unschedulable": unschedulable}}
|
body = {"spec": {"unschedulable": unschedulable}}
|
||||||
try:
|
try:
|
||||||
self._api_instance.patch_node(
|
self._api_instance.patch_node(
|
||||||
@@ -418,7 +455,6 @@ class K8sDrainAnsible(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def execute_module(self):
|
def execute_module(self):
|
||||||
|
|
||||||
state = self._module.params.get("state")
|
state = self._module.params.get("state")
|
||||||
name = self._module.params.get("name")
|
name = self._module.params.get("name")
|
||||||
try:
|
try:
|
||||||
@@ -486,6 +522,11 @@ def argspec():
|
|||||||
wait_sleep=dict(type="int", default=5),
|
wait_sleep=dict(type="int", default=5),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
pod_selectors=dict(
|
||||||
|
type="list",
|
||||||
|
elements="str",
|
||||||
|
aliases=["label_selectors"],
|
||||||
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return argument_spec
|
return argument_spec
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ module: k8s_exec
|
|||||||
|
|
||||||
short_description: Execute command in Pod
|
short_description: Execute command in Pod
|
||||||
|
|
||||||
version_added: "0.10.0"
|
version_added: 0.10.0
|
||||||
|
|
||||||
author: "Tristan de Cacqueray (@tristanC)"
|
author: "Tristan de Cacqueray (@tristanC)"
|
||||||
|
|
||||||
@@ -26,8 +26,8 @@ extends_documentation_fragment:
|
|||||||
- kubernetes.core.k8s_auth_options
|
- kubernetes.core.k8s_auth_options
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "python >= 3.6"
|
- "python >= 3.9"
|
||||||
- "kubernetes >= 12.0.0"
|
- "kubernetes >= 24.2.0"
|
||||||
- "PyYAML >= 3.11"
|
- "PyYAML >= 3.11"
|
||||||
|
|
||||||
notes:
|
notes:
|
||||||
@@ -131,27 +131,27 @@ except ImportError:
|
|||||||
# ImportError are managed by the common module already.
|
# ImportError are managed by the common module already.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
from ansible.module_utils._text import to_native
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
|
||||||
AnsibleModule,
|
AnsibleModule,
|
||||||
)
|
)
|
||||||
from ansible.module_utils._text import to_native
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.common import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.common import (
|
||||||
AUTH_ARG_SPEC,
|
AUTH_ARG_SPEC,
|
||||||
)
|
)
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import (
|
|
||||||
AnsibleK8SModule,
|
|
||||||
)
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
|
||||||
get_api_client,
|
get_api_client,
|
||||||
)
|
)
|
||||||
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import (
|
||||||
|
AnsibleK8SModule,
|
||||||
|
)
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
|
||||||
CoreException,
|
CoreException,
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from kubernetes.client.apis import core_v1_api
|
from kubernetes.client.apis import core_v1_api
|
||||||
from kubernetes.stream import stream
|
|
||||||
from kubernetes.client.exceptions import ApiException
|
from kubernetes.client.exceptions import ApiException
|
||||||
|
from kubernetes.stream import stream
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# ImportError are managed by the common module already.
|
# ImportError are managed by the common module already.
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -44,6 +44,14 @@ options:
|
|||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
default: []
|
default: []
|
||||||
|
hidden_fields:
|
||||||
|
description:
|
||||||
|
- Hide fields matching any of the field definitions in the result
|
||||||
|
- An example might be C(hidden_fields=[metadata.managedFields])
|
||||||
|
- Only field definitions that don't reference list items are supported (so V(spec.containers[0]) would not work)
|
||||||
|
type: list
|
||||||
|
elements: str
|
||||||
|
version_added: 3.0.0
|
||||||
|
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- kubernetes.core.k8s_auth_options
|
- kubernetes.core.k8s_auth_options
|
||||||
@@ -51,8 +59,8 @@ extends_documentation_fragment:
|
|||||||
- kubernetes.core.k8s_wait_options
|
- kubernetes.core.k8s_wait_options
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "python >= 3.6"
|
- "python >= 3.9"
|
||||||
- "kubernetes >= 12.0.0"
|
- "kubernetes >= 24.2.0"
|
||||||
- "PyYAML >= 3.11"
|
- "PyYAML >= 3.11"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -157,12 +165,12 @@ from ansible_collections.kubernetes.core.plugins.module_utils.args_common import
|
|||||||
AUTH_ARG_SPEC,
|
AUTH_ARG_SPEC,
|
||||||
WAIT_ARG_SPEC,
|
WAIT_ARG_SPEC,
|
||||||
)
|
)
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import (
|
|
||||||
AnsibleK8SModule,
|
|
||||||
)
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
|
||||||
get_api_client,
|
get_api_client,
|
||||||
)
|
)
|
||||||
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import (
|
||||||
|
AnsibleK8SModule,
|
||||||
|
)
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
|
||||||
CoreException,
|
CoreException,
|
||||||
)
|
)
|
||||||
@@ -183,6 +191,7 @@ def execute_module(module, svc):
|
|||||||
wait_sleep=module.params["wait_sleep"],
|
wait_sleep=module.params["wait_sleep"],
|
||||||
wait_timeout=module.params["wait_timeout"],
|
wait_timeout=module.params["wait_timeout"],
|
||||||
condition=module.params["wait_condition"],
|
condition=module.params["wait_condition"],
|
||||||
|
hidden_fields=module.params["hidden_fields"],
|
||||||
)
|
)
|
||||||
module.exit_json(changed=False, **facts)
|
module.exit_json(changed=False, **facts)
|
||||||
|
|
||||||
@@ -198,6 +207,7 @@ def argspec():
|
|||||||
namespace=dict(),
|
namespace=dict(),
|
||||||
label_selectors=dict(type="list", elements="str", default=[]),
|
label_selectors=dict(type="list", elements="str", default=[]),
|
||||||
field_selectors=dict(type="list", elements="str", default=[]),
|
field_selectors=dict(type="list", elements="str", default=[]),
|
||||||
|
hidden_fields=dict(type="list", elements="str"),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return args
|
return args
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ extends_documentation_fragment:
|
|||||||
- kubernetes.core.k8s_wait_options
|
- kubernetes.core.k8s_wait_options
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "python >= 3.6"
|
- "python >= 3.9"
|
||||||
- "kubernetes >= 12.0.0"
|
- "kubernetes >= 24.2.0"
|
||||||
- "PyYAML >= 3.11"
|
- "PyYAML >= 3.11"
|
||||||
- "jsonpatch"
|
- "jsonpatch"
|
||||||
"""
|
"""
|
||||||
@@ -127,8 +127,8 @@ error:
|
|||||||
import copy
|
import copy
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from ansible.module_utils.basic import missing_required_lib
|
|
||||||
from ansible.module_utils._text import to_native
|
from ansible.module_utils._text import to_native
|
||||||
|
from ansible.module_utils.basic import missing_required_lib
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
|
||||||
AnsibleModule,
|
AnsibleModule,
|
||||||
)
|
)
|
||||||
@@ -152,7 +152,6 @@ from ansible_collections.kubernetes.core.plugins.module_utils.k8s.waiter import
|
|||||||
get_waiter,
|
get_waiter,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from kubernetes.dynamic.exceptions import DynamicApiError
|
from kubernetes.dynamic.exceptions import DynamicApiError
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ module: k8s_log
|
|||||||
|
|
||||||
short_description: Fetch logs from Kubernetes resources
|
short_description: Fetch logs from Kubernetes resources
|
||||||
|
|
||||||
version_added: "0.10.0"
|
version_added: 0.10.0
|
||||||
|
|
||||||
author:
|
author:
|
||||||
- "Fabian von Feilitzsch (@fabianvf)"
|
- "Fabian von Feilitzsch (@fabianvf)"
|
||||||
@@ -61,30 +61,30 @@ options:
|
|||||||
- A relative time in seconds before the current time from which to show logs.
|
- A relative time in seconds before the current time from which to show logs.
|
||||||
required: no
|
required: no
|
||||||
type: str
|
type: str
|
||||||
version_added: '2.2.0'
|
version_added: 2.2.0
|
||||||
previous:
|
previous:
|
||||||
description:
|
description:
|
||||||
- If C(true), print the logs for the previous instance of the container in a pod if it exists.
|
- If C(true), print the logs for the previous instance of the container in a pod if it exists.
|
||||||
required: no
|
required: no
|
||||||
type: bool
|
type: bool
|
||||||
default: False
|
default: False
|
||||||
version_added: '2.4.0'
|
version_added: 2.4.0
|
||||||
tail_lines:
|
tail_lines:
|
||||||
description:
|
description:
|
||||||
- A number of lines from the end of the logs to retrieve.
|
- A number of lines from the end of the logs to retrieve.
|
||||||
required: no
|
required: no
|
||||||
type: int
|
type: int
|
||||||
version_added: '2.4.0'
|
version_added: 2.4.0
|
||||||
all_containers:
|
all_containers:
|
||||||
description:
|
description:
|
||||||
- If set to C(true), retrieve all containers' logs in the pod(s).
|
- If set to C(true), retrieve all containers' logs in the pod(s).
|
||||||
- mutually exclusive with C(container).
|
- mutually exclusive with C(container).
|
||||||
type: bool
|
type: bool
|
||||||
version_added: '2.4.0'
|
version_added: 2.4.0
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "python >= 3.6"
|
- "python >= 3.9"
|
||||||
- "kubernetes >= 12.0.0"
|
- "kubernetes >= 24.2.0"
|
||||||
- "PyYAML >= 3.11"
|
- "PyYAML >= 3.11"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ __metaclass__ = type
|
|||||||
DOCUMENTATION = r"""
|
DOCUMENTATION = r"""
|
||||||
module: k8s_rollback
|
module: k8s_rollback
|
||||||
short_description: Rollback Kubernetes (K8S) Deployments and DaemonSets
|
short_description: Rollback Kubernetes (K8S) Deployments and DaemonSets
|
||||||
version_added: "1.0.0"
|
version_added: 1.0.0
|
||||||
author:
|
author:
|
||||||
- "Julien Huon (@julienhuon)"
|
- "Julien Huon (@julienhuon)"
|
||||||
description:
|
description:
|
||||||
@@ -34,8 +34,8 @@ extends_documentation_fragment:
|
|||||||
- kubernetes.core.k8s_auth_options
|
- kubernetes.core.k8s_auth_options
|
||||||
- kubernetes.core.k8s_name_options
|
- kubernetes.core.k8s_name_options
|
||||||
requirements:
|
requirements:
|
||||||
- "python >= 3.6"
|
- "python >= 3.9"
|
||||||
- "kubernetes >= 12.0.0"
|
- "kubernetes >= 24.2.0"
|
||||||
- "PyYAML >= 3.11"
|
- "PyYAML >= 3.11"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
@@ -46,8 +45,8 @@ options:
|
|||||||
version_added: 2.0.0
|
version_added: 2.0.0
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "python >= 3.6"
|
- "python >= 3.9"
|
||||||
- "kubernetes >= 12.0.0"
|
- "kubernetes >= 24.2.0"
|
||||||
- "PyYAML >= 3.11"
|
- "PyYAML >= 3.11"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -151,14 +150,13 @@ except ImportError:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
from ansible.module_utils._text import to_native
|
from ansible.module_utils._text import to_native
|
||||||
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
|
||||||
AnsibleModule,
|
AnsibleModule,
|
||||||
)
|
)
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
|
||||||
AUTH_ARG_SPEC,
|
AUTH_ARG_SPEC,
|
||||||
RESOURCE_ARG_SPEC,
|
|
||||||
NAME_ARG_SPEC,
|
NAME_ARG_SPEC,
|
||||||
|
RESOURCE_ARG_SPEC,
|
||||||
)
|
)
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
|
||||||
get_api_client,
|
get_api_client,
|
||||||
@@ -170,15 +168,15 @@ from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions imp
|
|||||||
CoreException,
|
CoreException,
|
||||||
ResourceTimeout,
|
ResourceTimeout,
|
||||||
)
|
)
|
||||||
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.resource import (
|
||||||
|
create_definitions,
|
||||||
|
)
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.service import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.service import (
|
||||||
diff_objects,
|
diff_objects,
|
||||||
)
|
)
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.waiter import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.waiter import (
|
||||||
get_waiter,
|
get_waiter,
|
||||||
)
|
)
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.resource import (
|
|
||||||
create_definitions,
|
|
||||||
)
|
|
||||||
|
|
||||||
SCALE_ARG_SPEC = {
|
SCALE_ARG_SPEC = {
|
||||||
"replicas": {"type": "int", "required": True},
|
"replicas": {"type": "int", "required": True},
|
||||||
@@ -391,7 +389,7 @@ def scale(
|
|||||||
namespace=namespace,
|
namespace=namespace,
|
||||||
)
|
)
|
||||||
if not success:
|
if not success:
|
||||||
raise ResourceTimeout("Resource scaling timed out", **result)
|
raise ResourceTimeout("Resource scaling timed out", result)
|
||||||
|
|
||||||
match, diffs = diff_objects(existing.to_dict(), result["result"])
|
match, diffs = diff_objects(existing.to_dict(), result["result"])
|
||||||
result["changed"] = not match
|
result["changed"] = not match
|
||||||
|
|||||||
@@ -83,8 +83,8 @@ options:
|
|||||||
type: bool
|
type: bool
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- python >= 3.6
|
- python >= 3.9
|
||||||
- kubernetes >= 12.0.0
|
- kubernetes >= 24.2.0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = r"""
|
EXAMPLES = r"""
|
||||||
@@ -143,7 +143,6 @@ result:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
|
||||||
@@ -154,25 +153,24 @@ from ansible_collections.kubernetes.core.plugins.module_utils.args_common import
|
|||||||
COMMON_ARG_SPEC,
|
COMMON_ARG_SPEC,
|
||||||
RESOURCE_ARG_SPEC,
|
RESOURCE_ARG_SPEC,
|
||||||
)
|
)
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import (
|
|
||||||
AnsibleK8SModule,
|
|
||||||
)
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
|
||||||
get_api_client,
|
get_api_client,
|
||||||
)
|
)
|
||||||
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.core import (
|
||||||
|
AnsibleK8SModule,
|
||||||
|
)
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions import (
|
||||||
CoreException,
|
CoreException,
|
||||||
)
|
)
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.service import (
|
|
||||||
K8sService,
|
|
||||||
)
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.resource import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.resource import (
|
||||||
create_definitions,
|
create_definitions,
|
||||||
)
|
)
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.runner import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.runner import (
|
||||||
perform_action,
|
perform_action,
|
||||||
)
|
)
|
||||||
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.service import (
|
||||||
|
K8sService,
|
||||||
|
)
|
||||||
|
|
||||||
SERVICE_ARG_SPEC = {
|
SERVICE_ARG_SPEC = {
|
||||||
"apply": {"type": "bool", "default": False},
|
"apply": {"type": "bool", "default": False},
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ __metaclass__ = type
|
|||||||
DOCUMENTATION = r"""
|
DOCUMENTATION = r"""
|
||||||
module: k8s_taint
|
module: k8s_taint
|
||||||
short_description: Taint a node in a Kubernetes/OpenShift cluster
|
short_description: Taint a node in a Kubernetes/OpenShift cluster
|
||||||
version_added: "2.3.0"
|
version_added: 2.3.0
|
||||||
author: Alina Buzachis (@alinabuzachis)
|
author: Alina Buzachis (@alinabuzachis)
|
||||||
description:
|
description:
|
||||||
- Taint allows a node to refuse Pod to be scheduled unless that Pod has a matching toleration.
|
- Taint allows a node to refuse Pod to be scheduled unless that Pod has a matching toleration.
|
||||||
@@ -60,8 +60,8 @@ options:
|
|||||||
default: false
|
default: false
|
||||||
type: bool
|
type: bool
|
||||||
requirements:
|
requirements:
|
||||||
- python >= 3.6
|
- python >= 3.9
|
||||||
- kubernetes >= 12.0.0
|
- kubernetes >= 24.2.0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = r"""
|
EXAMPLES = r"""
|
||||||
@@ -127,7 +127,6 @@ result:
|
|||||||
import copy
|
import copy
|
||||||
|
|
||||||
from ansible.module_utils._text import to_native
|
from ansible.module_utils._text import to_native
|
||||||
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
|
||||||
AnsibleModule,
|
AnsibleModule,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
kubernetes>=12.0.0
|
kubernetes>=24.2.0
|
||||||
requests-oauthlib
|
requests-oauthlib
|
||||||
jsonpatch
|
jsonpatch
|
||||||
|
|||||||
@@ -24,3 +24,5 @@ test_namespace:
|
|||||||
- "helm-local-path-003"
|
- "helm-local-path-003"
|
||||||
- "helm-from-repository"
|
- "helm-from-repository"
|
||||||
- "helm-from-url"
|
- "helm-from-url"
|
||||||
|
- "helm-reuse-values"
|
||||||
|
- "helm-chart-with-space-into-name"
|
||||||
|
|||||||
130
tests/integration/targets/helm/library/helm_test_pending.py
Normal file
130
tests/integration/targets/helm/library/helm_test_pending.py
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright: (c) 2023, Ansible Project
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
|
DOCUMENTATION = r"""
|
||||||
|
---
|
||||||
|
module: helm_test_pending
|
||||||
|
short_description: created pending-install release
|
||||||
|
author:
|
||||||
|
- Aubin Bikouo (@abikouo)
|
||||||
|
requirements:
|
||||||
|
- "helm (https://github.com/helm/helm/releases)"
|
||||||
|
description:
|
||||||
|
- This module is used to create a pending install release for integration testing
|
||||||
|
- The scope of this module is the integration testing of the kubernetes.core collection only.
|
||||||
|
options:
|
||||||
|
binary_path:
|
||||||
|
description:
|
||||||
|
- The path of a helm binary to use.
|
||||||
|
required: true
|
||||||
|
type: path
|
||||||
|
chart_ref:
|
||||||
|
description:
|
||||||
|
- chart reference on chart repository (e.g. my-repo/my-chart-ref)
|
||||||
|
required: true
|
||||||
|
type: str
|
||||||
|
chart_release:
|
||||||
|
description:
|
||||||
|
- Release name to manage.
|
||||||
|
required: true
|
||||||
|
type: str
|
||||||
|
chart_release_namespace:
|
||||||
|
description:
|
||||||
|
- Kubernetes namespace where the chart should be installed.
|
||||||
|
required: true
|
||||||
|
type: str
|
||||||
|
"""
|
||||||
|
|
||||||
|
EXAMPLES = r"""
|
||||||
|
"""
|
||||||
|
|
||||||
|
RETURN = r"""
|
||||||
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
|
import subprocess
|
||||||
|
import time
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
||||||
|
class HelmReleaseNotFoundError(Exception):
|
||||||
|
def __init__(self, message):
|
||||||
|
super().__init__(message)
|
||||||
|
|
||||||
|
|
||||||
|
def create_pending_install_release(helm_binary, chart_ref, chart_release, namespace):
|
||||||
|
# create pending-install release
|
||||||
|
command = [
|
||||||
|
helm_binary,
|
||||||
|
"install",
|
||||||
|
chart_release,
|
||||||
|
chart_ref,
|
||||||
|
"--namespace",
|
||||||
|
namespace,
|
||||||
|
"--wait",
|
||||||
|
]
|
||||||
|
proc = subprocess.Popen(command)
|
||||||
|
time.sleep(2)
|
||||||
|
proc.kill()
|
||||||
|
# ensure release status is pending-install
|
||||||
|
command = [
|
||||||
|
helm_binary,
|
||||||
|
"list",
|
||||||
|
"--all",
|
||||||
|
"--output=json",
|
||||||
|
"--namespace",
|
||||||
|
namespace,
|
||||||
|
"--filter",
|
||||||
|
chart_release,
|
||||||
|
]
|
||||||
|
cmd = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
out, err = cmd.communicate()
|
||||||
|
|
||||||
|
data = json.loads(out)
|
||||||
|
if not data:
|
||||||
|
error = "Release %s not found." % chart_release
|
||||||
|
raise HelmReleaseNotFoundError(message=error)
|
||||||
|
return data[0]["status"] == "pending-install", data[0]["status"]
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
module = AnsibleModule(
|
||||||
|
argument_spec=dict(
|
||||||
|
binary_path=dict(type="path", required=True),
|
||||||
|
chart_ref=dict(type="str", required=True),
|
||||||
|
chart_release=dict(type="str", required=True),
|
||||||
|
chart_release_namespace=dict(type="str", required=True),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
params = dict(
|
||||||
|
helm_binary=module.params.get("binary_path"),
|
||||||
|
chart_release=module.params.get("chart_release"),
|
||||||
|
chart_ref=module.params.get("chart_ref"),
|
||||||
|
namespace=module.params.get("chart_release_namespace"),
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
result, status = create_pending_install_release(**params)
|
||||||
|
if not result:
|
||||||
|
module.fail_json(
|
||||||
|
msg="unable to create pending-install release, current status is %s"
|
||||||
|
% status
|
||||||
|
)
|
||||||
|
module.exit_json(changed=True, msg="Release created with status '%s'" % status)
|
||||||
|
except HelmReleaseNotFoundError as err:
|
||||||
|
module.fail_json(
|
||||||
|
msg="Error while trying to create pending-install release due to '%s'" % err
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -52,12 +52,12 @@ result:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.version import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.version import (
|
||||||
LooseVersion,
|
LooseVersion,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
|
|||||||
7
tests/integration/targets/helm/playbook.yaml
Normal file
7
tests/integration/targets/helm/playbook.yaml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
- connection: local
|
||||||
|
gather_facts: true
|
||||||
|
hosts: localhost
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- helm
|
||||||
5
tests/integration/targets/helm/runme.sh
Executable file
5
tests/integration/targets/helm/runme.sh
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -eux
|
||||||
|
export ANSIBLE_CALLBACKS_ENABLED=profile_tasks
|
||||||
|
export ANSIBLE_ROLES_PATH=../
|
||||||
|
ansible-playbook playbook.yaml "$@"
|
||||||
@@ -4,4 +4,4 @@
|
|||||||
loop_control:
|
loop_control:
|
||||||
loop_var: helm_version
|
loop_var: helm_version
|
||||||
with_items:
|
with_items:
|
||||||
- "v3.7.0"
|
- "v3.8.0"
|
||||||
|
|||||||
@@ -25,12 +25,18 @@
|
|||||||
- from_repository
|
- from_repository
|
||||||
- from_url
|
- from_url
|
||||||
|
|
||||||
|
- name: test helm upgrade with reuse_values
|
||||||
|
include_tasks: test_helm_reuse_values.yml
|
||||||
|
|
||||||
- name: test helm dependency update
|
- name: test helm dependency update
|
||||||
include_tasks: test_up_dep.yml
|
include_tasks: test_up_dep.yml
|
||||||
|
|
||||||
- name: Test helm uninstall
|
- name: Test helm uninstall
|
||||||
include_tasks: test_helm_uninstall.yml
|
include_tasks: test_helm_uninstall.yml
|
||||||
|
|
||||||
|
- name: Test helm install with chart name containing space
|
||||||
|
include_tasks: test_helm_with_space_into_chart_name.yml
|
||||||
|
|
||||||
# https://github.com/ansible-collections/community.kubernetes/issues/296
|
# https://github.com/ansible-collections/community.kubernetes/issues/296
|
||||||
- name: Test Skip CRDS feature in helm chart install
|
- name: Test Skip CRDS feature in helm chart install
|
||||||
include_tasks: test_crds.yml
|
include_tasks: test_crds.yml
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
---
|
||||||
|
- name: Test helm reuse_values
|
||||||
|
vars:
|
||||||
|
helm_namespace: "{{ test_namespace[9] }}"
|
||||||
|
chart_release_values:
|
||||||
|
replica:
|
||||||
|
replicaCount: 3
|
||||||
|
master:
|
||||||
|
count: 1
|
||||||
|
kind: Deployment
|
||||||
|
chart_reuse_values:
|
||||||
|
replica:
|
||||||
|
replicaCount: 1
|
||||||
|
master:
|
||||||
|
count: 3
|
||||||
|
block:
|
||||||
|
- name: Initial chart installation
|
||||||
|
helm:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
|
chart_ref: oci://registry-1.docker.io/bitnamicharts/redis
|
||||||
|
release_name: test-redis
|
||||||
|
release_namespace: "{{ helm_namespace }}"
|
||||||
|
create_namespace: true
|
||||||
|
release_values: "{{ chart_release_values }}"
|
||||||
|
register: install
|
||||||
|
|
||||||
|
- name: Get value set as string
|
||||||
|
helm_info:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
|
release_name: test-redis
|
||||||
|
release_namespace: "{{ helm_namespace }}"
|
||||||
|
register: release_value
|
||||||
|
|
||||||
|
- name: Validate that chart values are as expected
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- install is changed
|
||||||
|
- '"--reuse-values=True" not in install.command'
|
||||||
|
- release_value["status"]["values"] == chart_release_values
|
||||||
|
|
||||||
|
- name: Upgrade chart using reuse_values=true
|
||||||
|
helm:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
|
chart_ref: oci://registry-1.docker.io/bitnamicharts/redis
|
||||||
|
release_name: test-redis
|
||||||
|
release_namespace: "{{ helm_namespace }}"
|
||||||
|
reuse_values: true
|
||||||
|
reset_values: false
|
||||||
|
release_values: "{{ chart_reuse_values }}"
|
||||||
|
register: upgrade
|
||||||
|
|
||||||
|
- name: Get value set as string
|
||||||
|
helm_info:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
|
release_name: test-redis
|
||||||
|
release_namespace: "{{ helm_namespace }}"
|
||||||
|
register: release_value
|
||||||
|
|
||||||
|
- name: Validate that chart values are as expected
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- upgrade is changed
|
||||||
|
- '"--reuse-values=True" in upgrade.command'
|
||||||
|
- '"--reset-values" not in upgrade.command'
|
||||||
|
- release_value["status"]["values"] == chart_release_values | combine(chart_reuse_values, recursive=true)
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: Remove helm namespace
|
||||||
|
k8s:
|
||||||
|
api_version: v1
|
||||||
|
kind: Namespace
|
||||||
|
name: "{{ helm_namespace }}"
|
||||||
|
state: absent
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user