mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-11 20:12:18 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1527469cb5 |
@@ -1,5 +0,0 @@
|
|||||||
# 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]
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
---
|
|
||||||
profile: production
|
|
||||||
|
|
||||||
exclude_paths:
|
|
||||||
- .ansible/
|
|
||||||
- tests/integration
|
|
||||||
- tests/unit
|
|
||||||
- tests/sanity
|
|
||||||
60
.github/stale.yml
vendored
Normal file
60
.github/stale.yml
vendored
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
---
|
||||||
|
# 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.
|
||||||
21
.github/workflows/changelog.yaml
vendored
21
.github/workflows/changelog.yaml
vendored
@@ -1,21 +0,0 @@
|
|||||||
---
|
|
||||||
name: Changelog
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
types:
|
|
||||||
- opened
|
|
||||||
- reopened
|
|
||||||
- labeled
|
|
||||||
- unlabeled
|
|
||||||
- synchronize
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- stable-*
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
changelog:
|
|
||||||
uses: ansible-network/github_actions/.github/workflows/changelog.yml@main
|
|
||||||
14
.github/workflows/galaxy-import.yaml
vendored
14
.github/workflows/galaxy-import.yaml
vendored
@@ -1,14 +0,0 @@
|
|||||||
name: galaxy-import
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.head_ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- stable-*
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
galaxy_importer:
|
|
||||||
uses: ansible-network/github_actions/.github/workflows/galaxy_importer.yml@main
|
|
||||||
160
.github/workflows/integration-tests.yaml
vendored
160
.github/workflows/integration-tests.yaml
vendored
@@ -1,160 +0,0 @@
|
|||||||
name: Integration tests
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
types:
|
|
||||||
- opened
|
|
||||||
- reopened
|
|
||||||
- labeled
|
|
||||||
- unlabeled
|
|
||||||
- synchronize
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- stable-*
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
splitter:
|
|
||||||
env:
|
|
||||||
source_dir: "./source"
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
test_targets: ${{ steps.splitter.outputs.test_targets }}
|
|
||||||
test_targets_json: ${{ steps.splitter.outputs.test_targets_json }}
|
|
||||||
test_jobs: ${{ steps.splitter.outputs.test_jobs }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout the collection repository
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
path: ${{ env.source_dir }}
|
|
||||||
fetch-depth: "0"
|
|
||||||
|
|
||||||
- name: list changes for pull request
|
|
||||||
id: splitter
|
|
||||||
uses: ansible-network/github_actions/.github/actions/ansible_test_splitter@main
|
|
||||||
with:
|
|
||||||
collections_to_test: ${{ env.source_dir }}
|
|
||||||
total_jobs: 8
|
|
||||||
|
|
||||||
- name: Display splitter output
|
|
||||||
run: |
|
|
||||||
echo "test_targets=${{ steps.splitter.outputs.test_targets }}"
|
|
||||||
echo "test_targets_json=${{ steps.splitter.outputs.test_targets_json }}"
|
|
||||||
echo "test_jobs=${{ steps.splitter.outputs.test_jobs }}"
|
|
||||||
shell: bash
|
|
||||||
integration:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
timeout-minutes: 60
|
|
||||||
needs:
|
|
||||||
- splitter
|
|
||||||
if: ${{ needs.splitter.outputs.test_targets != '' }}
|
|
||||||
env:
|
|
||||||
source: "./source"
|
|
||||||
cloud_common: "./cloudcommon"
|
|
||||||
ansible_posix: "./ansible_posix"
|
|
||||||
community_general: "./community_general"
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
ansible-version:
|
|
||||||
- milestone
|
|
||||||
python-version:
|
|
||||||
- "3.12"
|
|
||||||
enable-turbo-mode:
|
|
||||||
- true
|
|
||||||
- false
|
|
||||||
workflow-id: ${{ fromJson(needs.splitter.outputs.test_jobs) }}
|
|
||||||
name: "integration-py${{ matrix.python-version }}-${{ matrix.ansible-version }}-${{ matrix.workflow-id }}-enable_turbo=${{ matrix.enable-turbo-mode }}"
|
|
||||||
steps:
|
|
||||||
- name: Read target
|
|
||||||
id: read-targets
|
|
||||||
run: |
|
|
||||||
import json, os
|
|
||||||
with open(os.environ.get('GITHUB_OUTPUT'), "a", encoding="utf-8") as fh:
|
|
||||||
fh.write(f'ansible_test_targets={json.loads(os.environ.get("ALL_TEST_TARGETS")).get(os.environ.get("WORKFLOW_ID"))}\n')
|
|
||||||
shell: python
|
|
||||||
env:
|
|
||||||
ALL_TEST_TARGETS: ${{ needs.splitter.outputs.test_targets_json }}
|
|
||||||
WORKFLOW_ID: ${{ matrix.workflow-id }}
|
|
||||||
|
|
||||||
- name: Display ansible test targets
|
|
||||||
run: |
|
|
||||||
echo "ansible_test_targets -> ${{ steps.read-targets.outputs.ansible_test_targets }}"
|
|
||||||
|
|
||||||
- name: Checkout kubernetes.core repository
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
path: ${{ env.source }}
|
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
|
||||||
|
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
|
||||||
uses: actions/setup-python@v4
|
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.python-version }}
|
|
||||||
|
|
||||||
# install ansible
|
|
||||||
- name: Install ansible-core (${{ matrix.ansible-version }})
|
|
||||||
run: >-
|
|
||||||
python3 -m pip install
|
|
||||||
https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz
|
|
||||||
--disable-pip-version-check
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Build and install collection
|
|
||||||
id: install-src
|
|
||||||
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
|
|
||||||
with:
|
|
||||||
install_python_dependencies: true
|
|
||||||
source_path: ${{ env.source }}
|
|
||||||
|
|
||||||
- name: checkout ansible-collections/cloud.common
|
|
||||||
uses: ansible-network/github_actions/.github/actions/checkout_dependency@main
|
|
||||||
with:
|
|
||||||
repository: ansible-collections/cloud.common
|
|
||||||
path: ${{ env.cloud_common }}
|
|
||||||
ref: main
|
|
||||||
|
|
||||||
- name: checkout ansible-collections/ansible.posix
|
|
||||||
uses: ansible-network/github_actions/.github/actions/checkout_dependency@main
|
|
||||||
with:
|
|
||||||
repository: ansible-collections/ansible.posix
|
|
||||||
path: ${{ env.ansible_posix }}
|
|
||||||
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
|
|
||||||
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
|
|
||||||
with:
|
|
||||||
install_python_dependencies: true
|
|
||||||
source_path: ${{ env.cloud_common }}
|
|
||||||
|
|
||||||
- name: install ansible.posix collection
|
|
||||||
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
|
|
||||||
with:
|
|
||||||
install_python_dependencies: true
|
|
||||||
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
|
|
||||||
uses: helm/kind-action@v1.8.0
|
|
||||||
with:
|
|
||||||
node_image: "kindest/node:v1.29.2"
|
|
||||||
|
|
||||||
- name: Run integration tests
|
|
||||||
uses: ansible-network/github_actions/.github/actions/ansible_test_integration@main
|
|
||||||
with:
|
|
||||||
collection_path: ${{ steps.install-src.outputs.collection_path }}
|
|
||||||
python_version: ${{ matrix.python-version }}
|
|
||||||
ansible_version: ${{ matrix.ansible-version }}
|
|
||||||
ansible_test_targets: ${{ steps.read-targets.outputs.ansible_test_targets }}
|
|
||||||
ansible_test_environment: |
|
|
||||||
ENABLE_TURBO_MODE=${{ matrix.enable-turbo-mode }}
|
|
||||||
23
.github/workflows/linters.yaml
vendored
23
.github/workflows/linters.yaml
vendored
@@ -1,23 +0,0 @@
|
|||||||
---
|
|
||||||
name: Linters
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- stable-*
|
|
||||||
tags:
|
|
||||||
- '*'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
linters:
|
|
||||||
uses: ansible-network/github_actions/.github/workflows/tox-linters.yml@main
|
|
||||||
ansible-lint:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: run-ansible-lint
|
|
||||||
uses: ansible/ansible-lint@v25.1.2
|
|
||||||
15
.github/workflows/sanity-tests.yaml
vendored
15
.github/workflows/sanity-tests.yaml
vendored
@@ -1,15 +0,0 @@
|
|||||||
---
|
|
||||||
name: Sanity tests
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- stable-*
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
sanity:
|
|
||||||
uses: ansible-network/github_actions/.github/workflows/sanity.yml@main
|
|
||||||
14
.github/workflows/unit-tests.yaml
vendored
14
.github/workflows/unit-tests.yaml
vendored
@@ -1,14 +0,0 @@
|
|||||||
name: Unit tests
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- stable-*
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
unit-source:
|
|
||||||
uses: ansible-network/github_actions/.github/workflows/unit_source.yml@main
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -13,7 +13,6 @@ 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,24 +5,16 @@ 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
|
||||||
|
|||||||
233
CHANGELOG.rst
233
CHANGELOG.rst
@@ -4,237 +4,6 @@ Kubernetes Collection Release Notes
|
|||||||
|
|
||||||
.. contents:: Topics
|
.. contents:: Topics
|
||||||
|
|
||||||
v5.3.0
|
|
||||||
======
|
|
||||||
|
|
||||||
Release Summary
|
|
||||||
---------------
|
|
||||||
|
|
||||||
This release includes minor changes, bug fixes and also bumps ``ansible-lint`` version to ``25.1.2``.
|
|
||||||
|
|
||||||
Minor Changes
|
|
||||||
-------------
|
|
||||||
|
|
||||||
- kubernetes.core - Bump version of ``ansible-lint`` to ``25.1.2`` (https://github.com/ansible-collections/kubernetes.core/pull/919).
|
|
||||||
- action/k8s_info - update templating mechanism with changes from ``ansible-core 2.19`` (https://github.com/ansible-collections/kubernetes.core/pull/888).
|
|
||||||
- helm - add ``reset_then_reuse_values`` support to helm module (https://github.com/ansible-collections/kubernetes.core/issues/803).
|
|
||||||
- helm - add support for ``insecure_skip_tls_verify`` option to helm and ``helm_repository`` (https://github.com/ansible-collections/kubernetes.core/issues/694).
|
|
||||||
|
|
||||||
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).
|
|
||||||
|
|
||||||
v5.2.0
|
|
||||||
======
|
|
||||||
|
|
||||||
Release Summary
|
|
||||||
---------------
|
|
||||||
|
|
||||||
This release adds more functionality to the hidden_fields option and support for waiting on ClusterOperators to reach a ready state.
|
|
||||||
|
|
||||||
Minor Changes
|
|
||||||
-------------
|
|
||||||
|
|
||||||
- k8s - Extend hidden_fields to allow the expression of more complex field types to be hidden (https://github.com/ansible-collections/kubernetes.core/pull/872)
|
|
||||||
- k8s_info - Extend hidden_fields to allow the expression of more complex field types to be hidden (https://github.com/ansible-collections/kubernetes.core/pull/872)
|
|
||||||
- waiter.py - add ClusterOperator support. The module can now check OpenShift cluster health by verifying ClusterOperator status requiring 'Available: True', 'Degraded: False', and 'Progressing: False' for success. (https://github.com/ansible-collections/kubernetes.core/issues/869)
|
|
||||||
|
|
||||||
v5.1.0
|
|
||||||
======
|
|
||||||
|
|
||||||
Release Summary
|
|
||||||
---------------
|
|
||||||
|
|
||||||
This release came with new module ``helm_registry_auth``, improvements to the error messages in the k8s_drain module, new parameter ``insecure_registry`` for ``helm_template`` module and several bug fixes.
|
|
||||||
|
|
||||||
Minor Changes
|
|
||||||
-------------
|
|
||||||
|
|
||||||
- Bump version of ansible-lint to minimum 24.7.0 (https://github.com/ansible-collections/kubernetes.core/pull/765).
|
|
||||||
- Parameter insecure_registry added to helm_template as equivalent of insecure-skip-tls-verify (https://github.com/ansible-collections/kubernetes.core/pull/805).
|
|
||||||
- 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).
|
|
||||||
|
|
||||||
New Modules
|
|
||||||
-----------
|
|
||||||
|
|
||||||
- helm_registry_auth - Helm registry authentication module
|
|
||||||
|
|
||||||
v5.0.0
|
|
||||||
======
|
|
||||||
|
|
||||||
Release Summary
|
|
||||||
---------------
|
|
||||||
|
|
||||||
This major release drops support for ``ansible-core<2.15``.
|
|
||||||
|
|
||||||
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).
|
|
||||||
|
|
||||||
Breaking Changes / Porting Guide
|
|
||||||
--------------------------------
|
|
||||||
|
|
||||||
- Remove support for ``ansible-core<2.15`` (https://github.com/ansible-collections/kubernetes.core/pull/737).
|
|
||||||
|
|
||||||
v4.0.0
|
|
||||||
======
|
|
||||||
|
|
||||||
Release Summary
|
|
||||||
---------------
|
|
||||||
|
|
||||||
This major release brings several bug fixes. We have also removed support for ``ansible-core<2.15`` and deprecated functions and class from ``module_utils/common.py``.
|
|
||||||
|
|
||||||
Minor Changes
|
|
||||||
-------------
|
|
||||||
|
|
||||||
- inventory/k8s.py - Defer removal of k8s inventory plugin to version 5.0 (https://github.com/ansible-collections/kubernetes.core/pull/723).
|
|
||||||
- k8s - The module and K8sService were changed so warnings returned by the K8S API are now displayed to the user.
|
|
||||||
|
|
||||||
Removed Features (previously deprecated)
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
- k8s - Support for ``merge_type=json`` has been removed in version 4.0.0. Please use ``kubernetes.core.k8s_json_patch`` instead (https://github.com/ansible-collections/kubernetes.core/pull/722).
|
|
||||||
- k8s_exec - the previously deprecated ``result.return_code`` return value has been removed, consider using ``result.rc`` instead (https://github.com/ansible-collections/kubernetes.core/pull/726).
|
|
||||||
- module_utils/common.py - the previously deprecated ``K8sAnsibleMixin`` class has been removed (https://github.com/ansible-collections/kubernetes.core/pull/726).
|
|
||||||
- module_utils/common.py - the previously deprecated ``configuration_digest()`` function has been removed (https://github.com/ansible-collections/kubernetes.core/pull/726).
|
|
||||||
- module_utils/common.py - the previously deprecated ``get_api_client()`` function has been removed (https://github.com/ansible-collections/kubernetes.core/pull/726).
|
|
||||||
- module_utils/common.py - the previously deprecated ``unique_string()`` function has been removed (https://github.com/ansible-collections/kubernetes.core/pull/726).
|
|
||||||
|
|
||||||
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).
|
|
||||||
- avoid unsafe conditions in integration tests (https://github.com/ansible-collections/kubernetes.core/pull/665).
|
|
||||||
- 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.3.0
|
|
||||||
======
|
|
||||||
|
|
||||||
Release Summary
|
|
||||||
---------------
|
|
||||||
|
|
||||||
This release comes with improvements to the error messages in the k8s_drain module and several bug fixes.
|
|
||||||
|
|
||||||
Minor Changes
|
|
||||||
-------------
|
|
||||||
|
|
||||||
- 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 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).
|
|
||||||
|
|
||||||
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
|
||||||
======
|
======
|
||||||
@@ -327,7 +96,7 @@ v2.3.1
|
|||||||
Bugfixes
|
Bugfixes
|
||||||
--------
|
--------
|
||||||
|
|
||||||
- Catch expectation raised when the process is waiting for resources (https://github.com/ansible-collections/kubernetes.core/issues/407).
|
- Catch exception 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).
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ Where modules have multiple parameters we recommend running through the 4-step m
|
|||||||
|
|
||||||
For general information on running the integration tests see the
|
For general information on running the integration tests see the
|
||||||
[Integration Tests page of the Module Development Guide](https://docs.ansible.com/ansible/devel/dev_guide/testing_integration.html#testing-integration),
|
[Integration Tests page of the Module Development Guide](https://docs.ansible.com/ansible/devel/dev_guide/testing_integration.html#testing-integration),
|
||||||
especially the section on configuration for cloud tests.
|
especially the section on configuration for cloud tests. For questions about writing tests the Ansible Kubernetes community can be found on Libera.Chat IRC as detailed below.
|
||||||
|
|
||||||
### Updating documentation
|
### Updating documentation
|
||||||
|
|
||||||
@@ -70,3 +70,11 @@ Review the changes and create a pull request using updated files.
|
|||||||
The `kubernetes.core` collection follows the Ansible project's
|
The `kubernetes.core` collection follows the Ansible project's
|
||||||
[Code of Conduct](https://docs.ansible.com/ansible/devel/community/code_of_conduct.html).
|
[Code of Conduct](https://docs.ansible.com/ansible/devel/community/code_of_conduct.html).
|
||||||
Please read and familiarize yourself with this document.
|
Please read and familiarize yourself with this document.
|
||||||
|
|
||||||
|
### IRC
|
||||||
|
Our IRC channels may require you to register your nickname. If you receive an error when you connect, see
|
||||||
|
[Libera.Chat's Nickname Registration guide](https://libera.chat/guides/registration) for instructions.
|
||||||
|
|
||||||
|
The `#ansible-kubernetes` channel on [libera.chat](https://libera.chat/) IRC is the main and official place to discuss use and development of the `kubernetes.core` collection.
|
||||||
|
|
||||||
|
For more information about Ansible's Kubernetes integration, browse the resources in the [Kubernetes Working Group](https://github.com/ansible/community/wiki/Kubernetes) Community wiki page.
|
||||||
|
|||||||
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 = 5.2.0
|
VERSION = 2.4.0
|
||||||
|
|
||||||
TEST_ARGS ?= ""
|
TEST_ARGS ?= ""
|
||||||
PYTHON_VERSION ?= `python -c 'import platform; print(".".join(platform.python_version_tuple()[0:2]))'`
|
PYTHON_VERSION ?= `python -c 'import platform; print(".".join(platform.python_version_tuple()[0:2]))'`
|
||||||
|
|||||||
85
README.md
85
README.md
@@ -1,29 +1,15 @@
|
|||||||
# Kubernetes Collection for Ansible
|
# Kubernetes Collection for Ansible
|
||||||
|
|
||||||
|
[](https://github.com/ansible-collections/kubernetes.core/actions) [](https://codecov.io/gh/ansible-collections/kubernetes.core)
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
## Communication
|
|
||||||
|
|
||||||
* Join the Ansible forum:
|
|
||||||
* [Get Help](https://forum.ansible.com/c/help/6): get help or help others.
|
|
||||||
* [Posts tagged with 'kubernetes'](https://forum.ansible.com/tag/kubernetes): subscribe to participate in collection-related conversations.
|
|
||||||
* [Social Spaces](https://forum.ansible.com/c/chat/4): gather and interact with fellow enthusiasts.
|
|
||||||
* [News & Announcements](https://forum.ansible.com/c/news/5): track project-wide announcements including social events.
|
|
||||||
|
|
||||||
* The Ansible [Bullhorn newsletter](https://docs.ansible.com/ansible/devel/community/communication.html#the-bullhorn): used to announce releases and important changes.
|
|
||||||
|
|
||||||
For more information about communication, see the [Ansible communication guide](https://docs.ansible.com/ansible/devel/community/communication.html).
|
|
||||||
|
|
||||||
## Requirements
|
|
||||||
|
|
||||||
<!--start requires_ansible-->
|
<!--start requires_ansible-->
|
||||||
## Ansible Version Compatibility
|
## Ansible version compatibility
|
||||||
|
|
||||||
This collection has been tested against following Ansible versions: **>=2.15.0**.
|
This collection has been tested against following Ansible versions: **>=2.9.17**.
|
||||||
|
|
||||||
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`).
|
||||||
@@ -32,37 +18,37 @@ 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.9+
|
* Collection supports 3.6+
|
||||||
|
|
||||||
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.24.
|
This collection supports Kubernetes versions >=1.19.
|
||||||
|
|
||||||
### 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
|
||||||
@@ -76,7 +62,6 @@ Name | Description
|
|||||||
[kubernetes.core.helm_plugin](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.helm_plugin_module.rst)|Manage Helm plugins
|
[kubernetes.core.helm_plugin](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.helm_plugin_module.rst)|Manage Helm plugins
|
||||||
[kubernetes.core.helm_plugin_info](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.helm_plugin_info_module.rst)|Gather information about Helm plugins
|
[kubernetes.core.helm_plugin_info](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.helm_plugin_info_module.rst)|Gather information about Helm plugins
|
||||||
[kubernetes.core.helm_pull](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.helm_pull_module.rst)|download a chart from a repository and (optionally) unpack it in local directory.
|
[kubernetes.core.helm_pull](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.helm_pull_module.rst)|download a chart from a repository and (optionally) unpack it in local directory.
|
||||||
[kubernetes.core.helm_registry_auth](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.helm_registry_auth_module.rst)|Helm registry authentication module
|
|
||||||
[kubernetes.core.helm_repository](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.helm_repository_module.rst)|Manage Helm repositories.
|
[kubernetes.core.helm_repository](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.helm_repository_module.rst)|Manage Helm repositories.
|
||||||
[kubernetes.core.helm_template](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.helm_template_module.rst)|Render chart templates
|
[kubernetes.core.helm_template](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.helm_template_module.rst)|Render chart templates
|
||||||
[kubernetes.core.k8s](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_module.rst)|Manage Kubernetes (K8s) objects
|
[kubernetes.core.k8s](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_module.rst)|Manage Kubernetes (K8s) objects
|
||||||
@@ -94,7 +79,9 @@ Name | Description
|
|||||||
|
|
||||||
<!--end collection content-->
|
<!--end collection content-->
|
||||||
|
|
||||||
## Installation
|
## Installation and Usage
|
||||||
|
|
||||||
|
### 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:
|
||||||
|
|
||||||
@@ -106,7 +93,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: 5.3.0
|
version: 2.4.0
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installing the Kubernetes Python Library
|
### Installing the Kubernetes Python Library
|
||||||
@@ -115,7 +102,7 @@ Content in this collection requires the [Kubernetes Python client](https://pypi.
|
|||||||
|
|
||||||
pip3 install kubernetes
|
pip3 install kubernetes
|
||||||
|
|
||||||
## Use Cases
|
### Using modules from the Kubernetes Collection in your playbooks
|
||||||
|
|
||||||
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`:
|
||||||
|
|
||||||
@@ -183,7 +170,7 @@ If upgrading older playbooks which were built prior to Ansible 2.10 and this col
|
|||||||
|
|
||||||
For documentation on how to use individual modules and other content included in this collection, please see the links in the 'Included content' section earlier in this README.
|
For documentation on how to use individual modules and other content included in this collection, please see the links in the 'Included content' section earlier in this README.
|
||||||
|
|
||||||
## Ansible Turbo Mode Tech Preview
|
## Ansible Turbo mode Tech Preview
|
||||||
|
|
||||||
|
|
||||||
The ``kubernetes.core`` collection supports Ansible Turbo mode as a tech preview via the ``cloud.common`` collection. By default, this feature is disabled. To enable Turbo mode for modules, set the environment variable `ENABLE_TURBO_MODE=1` on the managed node. For example:
|
The ``kubernetes.core`` collection supports Ansible Turbo mode as a tech preview via the ``cloud.common`` collection. By default, this feature is disabled. To enable Turbo mode for modules, set the environment variable `ENABLE_TURBO_MODE=1` on the managed node. For example:
|
||||||
@@ -202,16 +189,12 @@ 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).
|
||||||
|
|
||||||
## Contributing to this Collection
|
## Testing and Development
|
||||||
|
|
||||||
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).
|
||||||
@@ -248,33 +231,9 @@ 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
|
## More Information
|
||||||
|
|
||||||
<!--List available communication channels. In addition to channels specific to your collection, we also recommend to use the following ones.-->
|
|
||||||
|
|
||||||
> **Note:** The `stable-4` branch, which handles all `4.x.y` releases of this collection, is no longer supported. This means that no backports nor releases will be performed on the `stable-4` branch.
|
|
||||||
|
|
||||||
We announce releases and important changes through Ansible's [The Bullhorn newsletter](https://github.com/ansible/community/wiki/News#the-bullhorn). Be sure you are [subscribed](https://eepurl.com/gZmiEP).
|
|
||||||
|
|
||||||
We take part in the global quarterly [Ansible Contributor Summit](https://github.com/ansible/community/wiki/Contributor-Summit) virtually or in-person. Track [The Bullhorn newsletter](https://eepurl.com/gZmiEP) and join us.
|
|
||||||
|
|
||||||
For more information about communication, refer to the [Ansible Communication guide](https://docs.ansible.com/ansible/devel/community/communication.html).
|
|
||||||
|
|
||||||
For the latest supported versions, refer to the release notes below.
|
|
||||||
|
|
||||||
If you encounter issues or have questions, you can submit a support request through the following channels:
|
|
||||||
- GitHub Issues: Report bugs, request features, or ask questions by opening an issue in the [GitHub repository]((https://github.com/ansible-collections/kubernetes.core/).
|
|
||||||
|
|
||||||
## Release Notes
|
|
||||||
|
|
||||||
See the [raw generated changelog](https://github.com/ansible-collections/kubernetes.core/blob/main/CHANGELOG.rst).
|
|
||||||
|
|
||||||
## Code of Conduct
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
@@ -762,279 +762,3 @@ releases:
|
|||||||
name: helm_pull
|
name: helm_pull
|
||||||
namespace: ''
|
namespace: ''
|
||||||
release_date: '2023-01-24'
|
release_date: '2023-01-24'
|
||||||
3.0.0:
|
|
||||||
changes:
|
|
||||||
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:
|
|
||||||
- 20230206-deprecate-k8s-inventory.yml
|
|
||||||
- 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-20'
|
|
||||||
4.0.0:
|
|
||||||
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).
|
|
||||||
- avoid unsafe conditions in integration tests (https://github.com/ansible-collections/kubernetes.core/pull/665).
|
|
||||||
- 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).
|
|
||||||
minor_changes:
|
|
||||||
- inventory/k8s.py - Defer removal of k8s inventory plugin to version 5.0 (https://github.com/ansible-collections/kubernetes.core/pull/723).
|
|
||||||
- k8s - The module and K8sService were changed so warnings returned by the K8S
|
|
||||||
API are now displayed to the user.
|
|
||||||
release_summary: This major release brings several bug fixes. We have also removed
|
|
||||||
support for ``ansible-core<2.15`` and deprecated functions and class from
|
|
||||||
``module_utils/common.py``.
|
|
||||||
removed_features:
|
|
||||||
- k8s - Support for ``merge_type=json`` has been removed in version 4.0.0. Please
|
|
||||||
use ``kubernetes.core.k8s_json_patch`` instead (https://github.com/ansible-collections/kubernetes.core/pull/722).
|
|
||||||
- k8s_exec - the previously deprecated ``result.return_code`` return value has
|
|
||||||
been removed, consider using ``result.rc`` instead (https://github.com/ansible-collections/kubernetes.core/pull/726).
|
|
||||||
- module_utils/common.py - the previously deprecated ``K8sAnsibleMixin`` class
|
|
||||||
has been removed (https://github.com/ansible-collections/kubernetes.core/pull/726).
|
|
||||||
- module_utils/common.py - the previously deprecated ``configuration_digest()``
|
|
||||||
function has been removed (https://github.com/ansible-collections/kubernetes.core/pull/726).
|
|
||||||
- module_utils/common.py - the previously deprecated ``get_api_client()`` function
|
|
||||||
has been removed (https://github.com/ansible-collections/kubernetes.core/pull/726).
|
|
||||||
- module_utils/common.py - the previously deprecated ``unique_string()`` function
|
|
||||||
has been removed (https://github.com/ansible-collections/kubernetes.core/pull/726).
|
|
||||||
fragments:
|
|
||||||
- 20231206-fix-unsafe-condition-in-integration.yml
|
|
||||||
- 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
|
|
||||||
- 20240423-k8s-display-warnings-to-users.yml
|
|
||||||
- 4.0.0.yaml
|
|
||||||
- inventory-update_removal_date.yml
|
|
||||||
- k8s-merge_type-removed.yml
|
|
||||||
- module_utils-common-remove-deprecated-functions-and-class.yaml
|
|
||||||
release_date: '2024-05-24'
|
|
||||||
5.0.0:
|
|
||||||
changes:
|
|
||||||
breaking_changes:
|
|
||||||
- Remove support for ``ansible-core<2.15`` (https://github.com/ansible-collections/kubernetes.core/pull/737).
|
|
||||||
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).
|
|
||||||
release_summary: This major release drops support for ``ansible-core<2.15``.
|
|
||||||
fragments:
|
|
||||||
- 20240530-ansible-core-support-update.yaml
|
|
||||||
- 20240530-defer-removal-and-ansible-core-support-update.yaml
|
|
||||||
- 5.0.0.yml
|
|
||||||
release_date: '2024-05-31'
|
|
||||||
5.1.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:
|
|
||||||
- Bump version of ansible-lint to minimum 24.7.0 (https://github.com/ansible-collections/kubernetes.core/pull/765).
|
|
||||||
- Parameter insecure_registry added to helm_template as equivalent of insecure-skip-tls-verify
|
|
||||||
(https://github.com/ansible-collections/kubernetes.core/pull/805).
|
|
||||||
- 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 came with new module ``helm_registry_auth``, improvements
|
|
||||||
to the error messages in the k8s_drain module, new parameter ``insecure_registry``
|
|
||||||
for ``helm_template`` module and several bug fixes.
|
|
||||||
fragments:
|
|
||||||
- 0-readme.yml
|
|
||||||
- 20240601-doc-example-of-using-kubectl.yaml
|
|
||||||
- 20240611-helm-rc-version.yaml
|
|
||||||
- 20240620-fix-kustomize-plugin-fails-with-deprecation-warnings.yml
|
|
||||||
- 20241102-fix-ci-post-2.18-issue.yaml
|
|
||||||
- 20241103-completly-remove-obsolate-communication-channel.yaml
|
|
||||||
- 20241207-add-insecure-skip-tls-verify-to-helm-template.yaml
|
|
||||||
- 20241213-kubeconfig-set-no_log-true.yaml
|
|
||||||
- 756-fix-daemonset-waiting.yaml
|
|
||||||
- 765-bump-ansible-lint-version.yml
|
|
||||||
- 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
|
|
||||||
modules:
|
|
||||||
- description: Helm registry authentication module
|
|
||||||
name: helm_registry_auth
|
|
||||||
namespace: ''
|
|
||||||
release_date: '2025-01-20'
|
|
||||||
5.2.0:
|
|
||||||
changes:
|
|
||||||
minor_changes:
|
|
||||||
- k8s - Extend hidden_fields to allow the expression of more complex field types
|
|
||||||
to be hidden (https://github.com/ansible-collections/kubernetes.core/pull/872)
|
|
||||||
- k8s_info - Extend hidden_fields to allow the expression of more complex field
|
|
||||||
types to be hidden (https://github.com/ansible-collections/kubernetes.core/pull/872)
|
|
||||||
- 'waiter.py - add ClusterOperator support. The module can now check OpenShift
|
|
||||||
cluster health by verifying ClusterOperator status requiring ''Available:
|
|
||||||
True'', ''Degraded: False'', and ''Progressing: False'' for success. (https://github.com/ansible-collections/kubernetes.core/issues/869)'
|
|
||||||
release_summary: This release adds more functionality to the hidden_fields option
|
|
||||||
and support for waiting on ClusterOperators to reach a ready state.
|
|
||||||
fragments:
|
|
||||||
- 5.2.0.yml
|
|
||||||
- 643-extend-hidden-fields.yaml
|
|
||||||
- 879-clusteroperator-waiter.py.yaml
|
|
||||||
release_date: '2025-03-27'
|
|
||||||
5.3.0:
|
|
||||||
changes:
|
|
||||||
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).
|
|
||||||
minor_changes:
|
|
||||||
- Bump version of ansible-lint to 25.1.2 (https://github.com/ansible-collections/kubernetes.core/pull/919).
|
|
||||||
- action/k8s_info - update templating mechanism with changes from ``ansible-core
|
|
||||||
2.19`` (https://github.com/ansible-collections/kubernetes.core/pull/888).
|
|
||||||
- helm - add reset_then_reuse_values support to helm module (https://github.com/ansible-collections/kubernetes.core/issues/803).
|
|
||||||
- helm - add support for ``insecure_skip_tls_verify`` option to helm and helm_repository(https://github.com/ansible-collections/kubernetes.core/issues/694).
|
|
||||||
release_summary: This release includes minor changes, bug fixes and also bumps
|
|
||||||
ansible-lint version to ``25.1.2``.
|
|
||||||
fragments:
|
|
||||||
- 20250324-k8s_info-templating.yaml
|
|
||||||
- 5.3.0.yml
|
|
||||||
- 694-add-insecure-skip-tls-verify.yml
|
|
||||||
- 800-helm-add-reset_then_reuse_values-support.yml
|
|
||||||
- 898-k8s-dont-delete-in-check-mode.yaml
|
|
||||||
- 919-update-ansible-lint-version.yaml
|
|
||||||
release_date: '2025-05-16'
|
|
||||||
|
|||||||
@@ -105,27 +105,6 @@ 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>
|
||||||
@@ -148,7 +127,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">raw</span>
|
<span style="color: purple">path</span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -156,7 +135,6 @@ 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>
|
||||||
@@ -194,32 +172,6 @@ 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>
|
||||||
@@ -252,18 +204,11 @@ Examples
|
|||||||
|
|
||||||
.. code-block:: yaml
|
.. code-block:: yaml
|
||||||
|
|
||||||
- name: Gather information of Grafana chart inside monitoring namespace
|
- name: Deploy latest version 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
|
||||||
@@ -325,42 +270,6 @@ 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">
|
||||||
@@ -393,23 +302,6 @@ 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="2">Parameter</th>
|
<th colspan="1">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="2">
|
<td colspan="1">
|
||||||
<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="2">
|
<td colspan="1">
|
||||||
<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="2">
|
<td colspan="1">
|
||||||
<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="2">
|
<td colspan="1">
|
||||||
<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="2">
|
<td colspan="1">
|
||||||
<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="2">
|
<td colspan="1">
|
||||||
<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="2">
|
<td colspan="1">
|
||||||
<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="2">
|
<td colspan="1">
|
||||||
<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="2">
|
<td colspan="1">
|
||||||
<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,14 +194,13 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="1">
|
||||||
<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>
|
||||||
@@ -210,7 +209,7 @@ Parameters
|
|||||||
</ul>
|
</ul>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>Run standalone <code>helm dependency update CHART</code> before the operation.</div>
|
<div>Run standelone <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>
|
||||||
@@ -219,7 +218,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="1">
|
||||||
<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>
|
||||||
@@ -238,7 +237,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="1">
|
||||||
<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>
|
||||||
@@ -257,7 +256,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="1">
|
||||||
<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>
|
||||||
@@ -274,7 +273,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="1">
|
||||||
<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>
|
||||||
@@ -290,35 +289,12 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="1">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
||||||
<b>insecure_skip_tls_verify</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 5.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>Skip tls certificate checks for the chart download.</div>
|
|
||||||
<div>Do not confuse with the <code>validate_certs</code> option.</div>
|
|
||||||
<div>This option is only available for helm >= 3.16.0.</div>
|
|
||||||
<div style="font-size: small; color: darkgreen"><br/>aliases: skip_tls_certs_check</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<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">raw</span>
|
<span style="color: purple">path</span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -326,28 +302,11 @@ 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="2">
|
<td colspan="1">
|
||||||
<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>
|
||||||
@@ -366,7 +325,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="1">
|
||||||
<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>
|
||||||
@@ -383,7 +342,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="1">
|
||||||
<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>
|
||||||
@@ -400,7 +359,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="1">
|
||||||
<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>
|
||||||
@@ -420,7 +379,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="1">
|
||||||
<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>
|
||||||
@@ -437,7 +396,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="1">
|
||||||
<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>
|
||||||
@@ -459,130 +418,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
||||||
<b>reset_then_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 6.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 upgrading package, reset the values to the ones built into the chart, apply the last release's values and merge in any overrides from parameters O(release_values), O(values_files) or O(set_values).</div>
|
|
||||||
<div>If O(reset_values) or O(reuse_values) is set to V(True), this is ignored.</div>
|
|
||||||
<div>This feature requires helm diff >= 3.9.12.</div>
|
|
||||||
</td>
|
|
||||||
</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>
|
||||||
@@ -602,7 +438,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="1">
|
||||||
<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>
|
||||||
@@ -620,7 +456,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="1">
|
||||||
<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>
|
||||||
@@ -639,7 +475,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="1">
|
||||||
<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>
|
||||||
@@ -660,7 +496,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="1">
|
||||||
<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>
|
||||||
@@ -681,7 +517,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="1">
|
||||||
<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>
|
||||||
@@ -701,7 +537,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="1">
|
||||||
<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>
|
||||||
@@ -720,12 +556,6 @@ 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
|
||||||
@@ -782,15 +612,6 @@ 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:
|
||||||
@@ -836,17 +657,6 @@ 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">raw</span>
|
<span style="color: purple">path</span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -134,7 +134,6 @@ 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">raw</span>
|
<span style="color: purple">path</span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -134,7 +134,6 @@ 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>
|
||||||
@@ -151,7 +150,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> or <code>state=latest</code>.</div>
|
<div>Required only if <code>state=absent</code>.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -171,23 +170,6 @@ 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>
|
||||||
@@ -201,12 +183,10 @@ 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>
|
||||||
@@ -257,17 +237,6 @@ 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
|
||||||
|
|||||||
@@ -279,8 +279,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>Whether or not to check tls certificate for the chart download.</div>
|
<div>Whether or not to check tls certificate for the chart download.</div>
|
||||||
<div>Requires helm >= 3.3.0. Alias <code>insecure_skip_tls_verify</code> added in 5.3.0.</div>
|
<div>Requires helm >= 3.3.0.</div>
|
||||||
<div style="font-size: small; color: darkgreen"><br/>aliases: insecure_skip_tls_verify</div>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -1,332 +0,0 @@
|
|||||||
.. _kubernetes.core.helm_registry_auth_module:
|
|
||||||
|
|
||||||
|
|
||||||
**********************************
|
|
||||||
kubernetes.core.helm_registry_auth
|
|
||||||
**********************************
|
|
||||||
|
|
||||||
**Helm registry authentication module**
|
|
||||||
|
|
||||||
|
|
||||||
Version added: 5.1.0
|
|
||||||
|
|
||||||
.. contents::
|
|
||||||
:local:
|
|
||||||
:depth: 1
|
|
||||||
|
|
||||||
|
|
||||||
Synopsis
|
|
||||||
--------
|
|
||||||
- Helm registry authentication module allows you to login ``helm registry login`` and logout ``helm registry logout`` from a Helm registry.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Requirements
|
|
||||||
------------
|
|
||||||
The below requirements are needed on the host that executes this module.
|
|
||||||
|
|
||||||
- helm (https://github.com/helm/helm/releases) => 3.8.0
|
|
||||||
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
|
|
||||||
.. raw:: html
|
|
||||||
|
|
||||||
<table border=0 cellpadding=0 class="documentation-table">
|
|
||||||
<tr>
|
|
||||||
<th colspan="1">Parameter</th>
|
|
||||||
<th>Choices/<font color="blue">Defaults</font></th>
|
|
||||||
<th width="100%">Comments</th>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
||||||
<b>binary_path</b>
|
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
||||||
<div style="font-size: small">
|
|
||||||
<span style="color: purple">path</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div>The path of a helm binary to use.</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
||||||
<b>ca_file</b>
|
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
||||||
<div style="font-size: small">
|
|
||||||
<span style="color: purple">path</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div>Path to the CA certificate SSL file for verify registry server certificate.</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
||||||
<b>cert_file</b>
|
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
||||||
<div style="font-size: small">
|
|
||||||
<span style="color: purple">path</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div>Path to the client certificate SSL file for identify registry client using this certificate file.</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>
|
|
||||||
/ <span style="color: red">required</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div>Provide a URL for accessing the registry.</div>
|
|
||||||
<div style="font-size: small; color: darkgreen"><br/>aliases: registry_url</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
||||||
<b>insecure</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>Allow connections to SSL sites without certs.</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
||||||
<b>key_file</b>
|
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
||||||
<div style="font-size: small">
|
|
||||||
<span style="color: purple">path</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div>Path to the client key SSL file for identify registry client using this key file.</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
||||||
<b>password</b>
|
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
||||||
<div style="font-size: small">
|
|
||||||
<span style="color: purple">string</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div>Password for the registry.</div>
|
|
||||||
<div style="font-size: small; color: darkgreen"><br/>aliases: repo_password</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
||||||
<b>state</b>
|
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
||||||
<div style="font-size: small">
|
|
||||||
<span style="color: purple">string</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
|
||||||
<li><div style="color: blue"><b>present</b> ←</div></li>
|
|
||||||
<li>absent</li>
|
|
||||||
</ul>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div>Desired state of the registry.</div>
|
|
||||||
<div>If set to V(present) attempt to log in to the remote registry server using the URL specified in O(host).</div>
|
|
||||||
<div>If set to V(absent) attempt to log out from the remote registry server using the URL specified in O(host).</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
||||||
<b>username</b>
|
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
||||||
<div style="font-size: small">
|
|
||||||
<span style="color: purple">string</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div>Username for the registry.</div>
|
|
||||||
<div style="font-size: small; color: darkgreen"><br/>aliases: repo_username</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Examples
|
|
||||||
--------
|
|
||||||
|
|
||||||
.. code-block:: yaml
|
|
||||||
|
|
||||||
- name: Login to remote registry
|
|
||||||
kubernetes.core.helm_registry_auth:
|
|
||||||
username: admin
|
|
||||||
password: "sample_password"
|
|
||||||
host: localhost:5000
|
|
||||||
|
|
||||||
- name: Logout from remote registry
|
|
||||||
kubernetes.core.helm_registry_auth:
|
|
||||||
state: absent
|
|
||||||
host: localhost:5000
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Return Values
|
|
||||||
-------------
|
|
||||||
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
|
|
||||||
|
|
||||||
.. raw:: html
|
|
||||||
|
|
||||||
<table border=0 cellpadding=0 class="documentation-table">
|
|
||||||
<tr>
|
|
||||||
<th colspan="1">Key</th>
|
|
||||||
<th>Returned</th>
|
|
||||||
<th width="100%">Description</th>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="return-"></div>
|
|
||||||
<b>command</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>always</td>
|
|
||||||
<td>
|
|
||||||
<div>Full <code>helm</code> command executed</div>
|
|
||||||
<br/>
|
|
||||||
<div style="font-size: smaller"><b>Sample:</b></div>
|
|
||||||
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">/usr/local/bin/helm registry login oci-registry.domain.example --username=admin --password-stdin --insecure</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="return-"></div>
|
|
||||||
<b>failed</b>
|
|
||||||
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
|
||||||
<div style="font-size: small">
|
|
||||||
<span style="color: purple">boolean</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>always</td>
|
|
||||||
<td>
|
|
||||||
<div>Indicate if the <code>helm</code> command failed</div>
|
|
||||||
<br/>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="return-"></div>
|
|
||||||
<b>stderr</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>always</td>
|
|
||||||
<td>
|
|
||||||
<div>Full <code>helm</code> command stderr, in case you want to display it or examine the event log. Please be note that helm binnary may print messages to stderr even if the command is successful.</div>
|
|
||||||
<br/>
|
|
||||||
<div style="font-size: smaller"><b>Sample:</b></div>
|
|
||||||
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">Login Succeeded\n</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="return-"></div>
|
|
||||||
<b>stderr_lines</b>
|
|
||||||
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
|
||||||
<div style="font-size: small">
|
|
||||||
<span style="color: purple">list</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>always</td>
|
|
||||||
<td>
|
|
||||||
<div>Full <code>helm</code> command stderr, in case you want to display it or examine the event log</div>
|
|
||||||
<br/>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="return-"></div>
|
|
||||||
<b>stdout</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>always</td>
|
|
||||||
<td>
|
|
||||||
<div>Full <code>helm</code> command stdout, in case you want to display it or examine the event log</div>
|
|
||||||
<br/>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="return-"></div>
|
|
||||||
<b>stout_lines</b>
|
|
||||||
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
|
||||||
<div style="font-size: small">
|
|
||||||
<span style="color: purple">list</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>always</td>
|
|
||||||
<td>
|
|
||||||
<div>Full <code>helm</code> command stdout, in case you want to display it or examine the event log</div>
|
|
||||||
<br/>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br/><br/>
|
|
||||||
|
|
||||||
|
|
||||||
Status
|
|
||||||
------
|
|
||||||
|
|
||||||
|
|
||||||
Authors
|
|
||||||
~~~~~~~
|
|
||||||
|
|
||||||
- Yuriy Novostavskiy (@yurnov)
|
|
||||||
@@ -40,22 +40,6 @@ 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>
|
||||||
@@ -71,138 +55,6 @@ 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>insecure_skip_tls_verify</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 5.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>Skip tls certificate checks for the repository url.</div>
|
|
||||||
<div style="font-size: small; color: darkgreen"><br/>aliases: skip_tls_certs_check</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>
|
||||||
@@ -290,27 +142,6 @@ 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="2">Parameter</th>
|
<th colspan="1">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="2">
|
<td colspan="1">
|
||||||
<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="2">
|
<td colspan="1">
|
||||||
<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="2">
|
<td colspan="1">
|
||||||
<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="2">
|
<td colspan="1">
|
||||||
<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,14 +97,13 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="1">
|
||||||
<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>
|
||||||
@@ -120,27 +119,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="1">
|
||||||
<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>
|
||||||
@@ -159,27 +138,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="1">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
||||||
<b>insecure_registry</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 5.1.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>Skip TLS certificate checks for the chart download</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<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>
|
||||||
@@ -195,40 +154,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="1">
|
||||||
<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>
|
||||||
@@ -245,85 +171,7 @@ 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>
|
||||||
@@ -342,7 +190,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="1">
|
||||||
<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>
|
||||||
@@ -387,24 +235,6 @@ 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.9
|
- python >= 3.6
|
||||||
- kubernetes >= 24.2.0
|
- kubernetes >= 12.0.0
|
||||||
- PyYAML >= 3.11
|
- PyYAML >= 3.11
|
||||||
|
|
||||||
|
|
||||||
@@ -203,29 +203,9 @@ 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.9
|
- python >= 3.6
|
||||||
- kubernetes >= 24.2.0
|
- kubernetes >= 12.0.0
|
||||||
|
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@@ -215,7 +215,6 @@ 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>
|
||||||
@@ -272,25 +271,6 @@ 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>
|
||||||
@@ -558,7 +538,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 content into a file in the remote pod
|
- name: Copy /tmp/foo from a remote pod to /tmp/bar locally
|
||||||
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.9
|
- python >= 3.6
|
||||||
- kubernetes >= 24.2.0
|
- kubernetes >= 12.0.0
|
||||||
|
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@@ -132,7 +132,6 @@ 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>
|
||||||
@@ -148,7 +147,6 @@ 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>
|
||||||
@@ -157,7 +155,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>
|
||||||
@@ -336,7 +334,6 @@ 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>
|
||||||
@@ -356,25 +353,6 @@ 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>
|
||||||
@@ -414,25 +392,6 @@ 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>
|
||||||
@@ -595,15 +554,14 @@ Examples
|
|||||||
kubernetes.core.k8s_drain:
|
kubernetes.core.k8s_drain:
|
||||||
state: drain
|
state: drain
|
||||||
name: foo
|
name: foo
|
||||||
delete_options:
|
force: yes
|
||||||
force: yes
|
|
||||||
|
|
||||||
- name: Drain node "foo", but abort if there are pods not managed by a ReplicationController, Job, or DaemonSet, and use a grace period of 15 minutes.
|
- name: Drain node "foo", but abort if there are pods not managed by a ReplicationController, Job, or DaemonSet, and use a grace period of 15 minutes.
|
||||||
kubernetes.core.k8s_drain:
|
kubernetes.core.k8s_drain:
|
||||||
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:
|
||||||
@@ -615,14 +573,6 @@ 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.9
|
- python >= 3.6
|
||||||
- kubernetes >= 24.2.0
|
- kubernetes >= 12.0.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,7 +134,6 @@ 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>
|
||||||
@@ -215,7 +214,6 @@ 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>
|
||||||
@@ -232,26 +230,7 @@ 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>
|
||||||
@@ -306,7 +285,7 @@ Parameters
|
|||||||
<td>
|
<td>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>The pod name.</div>
|
<div>The pod name</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -323,7 +302,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 (for example, HTTP_PROXY).</div>
|
<div>Please note that this module does not pick up typical proxy settings from the environment (e.g. HTTP_PROXY).</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -470,13 +449,6 @@ 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.9
|
- python >= 3.6
|
||||||
- kubernetes >= 24.2.0
|
- kubernetes >= 12.0.0
|
||||||
- PyYAML >= 3.11
|
- PyYAML >= 3.11
|
||||||
|
|
||||||
|
|
||||||
@@ -153,30 +153,11 @@ 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> or V(hidden_fields=[spec.containers[0].env[3].value]) or V(hidden_fields=[metadata.annotations[kubectl.kubernetes.io/last-applied-configuration]])</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -259,7 +240,6 @@ 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>
|
||||||
@@ -274,7 +254,6 @@ 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>
|
||||||
@@ -316,25 +295,6 @@ 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,15 +13,6 @@ 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
|
||||||
--------
|
--------
|
||||||
@@ -36,8 +27,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.9
|
- python >= 3.6
|
||||||
- kubernetes >= 24.2.0
|
- kubernetes >= 12.0.0
|
||||||
- PyYAML >= 3.11
|
- PyYAML >= 3.11
|
||||||
|
|
||||||
|
|
||||||
@@ -331,24 +322,24 @@ Examples
|
|||||||
|
|
||||||
# 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
|
# 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
|
||||||
|
|
||||||
- name: Use default config (~/.kube/config) file and active context, and return objects for a specific namespace
|
# 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
|
||||||
|
|
||||||
- name: Use a custom config file, and a specific context.
|
# 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'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -357,15 +348,11 @@ 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.9
|
- python >= 3.6
|
||||||
- kubernetes >= 24.2.0
|
- kubernetes >= 12.0.0
|
||||||
- PyYAML >= 3.11
|
- PyYAML >= 3.11
|
||||||
- jsonpatch
|
- jsonpatch
|
||||||
|
|
||||||
@@ -220,7 +220,6 @@ 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>
|
||||||
@@ -257,25 +256,6 @@ 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>
|
||||||
@@ -614,7 +594,7 @@ Examples
|
|||||||
path: /metadata/labels/app
|
path: /metadata/labels/app
|
||||||
value: myapp
|
value: myapp
|
||||||
- op: replace
|
- op: replace
|
||||||
path: /spec/containers/0/image
|
patch: /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.9
|
- python >= 3.6
|
||||||
- kubernetes >= 24.2.0
|
- kubernetes >= 12.0.0
|
||||||
- PyYAML >= 3.11
|
- PyYAML >= 3.11
|
||||||
|
|
||||||
|
|
||||||
@@ -44,27 +44,6 @@ 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>
|
||||||
@@ -162,8 +141,7 @@ 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 or set <em>all_containers</em> to <code>true</code>.</div>
|
<div>If there is more than one container, this option is required.</div>
|
||||||
<div>mutually exclusive with <code>all_containers</code>.</div>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -262,7 +240,6 @@ 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>
|
||||||
@@ -277,7 +254,6 @@ 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>
|
||||||
@@ -319,25 +295,6 @@ 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>
|
||||||
@@ -377,26 +334,6 @@ 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>
|
||||||
@@ -498,22 +435,6 @@ 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>
|
||||||
@@ -598,16 +519,8 @@ 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.9
|
- python >= 3.6
|
||||||
- kubernetes >= 24.2.0
|
- kubernetes >= 12.0.0
|
||||||
- PyYAML >= 3.11
|
- PyYAML >= 3.11
|
||||||
|
|
||||||
|
|
||||||
@@ -438,28 +438,106 @@ 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="1">Key</th>
|
<th colspan="2">Key</th>
|
||||||
<th>Returned</th>
|
<th>Returned</th>
|
||||||
<th width="100%">Description</th>
|
<th width="100%">Description</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<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">list</span>
|
<span style="color: purple">complex</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/>
|
||||||
|
|
||||||
@@ -471,8 +549,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.9
|
- python >= 3.6
|
||||||
- kubernetes >= 24.2.0
|
- kubernetes >= 12.0.0
|
||||||
- PyYAML >= 3.11
|
- PyYAML >= 3.11
|
||||||
- jsonpatch
|
- jsonpatch
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ Parameters
|
|||||||
<td>
|
<td>
|
||||||
<div><code>apply</code> compares the desired resource definition with the previously supplied resource definition, ignoring properties that are automatically generated</div>
|
<div><code>apply</code> compares the desired resource definition with the previously supplied resource definition, ignoring properties that are automatically generated</div>
|
||||||
<div><code>apply</code> works better with Services than 'force=yes'</div>
|
<div><code>apply</code> works better with Services than 'force=yes'</div>
|
||||||
<div>Mutually exclusive with <code>merge_type</code>.</div>
|
<div>mutually exclusive with <code>merge_type</code></div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -208,30 +208,6 @@ 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>
|
||||||
@@ -360,44 +336,6 @@ 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> or V(hidden_fields=[spec.containers[0].env[3].value]) or V(hidden_fields=[metadata.annotations[kubectl.kubernetes.io/last-applied-configuration]])</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3">
|
<td colspan="3">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -479,7 +417,6 @@ 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>
|
||||||
@@ -512,17 +449,18 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
||||||
|
<li>json</li>
|
||||||
<li>merge</li>
|
<li>merge</li>
|
||||||
<li>strategic-merge</li>
|
<li>strategic-merge</li>
|
||||||
</ul>
|
</ul>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>Whether to override the default patch merge approach with a specific type. By default, the strategic merge will typically be used.</div>
|
<div>Whether to override the default patch merge approach with a specific type. By default, the strategic merge will typically be used.</div>
|
||||||
<div>For example, Custom Resource Definitions typically aren't updatable by the usual strategic merge. You may want to use <code>merge</code> if you see "strategic merge patch format is not supported".</div>
|
<div>For example, Custom Resource Definitions typically aren't updatable by the usual strategic merge. You may want to use <code>merge</code> if you see "strategic merge patch format is not supported"</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>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> has been removed in version 4.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 3.0.0. Please use <span class='module'>kubernetes.core.k8s_json_patch</span> instead.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -561,25 +499,6 @@ 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>
|
||||||
@@ -721,63 +640,6 @@ 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>
|
||||||
@@ -792,8 +654,7 @@ 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>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'>k8s</span> module.</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>
|
||||||
@@ -1155,14 +1016,6 @@ 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
|
||||||
@@ -1180,10 +1033,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:
|
||||||
@@ -1240,41 +1093,6 @@ 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.9
|
- python >= 3.6
|
||||||
- kubernetes >= 24.2.0
|
- kubernetes >= 12.0.0
|
||||||
- PyYAML >= 3.11
|
- PyYAML >= 3.11
|
||||||
|
|
||||||
|
|
||||||
@@ -152,7 +152,6 @@ 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>
|
||||||
@@ -239,7 +238,6 @@ 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,7 +252,6 @@ 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>
|
||||||
@@ -296,25 +293,6 @@ 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.9
|
- python >= 3.6
|
||||||
- kubernetes >= 24.2.0
|
- kubernetes >= 12.0.0
|
||||||
- PyYAML >= 3.11
|
- PyYAML >= 3.11
|
||||||
|
|
||||||
|
|
||||||
@@ -255,7 +255,6 @@ 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,7 +270,6 @@ 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>
|
||||||
@@ -313,25 +311,6 @@ 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>
|
||||||
@@ -518,8 +497,7 @@ 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>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'>k8s</span> module.</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.9
|
- python >= 3.6
|
||||||
- kubernetes >= 24.2.0
|
- kubernetes >= 12.0.0
|
||||||
|
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@@ -220,7 +220,6 @@ 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>
|
||||||
@@ -281,25 +280,6 @@ 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>
|
||||||
@@ -488,8 +468,7 @@ 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>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'>k8s</span> module.</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.9
|
- python >= 3.6
|
||||||
- kubernetes >= 24.2.0
|
- kubernetes >= 12.0.0
|
||||||
|
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@@ -182,7 +182,6 @@ 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,28 +208,6 @@ 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>
|
||||||
@@ -365,82 +343,6 @@ 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 }}"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -452,7 +354,7 @@ Status
|
|||||||
Authors
|
Authors
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
|
|
||||||
- xuxinkun (@xuxinkun)
|
- xuxinkun
|
||||||
|
|
||||||
|
|
||||||
.. hint::
|
.. hint::
|
||||||
|
|||||||
@@ -77,24 +77,6 @@ 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>
|
||||||
@@ -130,21 +112,17 @@ Examples
|
|||||||
.. code-block:: yaml
|
.. code-block:: yaml
|
||||||
|
|
||||||
- name: Run lookup using kustomize
|
- name: Run lookup using kustomize
|
||||||
ansible.builtin.set_fact:
|
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
|
||||||
ansible.builtin.set_fact:
|
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
|
||||||
kubernetes.core.k8s:
|
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
|
||||||
@@ -155,27 +133,106 @@ 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="1">Key</th>
|
<th colspan="2">Key</th>
|
||||||
<th>Returned</th>
|
<th>Returned</th>
|
||||||
<th width="100%">Description</th>
|
<th width="100%">Description</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="2">
|
||||||
<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">
|
||||||
|
<span style="color: purple">complex</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
<td>
|
||||||
|
<div>One ore more object definitions returned from the tool execution.</div>
|
||||||
|
<br/>
|
||||||
|
</td>
|
||||||
|
</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">
|
<div style="font-size: small">
|
||||||
<span style="color: purple">string</span>
|
<span style="color: purple">string</span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td></td>
|
<td>success</td>
|
||||||
<td>
|
<td>
|
||||||
<div>YAML string for the object definitions returned from the tool execution.</div>
|
<div>The versioned schema of this representation of an object.</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>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/>
|
||||||
|
|
||||||
@@ -187,7 +244,7 @@ Status
|
|||||||
Authors
|
Authors
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
|
|
||||||
- Aubin Bikouo (@abikouo)
|
- Aubin Bikouo <@abikouo>
|
||||||
|
|
||||||
|
|
||||||
.. hint::
|
.. hint::
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ authors:
|
|||||||
- mmazur (https://github.com/mmazur)
|
- mmazur (https://github.com/mmazur)
|
||||||
- jamescassell (https://github.com/jamescassell)
|
- jamescassell (https://github.com/jamescassell)
|
||||||
description: Kubernetes Collection for Ansible.
|
description: Kubernetes Collection for Ansible.
|
||||||
documentation: ""
|
documentation: ''
|
||||||
homepage: ""
|
homepage: ''
|
||||||
issues: https://github.com/ansible-collections/kubernetes.core/issues
|
issues: https://github.com/ansible-collections/kubernetes.core/issues
|
||||||
license_file: LICENSE
|
license_file: LICENSE
|
||||||
namespace: kubernetes
|
namespace: kubernetes
|
||||||
@@ -25,7 +25,7 @@ tags:
|
|||||||
- openshift
|
- openshift
|
||||||
- okd
|
- okd
|
||||||
- cluster
|
- cluster
|
||||||
version: 5.3.0
|
version: 2.4.0
|
||||||
build_ignore:
|
build_ignore:
|
||||||
- .DS_Store
|
- .DS_Store
|
||||||
- "*.tar.gz"
|
- '*.tar.gz'
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
requires_ansible: '>=2.15.0'
|
requires_ansible: '>=2.9.17'
|
||||||
|
|
||||||
action_groups:
|
action_groups:
|
||||||
helm:
|
helm:
|
||||||
@@ -20,12 +20,6 @@ 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
|
||||||
|
|||||||
@@ -8,41 +8,54 @@ from __future__ import absolute_import, division, print_function
|
|||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
import os
|
|
||||||
import platform
|
|
||||||
import traceback
|
import traceback
|
||||||
|
import os
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
import platform
|
||||||
|
|
||||||
from ansible.config.manager import ensure_type
|
from ansible.config.manager import ensure_type
|
||||||
from ansible.errors import (
|
from ansible.errors import (
|
||||||
AnsibleAction,
|
|
||||||
AnsibleActionFail,
|
|
||||||
AnsibleError,
|
AnsibleError,
|
||||||
AnsibleFileNotFound,
|
AnsibleFileNotFound,
|
||||||
|
AnsibleAction,
|
||||||
|
AnsibleActionFail,
|
||||||
)
|
)
|
||||||
from ansible.module_utils._text import to_bytes, to_native, to_text
|
|
||||||
from ansible.module_utils.parsing.convert_bool import boolean
|
from ansible.module_utils.parsing.convert_bool import boolean
|
||||||
from ansible.module_utils.six import iteritems, string_types
|
from ansible.module_utils.six import string_types, iteritems
|
||||||
|
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 _from_yaml_to_definition(buffer):
|
def remove_omit(self, data):
|
||||||
try:
|
if isinstance(data, dict):
|
||||||
import yaml
|
result = dict()
|
||||||
except ImportError:
|
for key, value in iteritems(data):
|
||||||
raise AnsibleError("Failed to import the required Python library (PyYAML).")
|
if value == self.omit:
|
||||||
return list(yaml.safe_load_all(buffer))
|
continue
|
||||||
|
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"
|
||||||
|
|
||||||
@@ -195,6 +208,7 @@ 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))
|
||||||
@@ -217,18 +231,17 @@ class ActionModule(ActionBase):
|
|||||||
old_vars = self._templar.available_variables
|
old_vars = self._templar.available_variables
|
||||||
|
|
||||||
default_environment = {}
|
default_environment = {}
|
||||||
if trust_as_template is None:
|
for key in (
|
||||||
for key in (
|
"newline_sequence",
|
||||||
"newline_sequence",
|
"variable_start_string",
|
||||||
"variable_start_string",
|
"variable_end_string",
|
||||||
"variable_end_string",
|
"block_start_string",
|
||||||
"block_start_string",
|
"block_end_string",
|
||||||
"block_end_string",
|
"trim_blocks",
|
||||||
"trim_blocks",
|
"lstrip_blocks",
|
||||||
"lstrip_blocks",
|
):
|
||||||
):
|
if hasattr(self._templar.environment, key):
|
||||||
if hasattr(self._templar.environment, key):
|
default_environment[key] = getattr(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"]
|
||||||
@@ -245,35 +258,26 @@ 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:
|
||||||
overrides[key] = value
|
setattr(self._templar.environment, key, value)
|
||||||
if trust_as_template is None:
|
else:
|
||||||
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
|
||||||
if trust_as_template:
|
result = self._templar.do_template(
|
||||||
template_data = trust_as_template(template_data)
|
template_data,
|
||||||
result = self._templar.template(
|
preserve_trailing_newlines=True,
|
||||||
template_data,
|
escape_backslashes=False,
|
||||||
preserve_trailing_newlines=True,
|
)
|
||||||
escape_backslashes=False,
|
if omit_value is not None:
|
||||||
overrides=overrides,
|
result_template.extend(RemoveOmit(result, omit_value).output())
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
result = self._templar.do_template(
|
result_template.append(result)
|
||||||
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,15 +72,6 @@ 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)
|
||||||
@@ -181,93 +172,18 @@ 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.errors import AnsibleError, AnsibleFileNotFound
|
|
||||||
from ansible.module_utils._text import to_bytes
|
|
||||||
from ansible.module_utils.six.moves import shlex_quote
|
|
||||||
from ansible.parsing.yaml.loader import AnsibleLoader
|
from ansible.parsing.yaml.loader import AnsibleLoader
|
||||||
from ansible.plugins.connection import BUFSIZE, ConnectionBase
|
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.plugins.connection import ConnectionBase, BUFSIZE
|
||||||
from ansible.utils.display import Display
|
from ansible.utils.display import Display
|
||||||
|
|
||||||
display = Display()
|
display = Display()
|
||||||
@@ -385,19 +301,6 @@ 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()
|
||||||
@@ -426,7 +329,6 @@ 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)
|
||||||
@@ -476,11 +378,7 @@ 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,
|
args, stdin=in_file, stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
stdin=in_file,
|
|
||||||
stdout=subprocess.PIPE,
|
|
||||||
stderr=subprocess.PIPE,
|
|
||||||
env=self._local_env(),
|
|
||||||
)
|
)
|
||||||
except OSError:
|
except OSError:
|
||||||
raise AnsibleError(
|
raise AnsibleError(
|
||||||
@@ -517,11 +415,7 @@ class Connection(ConnectionBase):
|
|||||||
) as out_file:
|
) as out_file:
|
||||||
try:
|
try:
|
||||||
p = subprocess.Popen(
|
p = subprocess.Popen(
|
||||||
args,
|
args, stdin=subprocess.PIPE, stdout=out_file, stderr=subprocess.PIPE
|
||||||
stdin=subprocess.PIPE,
|
|
||||||
stdout=out_file,
|
|
||||||
stderr=subprocess.PIPE,
|
|
||||||
env=self._local_env(),
|
|
||||||
)
|
)
|
||||||
except OSError:
|
except OSError:
|
||||||
raise AnsibleError(
|
raise AnsibleError(
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ __metaclass__ = type
|
|||||||
|
|
||||||
|
|
||||||
class ModuleDocFragment(object):
|
class ModuleDocFragment(object):
|
||||||
|
|
||||||
DOCUMENTATION = r"""
|
DOCUMENTATION = r"""
|
||||||
options:
|
options:
|
||||||
binary_path:
|
binary_path:
|
||||||
@@ -36,12 +37,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)
|
||||||
@@ -49,12 +50,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,6 +11,7 @@ __metaclass__ = type
|
|||||||
|
|
||||||
|
|
||||||
class ModuleDocFragment(object):
|
class ModuleDocFragment(object):
|
||||||
|
|
||||||
DOCUMENTATION = r"""
|
DOCUMENTATION = r"""
|
||||||
options:
|
options:
|
||||||
host:
|
host:
|
||||||
|
|||||||
@@ -11,11 +11,12 @@ __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,6 +11,7 @@ __metaclass__ = type
|
|||||||
|
|
||||||
|
|
||||||
class ModuleDocFragment(object):
|
class ModuleDocFragment(object):
|
||||||
|
|
||||||
DOCUMENTATION = r"""
|
DOCUMENTATION = r"""
|
||||||
options:
|
options:
|
||||||
api_version:
|
api_version:
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ __metaclass__ = type
|
|||||||
|
|
||||||
|
|
||||||
class ModuleDocFragment(object):
|
class ModuleDocFragment(object):
|
||||||
|
|
||||||
DOCUMENTATION = r"""
|
DOCUMENTATION = r"""
|
||||||
options:
|
options:
|
||||||
resource_definition:
|
resource_definition:
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ __metaclass__ = type
|
|||||||
|
|
||||||
|
|
||||||
class ModuleDocFragment(object):
|
class ModuleDocFragment(object):
|
||||||
|
|
||||||
DOCUMENTATION = r"""
|
DOCUMENTATION = r"""
|
||||||
options:
|
options:
|
||||||
replicas:
|
replicas:
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ __metaclass__ = type
|
|||||||
|
|
||||||
|
|
||||||
class ModuleDocFragment(object):
|
class ModuleDocFragment(object):
|
||||||
|
|
||||||
DOCUMENTATION = r"""
|
DOCUMENTATION = r"""
|
||||||
options:
|
options:
|
||||||
state:
|
state:
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ __metaclass__ = type
|
|||||||
|
|
||||||
|
|
||||||
class ModuleDocFragment(object):
|
class ModuleDocFragment(object):
|
||||||
|
|
||||||
DOCUMENTATION = r"""
|
DOCUMENTATION = r"""
|
||||||
options:
|
options:
|
||||||
wait:
|
wait:
|
||||||
|
|||||||
@@ -19,13 +19,6 @@ 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.
|
||||||
@@ -93,50 +86,50 @@ DOCUMENTATION = """
|
|||||||
to access.
|
to access.
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "python >= 3.9"
|
- "python >= 3.6"
|
||||||
- "kubernetes >= 24.2.0"
|
- "kubernetes >= 12.0.0"
|
||||||
- "PyYAML >= 3.11"
|
- "PyYAML >= 3.11"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = r"""
|
EXAMPLES = """
|
||||||
# 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
|
# 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
|
||||||
|
|
||||||
- name: Use default config (~/.kube/config) file and active context, and return objects for a specific namespace
|
# 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
|
||||||
|
|
||||||
- name: Use a custom config file, and a specific context.
|
# 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'
|
||||||
"""
|
"""
|
||||||
|
|
||||||
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 (
|
||||||
|
HAS_K8S_MODULE_HELPER,
|
||||||
try:
|
k8s_import_exception,
|
||||||
from kubernetes.dynamic.exceptions import DynamicApiError
|
)
|
||||||
|
|
||||||
HAS_K8S_MODULE_HELPER = True
|
|
||||||
k8s_import_exception = None
|
|
||||||
except ImportError as e:
|
|
||||||
HAS_K8S_MODULE_HELPER = False
|
|
||||||
k8s_import_exception = e
|
|
||||||
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:
|
||||||
|
from kubernetes.dynamic.exceptions import DynamicApiError
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def format_dynamic_api_exc(exc):
|
def format_dynamic_api_exc(exc):
|
||||||
@@ -162,12 +155,6 @@ 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)
|
||||||
@@ -193,6 +180,7 @@ 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.9"
|
- "python >= 3.6"
|
||||||
- "kubernetes >= 24.2.0"
|
- "kubernetes >= 12.0.0"
|
||||||
- "PyYAML >= 3.11"
|
- "PyYAML >= 3.11"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -179,6 +179,7 @@ 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,
|
||||||
)
|
)
|
||||||
@@ -213,6 +214,7 @@ 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,10 +30,6 @@ 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"
|
||||||
@@ -41,20 +37,16 @@ DOCUMENTATION = """
|
|||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
- name: Run lookup using kustomize
|
- name: Run lookup using kustomize
|
||||||
ansible.builtin.set_fact:
|
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
|
||||||
ansible.builtin.set_fact:
|
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
|
||||||
kubernetes.core.k8s:
|
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 = """
|
||||||
@@ -72,11 +64,12 @@ RETURN = """
|
|||||||
key1: val1
|
key1: val1
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
from ansible.errors import AnsibleLookupError
|
from ansible.errors import AnsibleLookupError
|
||||||
from ansible.module_utils.common.process import get_bin_path
|
|
||||||
from ansible.plugins.lookup import LookupBase
|
from ansible.plugins.lookup import LookupBase
|
||||||
|
from ansible.module_utils.common.process import get_bin_path
|
||||||
|
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
def get_binary_from_path(name, opt_dirs=None):
|
def get_binary_from_path(name, opt_dirs=None):
|
||||||
@@ -94,20 +87,12 @@ 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)
|
||||||
stdout, stderr = cmd.communicate()
|
return cmd.communicate()
|
||||||
return cmd.returncode, stdout, stderr
|
|
||||||
|
|
||||||
|
|
||||||
class LookupModule(LookupBase):
|
class LookupModule(LookupBase):
|
||||||
def run(
|
def run(
|
||||||
self,
|
self, terms, variables=None, dir=".", binary_path=None, opt_dirs=None, **kwargs
|
||||||
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:
|
||||||
@@ -138,21 +123,9 @@ class LookupModule(LookupBase):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if enable_helm:
|
(out, err) = run_command(command)
|
||||||
command += ["--enable-helm"]
|
if err:
|
||||||
|
raise AnsibleLookupError(
|
||||||
(ret, out, err) = run_command(command)
|
"kustomize command failed with: {0}".format(err.decode("utf-8"))
|
||||||
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 ( # noqa: F401
|
from ansible_collections.cloud.common.plugins.module_utils.turbo.module import (
|
||||||
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
|
||||||
|
|
||||||
import json
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
import json
|
||||||
|
|
||||||
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,6 +31,7 @@ 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:
|
||||||
@@ -149,7 +150,6 @@ def k8s_apply(resource, definition, **kwargs):
|
|||||||
force_conflicts=kwargs.get("force_conflicts"),
|
force_conflicts=kwargs.get("force_conflicts"),
|
||||||
field_manager=kwargs.get("field_manager"),
|
field_manager=kwargs.get("field_manager"),
|
||||||
dry_run=kwargs.get("dry_run"),
|
dry_run=kwargs.get("dry_run"),
|
||||||
serialize=kwargs.get("serialize"),
|
|
||||||
)
|
)
|
||||||
if not existing:
|
if not existing:
|
||||||
return resource.create(
|
return resource.create(
|
||||||
@@ -159,7 +159,6 @@ def k8s_apply(resource, definition, **kwargs):
|
|||||||
return resource.get(
|
return resource.get(
|
||||||
name=definition["metadata"]["name"],
|
name=definition["metadata"]["name"],
|
||||||
namespace=definition["metadata"].get("namespace"),
|
namespace=definition["metadata"].get("namespace"),
|
||||||
**kwargs
|
|
||||||
)
|
)
|
||||||
return resource.patch(
|
return resource.patch(
|
||||||
body=desired,
|
body=desired,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ AUTH_PROXY_HEADERS_SPEC = dict(
|
|||||||
)
|
)
|
||||||
|
|
||||||
AUTH_ARG_SPEC = {
|
AUTH_ARG_SPEC = {
|
||||||
"kubeconfig": {"type": "raw", "no_log": True},
|
"kubeconfig": {"type": "raw"},
|
||||||
"context": {},
|
"context": {},
|
||||||
"host": {},
|
"host": {},
|
||||||
"api_key": {"no_log": True},
|
"api_key": {"no_log": True},
|
||||||
|
|||||||
@@ -13,18 +13,15 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
import hashlib
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import tempfile
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
import hashlib
|
||||||
|
import tempfile
|
||||||
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,
|
||||||
@@ -32,6 +29,10 @@ 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):
|
||||||
@@ -113,7 +114,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("/", 1)
|
resource, name = subresource["name"].split("/")
|
||||||
subresources[resource][name] = subresource
|
subresources[resource][name] = subresource
|
||||||
|
|
||||||
for resource in resources_raw:
|
for resource in resources_raw:
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -18,26 +18,25 @@ from __future__ import absolute_import, division, print_function
|
|||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import tarfile
|
from tempfile import TemporaryFile, NamedTemporaryFile
|
||||||
from abc import ABCMeta, abstractmethod
|
|
||||||
from select import select
|
from select import select
|
||||||
from tempfile import NamedTemporaryFile, TemporaryFile
|
from abc import ABCMeta, abstractmethod
|
||||||
|
import tarfile
|
||||||
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 (
|
||||||
ABNF,
|
|
||||||
ERROR_CHANNEL,
|
|
||||||
STDERR_CHANNEL,
|
|
||||||
STDOUT_CHANNEL,
|
STDOUT_CHANNEL,
|
||||||
|
STDERR_CHANNEL,
|
||||||
|
ERROR_CHANNEL,
|
||||||
|
ABNF,
|
||||||
)
|
)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ from __future__ import absolute_import, division, print_function
|
|||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
import hashlib
|
|
||||||
import json
|
import json
|
||||||
|
import hashlib
|
||||||
|
|
||||||
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,18 +7,19 @@ 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 AnsibleModule, missing_required_lib
|
from ansible.module_utils.basic import 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
|
||||||
@@ -77,11 +78,13 @@ 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")
|
||||||
@@ -114,7 +117,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(os.path.expanduser(kubeconfig)) as fd:
|
with open(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
|
||||||
@@ -159,13 +162,11 @@ class AnsibleHelmModule(object):
|
|||||||
self.helm_env = self._prepare_helm_environment()
|
self.helm_env = self._prepare_helm_environment()
|
||||||
return self.helm_env
|
return self.helm_env
|
||||||
|
|
||||||
def run_helm_command(self, command, fails_on_error=True, data=None):
|
def run_helm_command(self, command, fails_on_error=True):
|
||||||
if not HAS_YAML:
|
if not HAS_YAML:
|
||||||
self.fail_json(msg=missing_required_lib("PyYAML"), exception=YAML_IMP_ERR)
|
self.fail_json(msg=missing_required_lib("PyYAML"), exception=YAML_IMP_ERR)
|
||||||
|
|
||||||
rc, out, err = self.run_command(
|
rc, out, err = self.run_command(command, environ_update=self.env_update)
|
||||||
command, environ_update=self.env_update, data=data
|
|
||||||
)
|
|
||||||
if fails_on_error and rc != 0:
|
if fails_on_error and rc != 0:
|
||||||
self.fail_json(
|
self.fail_json(
|
||||||
msg="Failure when executing Helm command. Exited {0}.\nstdout: {1}\nstderr: {2}".format(
|
msg="Failure when executing Helm command. Exited {0}.\nstdout: {1}\nstderr: {2}".format(
|
||||||
@@ -183,12 +184,13 @@ 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(.*?)",', out)
|
m = re.match(r'version.BuildInfo{Version:"v([0-9\.]*)",', out)
|
||||||
if m:
|
if m:
|
||||||
return m.group(1)
|
return m.group(1)
|
||||||
m = re.match(r'Client: &version.Version{SemVer:"v(.*?)", ', out)
|
m = re.match(r'Client: &version.Version{SemVer:"v([0-9\.]*)", ', out)
|
||||||
if m:
|
if m:
|
||||||
return m.group(1)
|
return m.group(1)
|
||||||
return None
|
return None
|
||||||
@@ -214,6 +216,7 @@ 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)
|
||||||
|
|
||||||
@@ -225,6 +228,7 @@ 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",
|
||||||
@@ -237,6 +241,7 @@ 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,7 +16,6 @@ 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,11 +1,12 @@
|
|||||||
# 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 hashlib
|
|
||||||
import os
|
import os
|
||||||
|
import hashlib
|
||||||
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,12 +1,15 @@
|
|||||||
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.
|
||||||
@@ -35,7 +38,7 @@ class AnsibleK8SModule:
|
|||||||
|
|
||||||
if self.settings["check_k8s"]:
|
if self.settings["check_k8s"]:
|
||||||
self.requires("kubernetes")
|
self.requires("kubernetes")
|
||||||
self.has_at_least("kubernetes", "24.2.0", warn=True)
|
self.has_at_least("kubernetes", "12.0.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 Dict, Iterable, List, Optional, Union, cast
|
from typing import cast, Dict, Iterable, List, Optional, Union
|
||||||
|
|
||||||
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,7 +17,9 @@ 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 (
|
||||||
@@ -44,51 +46,16 @@ 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 = get_definitions(svc, module.params)
|
definitions = create_definitions(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": {}}
|
||||||
@@ -135,11 +102,9 @@ 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 = {}
|
||||||
warnings = []
|
|
||||||
|
|
||||||
resource = svc.find_resource(kind, api_version, fail=True)
|
resource = svc.find_resource(kind, api_version, fail=True)
|
||||||
definition["kind"] = resource.kind
|
definition["kind"] = resource.kind
|
||||||
@@ -173,7 +138,7 @@ def perform_action(svc, definition: Dict, params: Dict) -> Dict:
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
if params.get("apply"):
|
if params.get("apply"):
|
||||||
instance, warnings = svc.apply(resource, definition, existing)
|
instance = svc.apply(resource, definition, existing)
|
||||||
result["method"] = "apply"
|
result["method"] = "apply"
|
||||||
elif not existing:
|
elif not existing:
|
||||||
if state == "patched":
|
if state == "patched":
|
||||||
@@ -184,19 +149,16 @@ def perform_action(svc, definition: Dict, params: Dict) -> Dict:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
return result
|
return result
|
||||||
instance, warnings = svc.create(resource, definition)
|
instance = svc.create(resource, definition)
|
||||||
result["method"] = "create"
|
result["method"] = "create"
|
||||||
result["changed"] = True
|
result["changed"] = True
|
||||||
elif params.get("force", False):
|
elif params.get("force", False):
|
||||||
instance, warnings = svc.replace(resource, definition, existing)
|
instance = svc.replace(resource, definition, existing)
|
||||||
result["method"] = "replace"
|
result["method"] = "replace"
|
||||||
else:
|
else:
|
||||||
instance, warnings = svc.update(resource, definition, existing)
|
instance = svc.update(resource, definition, existing)
|
||||||
result["method"] = "update"
|
result["method"] = "update"
|
||||||
|
|
||||||
if warnings:
|
|
||||||
result["warnings"] = warnings
|
|
||||||
|
|
||||||
# If needed, wait and/or create diff
|
# If needed, wait and/or create diff
|
||||||
success = True
|
success = True
|
||||||
|
|
||||||
@@ -215,7 +177,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, hidden_fields)
|
match, diffs = diff_objects(existing, instance)
|
||||||
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 "
|
||||||
@@ -225,7 +187,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"] = hide_fields(instance, hidden_fields)
|
result["result"] = instance
|
||||||
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,35 +1,38 @@
|
|||||||
# 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 json import loads
|
|
||||||
from re import compile
|
|
||||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
|
||||||
|
|
||||||
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.exceptions import (
|
|
||||||
CoreException,
|
|
||||||
)
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.waiter import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.waiter import (
|
||||||
Waiter,
|
Waiter,
|
||||||
exists,
|
exists,
|
||||||
get_waiter,
|
|
||||||
resource_absent,
|
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 (
|
||||||
|
CoreException,
|
||||||
|
)
|
||||||
|
|
||||||
|
from ansible.module_utils.common.dict_transformations import dict_merge
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from kubernetes.dynamic.exceptions import (
|
from kubernetes.dynamic.exceptions import (
|
||||||
BadRequestError,
|
|
||||||
ConflictError,
|
|
||||||
ForbiddenError,
|
|
||||||
MethodNotAllowedError,
|
|
||||||
NotFoundError,
|
NotFoundError,
|
||||||
ResourceNotFoundError,
|
ResourceNotFoundError,
|
||||||
ResourceNotUniqueError,
|
ResourceNotUniqueError,
|
||||||
|
ConflictError,
|
||||||
|
ForbiddenError,
|
||||||
|
MethodNotAllowedError,
|
||||||
|
BadRequestError,
|
||||||
)
|
)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# Handled in module setup
|
# Handled in module setup
|
||||||
@@ -144,12 +147,18 @@ class K8sService:
|
|||||||
name: str,
|
name: str,
|
||||||
namespace: str,
|
namespace: str,
|
||||||
merge_type: str = None,
|
merge_type: str = None,
|
||||||
) -> Tuple[Dict, List[str]]:
|
) -> Dict:
|
||||||
|
if merge_type == "json":
|
||||||
|
self.module.deprecate(
|
||||||
|
msg="json as a merge_type value is deprecated. Please use the k8s_json_patch module instead.",
|
||||||
|
version="3.0.0",
|
||||||
|
collection_name="kubernetes.core",
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
params = dict(name=name, namespace=namespace, serialize=False)
|
params = dict(name=name, namespace=namespace)
|
||||||
if merge_type:
|
if merge_type:
|
||||||
params["content_type"] = "application/{0}-patch+json".format(merge_type)
|
params["content_type"] = "application/{0}-patch+json".format(merge_type)
|
||||||
return decode_response(self.client.patch(resource, definition, **params))
|
return self.client.patch(resource, definition, **params).to_dict()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
reason = e.body if hasattr(e, "body") else e
|
reason = e.body if hasattr(e, "body") else e
|
||||||
msg = "Failed to patch object: {0}".format(reason)
|
msg = "Failed to patch object: {0}".format(reason)
|
||||||
@@ -202,30 +211,6 @@ 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,
|
||||||
@@ -239,7 +224,6 @@ 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)
|
||||||
@@ -302,9 +286,7 @@ class K8sService:
|
|||||||
instances = resources.get("items") or [resources]
|
instances = resources.get("items") or [resources]
|
||||||
|
|
||||||
if not wait:
|
if not wait:
|
||||||
result["resources"] = [
|
result["resources"] = instances
|
||||||
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.
|
||||||
@@ -323,127 +305,126 @@ 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(hide_fields(res, hidden_fields))
|
result["resources"].append(res)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def create(self, resource: Resource, definition: Dict) -> Tuple[Dict, List[str]]:
|
def create(self, resource: Resource, definition: Dict) -> Dict:
|
||||||
namespace = definition["metadata"].get("namespace")
|
namespace = definition["metadata"].get("namespace")
|
||||||
name = definition["metadata"].get("name")
|
name = definition["metadata"].get("name")
|
||||||
|
|
||||||
if self._client_side_dry_run:
|
if self._client_side_dry_run:
|
||||||
return _encode_stringdata(definition), []
|
k8s_obj = _encode_stringdata(definition)
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
return decode_response(
|
k8s_obj = self.client.create(
|
||||||
self.client.create(
|
resource, definition, namespace=namespace
|
||||||
resource, definition, namespace=namespace, serialize=False
|
).to_dict()
|
||||||
|
except ConflictError:
|
||||||
|
# Some resources, like ProjectRequests, can't be created multiple times,
|
||||||
|
# because the resources that they create don't match their kind
|
||||||
|
# In this case we'll mark it as unchanged and warn the user
|
||||||
|
self.module.warn(
|
||||||
|
"{0} was not found, but creating it returned a 409 Conflict error. This can happen \
|
||||||
|
if the resource you are creating does not directly create a resource of the same kind.".format(
|
||||||
|
name
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
return dict()
|
||||||
except ConflictError:
|
except Exception as e:
|
||||||
# Some resources, like ProjectRequests, can't be created multiple times,
|
reason = e.body if hasattr(e, "body") else e
|
||||||
# because the resources that they create don't match their kind
|
msg = "Failed to create object: {0}".format(reason)
|
||||||
# In this case we'll mark it as unchanged and warn the user
|
raise CoreException(msg) from e
|
||||||
self.module.warn(
|
return k8s_obj
|
||||||
"{0} was not found, but creating it returned a 409 Conflict error. This can happen \
|
|
||||||
if the resource you are creating does not directly create a resource of the same kind.".format(
|
|
||||||
name
|
|
||||||
)
|
|
||||||
)
|
|
||||||
return dict(), []
|
|
||||||
except Exception as e:
|
|
||||||
reason = e.body if hasattr(e, "body") else e
|
|
||||||
msg = "Failed to create object: {0}".format(reason)
|
|
||||||
raise CoreException(msg) from e
|
|
||||||
|
|
||||||
def apply(
|
def apply(
|
||||||
self,
|
self,
|
||||||
resource: Resource,
|
resource: Resource,
|
||||||
definition: Dict,
|
definition: Dict,
|
||||||
existing: Optional[ResourceInstance] = None,
|
existing: Optional[ResourceInstance] = None,
|
||||||
) -> Tuple[Dict, List[str]]:
|
) -> Dict:
|
||||||
namespace = definition["metadata"].get("namespace")
|
namespace = definition["metadata"].get("namespace")
|
||||||
|
|
||||||
server_side_apply = self.module.params.get("server_side_apply")
|
server_side_apply = self.module.params.get("server_side_apply")
|
||||||
if server_side_apply:
|
if server_side_apply:
|
||||||
requires("kubernetes", "19.15.0", reason="to use server side apply")
|
requires("kubernetes", "19.15.0", reason="to use server side apply")
|
||||||
|
|
||||||
if self._client_side_dry_run:
|
if self._client_side_dry_run:
|
||||||
ignored, patch = apply_object(resource, _encode_stringdata(definition))
|
ignored, patch = apply_object(resource, _encode_stringdata(definition))
|
||||||
if existing:
|
if existing:
|
||||||
return dict_merge(existing.to_dict(), patch), []
|
k8s_obj = dict_merge(existing.to_dict(), patch)
|
||||||
else:
|
else:
|
||||||
return patch, []
|
k8s_obj = patch
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
params = {}
|
params = {}
|
||||||
if server_side_apply:
|
if server_side_apply:
|
||||||
params["server_side"] = True
|
params["server_side"] = True
|
||||||
params.update(server_side_apply)
|
params.update(server_side_apply)
|
||||||
return decode_response(
|
k8s_obj = self.client.apply(
|
||||||
self.client.apply(
|
resource, definition, namespace=namespace, **params
|
||||||
resource, definition, namespace=namespace, serialize=False, **params
|
).to_dict()
|
||||||
)
|
except Exception as e:
|
||||||
)
|
reason = e.body if hasattr(e, "body") else e
|
||||||
except Exception as e:
|
msg = "Failed to apply object: {0}".format(reason)
|
||||||
reason = e.body if hasattr(e, "body") else e
|
raise CoreException(msg) from e
|
||||||
msg = "Failed to apply object: {0}".format(reason)
|
return k8s_obj
|
||||||
raise CoreException(msg) from e
|
|
||||||
|
|
||||||
def replace(
|
def replace(
|
||||||
self,
|
self,
|
||||||
resource: Resource,
|
resource: Resource,
|
||||||
definition: Dict,
|
definition: Dict,
|
||||||
existing: ResourceInstance,
|
existing: ResourceInstance,
|
||||||
) -> Tuple[Dict, List[str]]:
|
) -> Dict:
|
||||||
append_hash = self.module.params.get("append_hash", False)
|
append_hash = self.module.params.get("append_hash", False)
|
||||||
name = definition["metadata"].get("name")
|
name = definition["metadata"].get("name")
|
||||||
namespace = definition["metadata"].get("namespace")
|
namespace = definition["metadata"].get("namespace")
|
||||||
|
|
||||||
if self._client_side_dry_run:
|
if self._client_side_dry_run:
|
||||||
return _encode_stringdata(definition), []
|
k8s_obj = _encode_stringdata(definition)
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
return decode_response(
|
k8s_obj = self.client.replace(
|
||||||
self.client.replace(
|
|
||||||
resource,
|
resource,
|
||||||
definition,
|
definition,
|
||||||
name=name,
|
name=name,
|
||||||
namespace=namespace,
|
namespace=namespace,
|
||||||
append_hash=append_hash,
|
append_hash=append_hash,
|
||||||
serialize=False,
|
).to_dict()
|
||||||
)
|
except Exception as e:
|
||||||
)
|
reason = e.body if hasattr(e, "body") else e
|
||||||
except Exception as e:
|
msg = "Failed to replace object: {0}".format(reason)
|
||||||
reason = e.body if hasattr(e, "body") else e
|
raise CoreException(msg) from e
|
||||||
msg = "Failed to replace object: {0}".format(reason)
|
return k8s_obj
|
||||||
raise CoreException(msg) from e
|
|
||||||
|
|
||||||
def update(
|
def update(
|
||||||
self, resource: Resource, definition: Dict, existing: ResourceInstance
|
self, resource: Resource, definition: Dict, existing: ResourceInstance
|
||||||
) -> Tuple[Dict, List[str]]:
|
) -> Dict:
|
||||||
name = definition["metadata"].get("name")
|
name = definition["metadata"].get("name")
|
||||||
namespace = definition["metadata"].get("namespace")
|
namespace = definition["metadata"].get("namespace")
|
||||||
|
|
||||||
if self._client_side_dry_run:
|
if self._client_side_dry_run:
|
||||||
return dict_merge(existing.to_dict(), _encode_stringdata(definition)), []
|
k8s_obj = dict_merge(existing.to_dict(), _encode_stringdata(definition))
|
||||||
|
else:
|
||||||
exception = None
|
exception = None
|
||||||
for merge_type in self.module.params.get("merge_type") or [
|
for merge_type in self.module.params.get("merge_type") or [
|
||||||
"strategic-merge",
|
"strategic-merge",
|
||||||
"merge",
|
"merge",
|
||||||
]:
|
]:
|
||||||
try:
|
try:
|
||||||
return self.patch_resource(
|
k8s_obj = self.patch_resource(
|
||||||
resource,
|
resource,
|
||||||
definition,
|
definition,
|
||||||
name,
|
name,
|
||||||
namespace,
|
namespace,
|
||||||
merge_type=merge_type,
|
merge_type=merge_type,
|
||||||
)
|
)
|
||||||
except CoreException as e:
|
exception = None
|
||||||
exception = e
|
except CoreException as e:
|
||||||
continue
|
exception = e
|
||||||
raise exception
|
continue
|
||||||
|
break
|
||||||
|
if exception:
|
||||||
|
raise exception
|
||||||
|
return k8s_obj
|
||||||
|
|
||||||
def delete(
|
def delete(
|
||||||
self,
|
self,
|
||||||
@@ -473,7 +454,7 @@ class K8sService:
|
|||||||
if label_selectors:
|
if label_selectors:
|
||||||
params["label_selector"] = ",".join(label_selectors)
|
params["label_selector"] = ",".join(label_selectors)
|
||||||
|
|
||||||
if delete_options and not self.module.check_mode:
|
if delete_options:
|
||||||
body = {
|
body = {
|
||||||
"apiVersion": "v1",
|
"apiVersion": "v1",
|
||||||
"kind": "DeleteOptions",
|
"kind": "DeleteOptions",
|
||||||
@@ -490,9 +471,7 @@ class K8sService:
|
|||||||
return k8s_obj
|
return k8s_obj
|
||||||
|
|
||||||
|
|
||||||
def diff_objects(
|
def diff_objects(existing: Dict, new: Dict) -> Tuple[bool, Dict]:
|
||||||
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:
|
||||||
@@ -501,214 +480,17 @@ def diff_objects(
|
|||||||
result["before"] = diff[0]
|
result["before"] = diff[0]
|
||||||
result["after"] = diff[1]
|
result["after"] = diff[1]
|
||||||
|
|
||||||
if list(result["after"].keys()) == ["metadata"] and list(
|
if list(result["after"].keys()) != ["metadata"] or list(
|
||||||
result["before"].keys()
|
result["before"].keys()
|
||||||
) == ["metadata"]:
|
) != ["metadata"]:
|
||||||
# If only metadata.generation and metadata.resourceVersion changed, ignore it
|
return False, result
|
||||||
ignored_keys = set(["generation", "resourceVersion"])
|
|
||||||
|
|
||||||
if set(result["after"]["metadata"].keys()).issubset(ignored_keys) and set(
|
# If only metadata.generation and metadata.resourceVersion changed, ignore it
|
||||||
result["before"]["metadata"].keys()
|
ignored_keys = set(["generation", "resourceVersion"])
|
||||||
).issubset(ignored_keys):
|
|
||||||
return True, result
|
|
||||||
|
|
||||||
result["before"] = hide_fields(result["before"], hidden_fields)
|
if not set(result["after"]["metadata"].keys()).issubset(ignored_keys):
|
||||||
result["after"] = hide_fields(result["after"], hidden_fields)
|
return False, result
|
||||||
|
if not set(result["before"]["metadata"].keys()).issubset(ignored_keys):
|
||||||
|
return False, result
|
||||||
|
|
||||||
return False, result
|
return True, result
|
||||||
|
|
||||||
|
|
||||||
def hide_field_tree(hidden_field: str) -> List[str]:
|
|
||||||
result = []
|
|
||||||
key, rest = hide_field_split2(hidden_field)
|
|
||||||
result.append(key)
|
|
||||||
while rest:
|
|
||||||
key, rest = hide_field_split2(rest)
|
|
||||||
result.append(key)
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
def build_hidden_field_tree(hidden_fields: List[str]) -> Dict[str, Any]:
|
|
||||||
"""Group hidden field targeting the same json key
|
|
||||||
Example:
|
|
||||||
Input: ['env[3]', 'env[0]']
|
|
||||||
Output: {'env': [0, 3]}
|
|
||||||
"""
|
|
||||||
output = {}
|
|
||||||
for hidden_field in hidden_fields:
|
|
||||||
current = output
|
|
||||||
tree = hide_field_tree(hidden_field)
|
|
||||||
for idx, key in enumerate(tree):
|
|
||||||
if current.get(key, "") is None:
|
|
||||||
break
|
|
||||||
if idx == (len(tree) - 1):
|
|
||||||
current[key] = None
|
|
||||||
elif key not in current:
|
|
||||||
current[key] = {}
|
|
||||||
current = current[key]
|
|
||||||
return output
|
|
||||||
|
|
||||||
|
|
||||||
# hide_field should be able to cope with simple or more complicated
|
|
||||||
# field definitions
|
|
||||||
# e.g. status or metadata.managedFields or
|
|
||||||
# spec.template.spec.containers[0].env[3].value or
|
|
||||||
# metadata.annotations[kubectl.kubernetes.io/last-applied-configuration]
|
|
||||||
def hide_field(
|
|
||||||
definition: Union[Dict[str, Any], List[Any]], hidden_field: Dict[str, Any]
|
|
||||||
) -> Dict[str, Any]:
|
|
||||||
def dict_contains_key(obj: Dict[str, Any], key: str) -> bool:
|
|
||||||
return key in obj
|
|
||||||
|
|
||||||
def list_contains_key(obj: List[Any], key: str) -> bool:
|
|
||||||
return int(key) < len(obj)
|
|
||||||
|
|
||||||
hidden_keys = list(hidden_field.keys())
|
|
||||||
field_contains_key = dict_contains_key
|
|
||||||
field_get_key = str
|
|
||||||
if isinstance(definition, list):
|
|
||||||
# Sort with reverse=true so that when we delete an item from the list, the order is not changed
|
|
||||||
hidden_keys = sorted(
|
|
||||||
[k for k in hidden_field.keys() if k.isdecimal()], reverse=True
|
|
||||||
)
|
|
||||||
field_contains_key = list_contains_key
|
|
||||||
field_get_key = int
|
|
||||||
|
|
||||||
for key in hidden_keys:
|
|
||||||
if field_contains_key(definition, key):
|
|
||||||
value = hidden_field.get(key)
|
|
||||||
convert_key = field_get_key(key)
|
|
||||||
if value is None:
|
|
||||||
del definition[convert_key]
|
|
||||||
else:
|
|
||||||
definition[convert_key] = hide_field(definition[convert_key], value)
|
|
||||||
if (
|
|
||||||
definition[convert_key] == dict()
|
|
||||||
or definition[convert_key] == list()
|
|
||||||
):
|
|
||||||
del definition[convert_key]
|
|
||||||
|
|
||||||
return definition
|
|
||||||
|
|
||||||
|
|
||||||
def hide_fields(
|
|
||||||
definition: Dict[str, Any], hidden_fields: Optional[List[str]]
|
|
||||||
) -> Dict[str, Any]:
|
|
||||||
if not hidden_fields:
|
|
||||||
return definition
|
|
||||||
result = copy.deepcopy(definition)
|
|
||||||
hidden_field_tree = build_hidden_field_tree(hidden_fields)
|
|
||||||
return hide_field(result, hidden_field_tree)
|
|
||||||
|
|
||||||
|
|
||||||
def decode_response(resp) -> Tuple[Dict, List[str]]:
|
|
||||||
"""
|
|
||||||
This function decodes unserialized responses from the Kubernetes python
|
|
||||||
client and decodes the RFC2616 14.46 warnings found in the response
|
|
||||||
headers.
|
|
||||||
"""
|
|
||||||
obj = ResourceInstance(None, loads(resp.data.decode("utf8"))).to_dict()
|
|
||||||
warnings = []
|
|
||||||
if (
|
|
||||||
resp.headers is not None
|
|
||||||
and "warning" in resp.headers
|
|
||||||
and resp.headers["warning"] is not None
|
|
||||||
):
|
|
||||||
warnings = resp.headers["warning"].split(", ")
|
|
||||||
return obj, decode_warnings(warnings)
|
|
||||||
|
|
||||||
|
|
||||||
def decode_warnings(warnings: str) -> List[str]:
|
|
||||||
"""
|
|
||||||
This function decodes RFC2616 14.46 warnings in a simplified way, where
|
|
||||||
only the warn-texts are returned in a list.
|
|
||||||
"""
|
|
||||||
p = compile('\\d{3} .+ (".+")')
|
|
||||||
|
|
||||||
decoded = []
|
|
||||||
for warning in warnings:
|
|
||||||
m = p.match(warning)
|
|
||||||
if m:
|
|
||||||
try:
|
|
||||||
parsed, unused = parse_quoted_string(m.group(1))
|
|
||||||
decoded.append(parsed)
|
|
||||||
except ValueError:
|
|
||||||
continue
|
|
||||||
|
|
||||||
return decoded
|
|
||||||
|
|
||||||
|
|
||||||
def parse_quoted_string(quoted_string: str) -> Tuple[str, str]:
|
|
||||||
"""
|
|
||||||
This function was adapted from:
|
|
||||||
https://github.com/kubernetes/apimachinery/blob/bb8822152cabfb4f34dbc26270f874ce53db50de/pkg/util/net/http.go#L609
|
|
||||||
"""
|
|
||||||
if len(quoted_string) == 0:
|
|
||||||
raise ValueError("invalid quoted string: 0-length")
|
|
||||||
|
|
||||||
if quoted_string[0] != '"':
|
|
||||||
raise ValueError("invalid quoted string: missing initial quote")
|
|
||||||
|
|
||||||
quoted_string = quoted_string[1:]
|
|
||||||
remainder = ""
|
|
||||||
escaping = False
|
|
||||||
closed_quote = False
|
|
||||||
result = []
|
|
||||||
|
|
||||||
for i, b in enumerate(quoted_string):
|
|
||||||
if b == '"':
|
|
||||||
if escaping:
|
|
||||||
result.append(b)
|
|
||||||
escaping = False
|
|
||||||
else:
|
|
||||||
closed_quote = True
|
|
||||||
remainder_start = i + 1
|
|
||||||
remainder = quoted_string[remainder_start:].strip()
|
|
||||||
break
|
|
||||||
elif b == "\\":
|
|
||||||
if escaping:
|
|
||||||
result.append(b)
|
|
||||||
escaping = False
|
|
||||||
else:
|
|
||||||
escaping = True
|
|
||||||
else:
|
|
||||||
result.append(b)
|
|
||||||
escaping = False
|
|
||||||
|
|
||||||
if not closed_quote:
|
|
||||||
raise ValueError("invalid quoted string: missing closing quote")
|
|
||||||
|
|
||||||
return "".join(result), remainder
|
|
||||||
|
|
||||||
|
|
||||||
# hide_field_split2 returns the first key in hidden_field and the rest of the hidden_field
|
|
||||||
# We expect the first key to either be in brackets, to be terminated by the start of a left
|
|
||||||
# bracket, or to be terminated by a dot.
|
|
||||||
|
|
||||||
# examples would be:
|
|
||||||
# field.another.next -> (field, another.next)
|
|
||||||
# field[key].value -> (field, [key].value)
|
|
||||||
# [key].value -> (key, value)
|
|
||||||
# [one][two] -> (one, [two])
|
|
||||||
|
|
||||||
|
|
||||||
def hide_field_split2(hidden_field: str) -> Tuple[str, str]:
|
|
||||||
lbracket = hidden_field.find("[")
|
|
||||||
rbracket = hidden_field.find("]")
|
|
||||||
dot = hidden_field.find(".")
|
|
||||||
|
|
||||||
if lbracket == 0:
|
|
||||||
# skip past right bracket and any following dot
|
|
||||||
rest = hidden_field[rbracket + 1 :] # noqa: E203
|
|
||||||
if rest and rest[0] == ".":
|
|
||||||
rest = rest[1:]
|
|
||||||
return (hidden_field[lbracket + 1 : rbracket], rest) # noqa: E203
|
|
||||||
|
|
||||||
if lbracket != -1 and (dot == -1 or lbracket < dot):
|
|
||||||
return (hidden_field[:lbracket], hidden_field[lbracket:])
|
|
||||||
|
|
||||||
split = hidden_field.split(".", 1)
|
|
||||||
if len(split) == 1:
|
|
||||||
return split[0], ""
|
|
||||||
return split
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ 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,
|
||||||
)
|
)
|
||||||
@@ -51,7 +52,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 or 0)
|
and daemonset.status.updatedNumberScheduled
|
||||||
== 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
|
||||||
@@ -60,13 +61,6 @@ 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
|
||||||
@@ -117,34 +111,11 @@ def exists(resource: Optional[ResourceInstance]) -> bool:
|
|||||||
return bool(resource) and not empty_list(resource)
|
return bool(resource) and not empty_list(resource)
|
||||||
|
|
||||||
|
|
||||||
def cluster_operator_ready(resource: ResourceInstance) -> bool:
|
|
||||||
"""
|
|
||||||
Predicate to check if a single ClusterOperator is healthy.
|
|
||||||
Returns True if:
|
|
||||||
- "Available" is True
|
|
||||||
- "Degraded" is False
|
|
||||||
- "Progressing" is False
|
|
||||||
"""
|
|
||||||
if not resource:
|
|
||||||
return False
|
|
||||||
|
|
||||||
# Extract conditions from the resource's status
|
|
||||||
conditions = resource.get("status", {}).get("conditions", [])
|
|
||||||
|
|
||||||
status = {x.get("type", ""): x.get("status") for x in conditions}
|
|
||||||
return (
|
|
||||||
(status.get("Degraded") == "False")
|
|
||||||
and (status.get("Progressing") == "False")
|
|
||||||
and (status.get("Available") == "True")
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
RESOURCE_PREDICATES = {
|
RESOURCE_PREDICATES = {
|
||||||
"DaemonSet": daemonset_ready,
|
"DaemonSet": daemonset_ready,
|
||||||
"Deployment": deployment_ready,
|
"Deployment": deployment_ready,
|
||||||
"Pod": pod_ready,
|
"Pod": pod_ready,
|
||||||
"StatefulSet": statefulset_ready,
|
"StatefulSet": statefulset_ready,
|
||||||
"ClusterOperator": cluster_operator_ready,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,11 +18,12 @@ 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,6 +16,7 @@ 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,32 +129,7 @@ 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
|
|
||||||
reset_then_reuse_values:
|
|
||||||
description:
|
|
||||||
- When upgrading package, reset the values to the ones built into the chart, apply the last release's values and merge in any overrides from
|
|
||||||
parameters O(release_values), O(values_files) or O(set_values).
|
|
||||||
- If O(reset_values) or O(reuse_values) is set to V(True), this is ignored.
|
|
||||||
- This feature requires helm diff >= 3.9.12.
|
|
||||||
type: bool
|
|
||||||
required: false
|
|
||||||
default: False
|
|
||||||
version_added: 6.0.0
|
|
||||||
|
|
||||||
#Helm options
|
#Helm options
|
||||||
disable_hook:
|
disable_hook:
|
||||||
@@ -191,7 +166,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.
|
||||||
@@ -202,12 +177,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.
|
||||||
@@ -215,28 +190,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"
|
||||||
insecure_skip_tls_verify:
|
|
||||||
description:
|
|
||||||
- Skip tls certificate checks for the chart download.
|
|
||||||
- Do not confuse with the C(validate_certs) option.
|
|
||||||
- This option is only available for helm >= 3.16.0.
|
|
||||||
type: bool
|
|
||||||
default: False
|
|
||||||
aliases: [ skip_tls_certs_check ]
|
|
||||||
version_added: 5.3.0
|
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- kubernetes.core.helm_common_options
|
- kubernetes.core.helm_common_options
|
||||||
"""
|
"""
|
||||||
@@ -344,17 +310,6 @@ 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"""
|
||||||
@@ -412,11 +367,10 @@ 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,
|
||||||
)
|
)
|
||||||
@@ -452,20 +406,14 @@ def get_release(state, release_name):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_release_status(module, release_name, all_status=False):
|
def get_release_status(module, release_name):
|
||||||
"""
|
"""
|
||||||
Get Release state from all release status (deployed, failed, pending-install, etc)
|
Get Release state from deployed release
|
||||||
"""
|
"""
|
||||||
|
|
||||||
list_command = [
|
list_command = (
|
||||||
module.get_helm_binary(),
|
module.get_helm_binary() + " list --output=yaml --filter " + release_name
|
||||||
"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)
|
||||||
|
|
||||||
@@ -491,18 +439,15 @@ def run_dep_update(module, chart_ref):
|
|||||||
"""
|
"""
|
||||||
Run dependency update
|
Run dependency update
|
||||||
"""
|
"""
|
||||||
dep_update = module.get_helm_binary() + f" dependency update '{chart_ref}'"
|
dep_update = module.get_helm_binary() + " dependency update " + chart_ref
|
||||||
rc, out, err = module.run_helm_command(dep_update)
|
rc, out, err = module.run_helm_command(dep_update)
|
||||||
|
|
||||||
|
|
||||||
def fetch_chart_info(module, command, chart_ref, insecure_skip_tls_verify=False):
|
def fetch_chart_info(module, command, chart_ref):
|
||||||
"""
|
"""
|
||||||
Get chart info
|
Get chart info
|
||||||
"""
|
"""
|
||||||
inspect_command = command + f" show chart '{chart_ref}'"
|
inspect_command = command + " show chart " + chart_ref
|
||||||
|
|
||||||
if insecure_skip_tls_verify:
|
|
||||||
inspect_command += " --insecure-skip-tls-verify"
|
|
||||||
|
|
||||||
rc, out, err = module.run_helm_command(inspect_command)
|
rc, out, err = module.run_helm_command(inspect_command)
|
||||||
|
|
||||||
@@ -510,7 +455,6 @@ def fetch_chart_info(module, command, chart_ref, insecure_skip_tls_verify=False)
|
|||||||
|
|
||||||
|
|
||||||
def deploy(
|
def deploy(
|
||||||
module,
|
|
||||||
command,
|
command,
|
||||||
release_name,
|
release_name,
|
||||||
release_values,
|
release_values,
|
||||||
@@ -529,10 +473,6 @@ 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,
|
|
||||||
reset_then_reuse_values=False,
|
|
||||||
insecure_skip_tls_verify=False,
|
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Install/upgrade/rollback release chart
|
Install/upgrade/rollback release chart
|
||||||
@@ -544,22 +484,9 @@ 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"
|
|
||||||
|
|
||||||
if reuse_values is not None:
|
# Always reset values to keep release_values equal to values released
|
||||||
deploy_command += " --reuse-values=" + str(reuse_values)
|
deploy_command += " --reset-values"
|
||||||
|
|
||||||
if reset_then_reuse_values:
|
|
||||||
helm_version = module.get_helm_version()
|
|
||||||
if LooseVersion(helm_version) < LooseVersion("3.14.0"):
|
|
||||||
module.fail_json(
|
|
||||||
msg="reset_then_reuse_values requires helm >= 3.14.0, current version is {0}".format(
|
|
||||||
helm_version
|
|
||||||
)
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
deploy_command += " --reset-then-reuse-values"
|
|
||||||
|
|
||||||
if wait:
|
if wait:
|
||||||
deploy_command += " --wait"
|
deploy_command += " --wait"
|
||||||
@@ -584,17 +511,6 @@ def deploy(
|
|||||||
if create_namespace:
|
if create_namespace:
|
||||||
deploy_command += " --create-namespace"
|
deploy_command += " --create-namespace"
|
||||||
|
|
||||||
if insecure_skip_tls_verify:
|
|
||||||
helm_version = module.get_helm_version()
|
|
||||||
if LooseVersion(helm_version) < LooseVersion("3.16.0"):
|
|
||||||
module.fail_json(
|
|
||||||
msg="insecure_skip_tls_verify requires helm >= 3.16.0, current version is {0}".format(
|
|
||||||
helm_version
|
|
||||||
)
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
deploy_command += " --insecure-skip-tls-verify"
|
|
||||||
|
|
||||||
if values_files:
|
if values_files:
|
||||||
for value_file in values_files:
|
for value_file in values_files:
|
||||||
deploy_command += " --values=" + value_file
|
deploy_command += " --values=" + value_file
|
||||||
@@ -604,10 +520,9 @@ 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"
|
||||||
@@ -618,7 +533,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 + f" '{chart_name}'"
|
deploy_command += " " + release_name + " " + chart_name
|
||||||
return deploy_command
|
return deploy_command
|
||||||
|
|
||||||
|
|
||||||
@@ -684,12 +599,6 @@ 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,
|
|
||||||
reset_then_reuse_values=False,
|
|
||||||
insecure_skip_tls_verify=False,
|
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Use helm diff to determine if a release would change by upgrading a chart.
|
Use helm diff to determine if a release would change by upgrading a chart.
|
||||||
@@ -703,13 +612,7 @@ 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=" + str(reset_values)
|
cmd += " " + "--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")
|
||||||
@@ -718,32 +621,9 @@ def helmdiff_check(
|
|||||||
cmd += " -f=" + path
|
cmd += " -f=" + path
|
||||||
module.add_cleanup_file(path)
|
module.add_cleanup_file(path)
|
||||||
|
|
||||||
if set_value_args:
|
if values_files:
|
||||||
cmd += " " + set_value_args
|
for values_file in values_files:
|
||||||
|
cmd += " -f=" + values_file
|
||||||
if reuse_values:
|
|
||||||
cmd += " --reuse-values"
|
|
||||||
|
|
||||||
if reset_then_reuse_values:
|
|
||||||
helm_diff_version = get_plugin_version("diff")
|
|
||||||
helm_version = module.get_helm_version()
|
|
||||||
fail_msg = ""
|
|
||||||
if LooseVersion(helm_diff_version) < LooseVersion("3.9.12"):
|
|
||||||
fail_msg = "reset_then_reuse_values requires helm diff >= 3.9.12, current version is {0}\n".format(
|
|
||||||
helm_diff_version
|
|
||||||
)
|
|
||||||
if LooseVersion(helm_version) < LooseVersion("3.14.0"):
|
|
||||||
fail_msg += "reset_then_reuse_values requires helm >= 3.14.0, current version is {0}\n".format(
|
|
||||||
helm_version
|
|
||||||
)
|
|
||||||
|
|
||||||
if fail_msg:
|
|
||||||
module.fail_json(msg=fail_msg)
|
|
||||||
else:
|
|
||||||
cmd += " --reset-then-reuse-values"
|
|
||||||
|
|
||||||
if insecure_skip_tls_verify:
|
|
||||||
cmd += " --insecure-skip-tls-verify"
|
|
||||||
|
|
||||||
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())
|
||||||
@@ -802,12 +682,6 @@ 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),
|
|
||||||
reset_then_reuse_values=dict(type="bool", default=False),
|
|
||||||
insecure_skip_tls_verify=dict(
|
|
||||||
type="bool", default=False, aliases=["skip_tls_certs_check"]
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return arg_spec
|
return arg_spec
|
||||||
@@ -858,40 +732,34 @@ 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")
|
|
||||||
reset_then_reuse_values = module.params.get("reset_then_reuse_values")
|
|
||||||
insecure_skip_tls_verify = module.params.get("insecure_skip_tls_verify")
|
|
||||||
|
|
||||||
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
|
||||||
all_status = release_state == "absent"
|
release_status = get_release_status(module, release_name)
|
||||||
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:
|
||||||
# skip release statuses 'uninstalled' and 'uninstalling'
|
if replace:
|
||||||
if not release_status["status"].startswith("uninstall"):
|
module.fail_json(msg="replace is not applicable when state is absent")
|
||||||
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
|
||||||
|
|
||||||
@@ -899,9 +767,7 @@ def main():
|
|||||||
helm_cmd += " --repo=" + chart_repo_url
|
helm_cmd += " --repo=" + chart_repo_url
|
||||||
|
|
||||||
# Fetch chart info to have real version and real name for chart_ref from archive, folder or url
|
# Fetch chart info to have real version and real name for chart_ref from archive, folder or url
|
||||||
chart_info = fetch_chart_info(
|
chart_info = fetch_chart_info(module, helm_cmd, chart_ref)
|
||||||
module, helm_cmd, chart_ref, insecure_skip_tls_verify
|
|
||||||
)
|
|
||||||
|
|
||||||
if dependency_update:
|
if dependency_update:
|
||||||
if chart_info.get("dependencies"):
|
if chart_info.get("dependencies"):
|
||||||
@@ -933,13 +799,12 @@ 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."
|
||||||
)
|
)
|
||||||
|
|
||||||
set_value_args = None
|
|
||||||
if set_values:
|
|
||||||
set_value_args = module.get_helm_set_values_args(set_values)
|
|
||||||
|
|
||||||
if release_status is None: # Not installed
|
if release_status is None: # Not installed
|
||||||
|
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,
|
||||||
@@ -958,14 +823,11 @@ 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,
|
|
||||||
reset_then_reuse_values=reset_then_reuse_values,
|
|
||||||
insecure_skip_tls_verify=insecure_skip_tls_verify,
|
|
||||||
)
|
)
|
||||||
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
|
||||||
@@ -983,12 +845,6 @@ 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,
|
|
||||||
reset_then_reuse_values=reset_then_reuse_values,
|
|
||||||
insecure_skip_tls_verify=insecure_skip_tls_verify,
|
|
||||||
)
|
)
|
||||||
if would_change and module._diff:
|
if would_change and module._diff:
|
||||||
opt_result["diff"] = {"prepared": prepared}
|
opt_result["diff"] = {"prepared": prepared}
|
||||||
@@ -1002,8 +858,11 @@ 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,
|
||||||
@@ -1022,10 +881,6 @@ 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,
|
|
||||||
reset_then_reuse_values=reset_then_reuse_values,
|
|
||||||
insecure_skip_tls_verify=insecure_skip_tls_verify,
|
|
||||||
)
|
)
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
@@ -1059,7 +914,7 @@ def main():
|
|||||||
changed=changed,
|
changed=changed,
|
||||||
stdout=out,
|
stdout=out,
|
||||||
stderr=err,
|
stderr=err,
|
||||||
status=get_release_status(module, release_name, all_status=True),
|
status=get_release_status(module, release_name),
|
||||||
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)
|
||||||
@@ -52,8 +52,7 @@ options:
|
|||||||
- If set to C(uninstalling), show releases that are currently being uninstalled.
|
- If set to C(uninstalling), show releases that are currently being uninstalled.
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
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 +60,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 +122,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 copy
|
|
||||||
import traceback
|
import traceback
|
||||||
|
import copy
|
||||||
|
|
||||||
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,7 +109,6 @@ 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,10 +71,9 @@ 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,
|
|
||||||
parse_helm_plugin_list,
|
parse_helm_plugin_list,
|
||||||
|
AnsibleHelmModule,
|
||||||
)
|
)
|
||||||
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,
|
||||||
@@ -83,6 +82,7 @@ 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:
|
||||||
@@ -75,10 +75,9 @@ options:
|
|||||||
skip_tls_certs_check:
|
skip_tls_certs_check:
|
||||||
description:
|
description:
|
||||||
- Whether or not to check tls certificate for the chart download.
|
- Whether or not to check tls certificate for the chart download.
|
||||||
- Requires helm >= 3.3.0. Alias C(insecure_skip_tls_verify) added in 5.3.0.
|
- Requires helm >= 3.3.0.
|
||||||
type: bool
|
type: bool
|
||||||
default: False
|
default: False
|
||||||
aliases: [ insecure_skip_tls_verify ]
|
|
||||||
chart_devel:
|
chart_devel:
|
||||||
description:
|
description:
|
||||||
- Use development versions, too. Equivalent to version '>0.0.0-0'.
|
- Use development versions, too. Equivalent to version '>0.0.0-0'.
|
||||||
@@ -190,10 +189,8 @@ 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, no_log=False),
|
pass_credentials=dict(type="bool", default=False),
|
||||||
skip_tls_certs_check=dict(
|
skip_tls_certs_check=dict(type="bool", default=False),
|
||||||
type="bool", default=False, aliases=["insecure_skip_tls_verify"]
|
|
||||||
),
|
|
||||||
chart_devel=dict(type="bool"),
|
chart_devel=dict(type="bool"),
|
||||||
untar_chart=dict(type="bool", default=False),
|
untar_chart=dict(type="bool", default=False),
|
||||||
destination=dict(type="path", required=True),
|
destination=dict(type="path", required=True),
|
||||||
|
|||||||
@@ -1,238 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Copyright: © Ericsson AB 2024
|
|
||||||
# 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_registry_auth
|
|
||||||
|
|
||||||
short_description: Helm registry authentication module
|
|
||||||
|
|
||||||
version_added: 5.1.0
|
|
||||||
|
|
||||||
author:
|
|
||||||
- Yuriy Novostavskiy (@yurnov)
|
|
||||||
|
|
||||||
requirements:
|
|
||||||
- "helm (https://github.com/helm/helm/releases) => 3.8.0"
|
|
||||||
|
|
||||||
description:
|
|
||||||
- Helm registry authentication module allows you to login C(helm registry login) and logout C(helm registry logout) from a Helm registry.
|
|
||||||
|
|
||||||
options:
|
|
||||||
state:
|
|
||||||
description:
|
|
||||||
- Desired state of the registry.
|
|
||||||
- If set to V(present) attempt to log in to the remote registry server using the URL specified in O(host).
|
|
||||||
- If set to V(absent) attempt to log out from the remote registry server using the URL specified in O(host).
|
|
||||||
required: false
|
|
||||||
default: present
|
|
||||||
choices: ['present', 'absent']
|
|
||||||
type: str
|
|
||||||
host:
|
|
||||||
description:
|
|
||||||
- Provide a URL for accessing the registry.
|
|
||||||
required: true
|
|
||||||
aliases: [ registry_url ]
|
|
||||||
type: str
|
|
||||||
insecure:
|
|
||||||
description:
|
|
||||||
- Allow connections to SSL sites without certs.
|
|
||||||
required: false
|
|
||||||
default: false
|
|
||||||
type: bool
|
|
||||||
username:
|
|
||||||
description:
|
|
||||||
- Username for the registry.
|
|
||||||
required: false
|
|
||||||
type: str
|
|
||||||
aliases: [ repo_username ]
|
|
||||||
password:
|
|
||||||
description:
|
|
||||||
- Password for the registry.
|
|
||||||
required: false
|
|
||||||
type: str
|
|
||||||
aliases: [ repo_password ]
|
|
||||||
key_file:
|
|
||||||
description:
|
|
||||||
- Path to the client key SSL file for identify registry client using this key file.
|
|
||||||
required: false
|
|
||||||
type: path
|
|
||||||
cert_file:
|
|
||||||
description:
|
|
||||||
- Path to the client certificate SSL file for identify registry client using this certificate file.
|
|
||||||
required: false
|
|
||||||
type: path
|
|
||||||
ca_file:
|
|
||||||
description:
|
|
||||||
- Path to the CA certificate SSL file for verify registry server certificate.
|
|
||||||
required: false
|
|
||||||
type: path
|
|
||||||
binary_path:
|
|
||||||
description:
|
|
||||||
- The path of a helm binary to use.
|
|
||||||
required: false
|
|
||||||
type: path
|
|
||||||
"""
|
|
||||||
|
|
||||||
EXAMPLES = r"""
|
|
||||||
- name: Login to remote registry
|
|
||||||
kubernetes.core.helm_registry_auth:
|
|
||||||
username: admin
|
|
||||||
password: "sample_password"
|
|
||||||
host: localhost:5000
|
|
||||||
|
|
||||||
- name: Logout from remote registry
|
|
||||||
kubernetes.core.helm_registry_auth:
|
|
||||||
state: absent
|
|
||||||
host: localhost:5000
|
|
||||||
"""
|
|
||||||
|
|
||||||
RETURN = r"""
|
|
||||||
stdout:
|
|
||||||
type: str
|
|
||||||
description: Full C(helm) command stdout, in case you want to display it or examine the event log
|
|
||||||
returned: always
|
|
||||||
stout_lines:
|
|
||||||
type: list
|
|
||||||
description: Full C(helm) command stdout, in case you want to display it or examine the event log
|
|
||||||
returned: always
|
|
||||||
stderr:
|
|
||||||
type: str
|
|
||||||
description: >-
|
|
||||||
Full C(helm) command stderr, in case you want to display it or examine the event log.
|
|
||||||
Please be note that helm binnary may print messages to stderr even if the command is successful.
|
|
||||||
returned: always
|
|
||||||
sample: 'Login Succeeded\n'
|
|
||||||
stderr_lines:
|
|
||||||
type: list
|
|
||||||
description: Full C(helm) command stderr, in case you want to display it or examine the event log
|
|
||||||
returned: always
|
|
||||||
command:
|
|
||||||
type: str
|
|
||||||
description: Full C(helm) command executed
|
|
||||||
returned: always
|
|
||||||
sample: '/usr/local/bin/helm registry login oci-registry.domain.example --username=admin --password-stdin --insecure'
|
|
||||||
failed:
|
|
||||||
type: bool
|
|
||||||
description: Indicate if the C(helm) command failed
|
|
||||||
returned: always
|
|
||||||
sample: false
|
|
||||||
"""
|
|
||||||
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.helm import (
|
|
||||||
AnsibleHelmModule,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def arg_spec():
|
|
||||||
return dict(
|
|
||||||
binary_path=dict(type="path", required=False),
|
|
||||||
host=dict(type="str", aliases=["registry_url"], required=True),
|
|
||||||
state=dict(default="present", choices=["present", "absent"], required=False),
|
|
||||||
insecure=dict(type="bool", default=False, required=False),
|
|
||||||
username=dict(type="str", aliases=["repo_username"], required=False),
|
|
||||||
password=dict(
|
|
||||||
type="str", aliases=["repo_password"], no_log=True, required=False
|
|
||||||
),
|
|
||||||
key_file=dict(type="path", required=False),
|
|
||||||
cert_file=dict(type="path", required=False),
|
|
||||||
ca_file=dict(type="path", required=False),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def login(
|
|
||||||
command,
|
|
||||||
host,
|
|
||||||
insecure,
|
|
||||||
username,
|
|
||||||
password,
|
|
||||||
key_file,
|
|
||||||
cert_file,
|
|
||||||
ca_file,
|
|
||||||
):
|
|
||||||
login_command = command + " registry login " + host
|
|
||||||
|
|
||||||
if username is not None and password is not None:
|
|
||||||
login_command += " --username=" + username + " --password-stdin"
|
|
||||||
|
|
||||||
if insecure:
|
|
||||||
login_command += " --insecure"
|
|
||||||
|
|
||||||
if key_file is not None:
|
|
||||||
login_command += " --key-file=" + key_file
|
|
||||||
|
|
||||||
if cert_file is not None:
|
|
||||||
login_command += " --cert-file=" + cert_file
|
|
||||||
|
|
||||||
if ca_file is not None:
|
|
||||||
login_command += " --ca-file=" + ca_file
|
|
||||||
|
|
||||||
return login_command
|
|
||||||
|
|
||||||
|
|
||||||
def logout(command, host):
|
|
||||||
return command + " registry logout " + host
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
global module
|
|
||||||
|
|
||||||
module = AnsibleHelmModule(
|
|
||||||
argument_spec=arg_spec(),
|
|
||||||
required_together=[["username", "password"]],
|
|
||||||
supports_check_mode=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
changed = False
|
|
||||||
|
|
||||||
host = module.params.get("host")
|
|
||||||
state = module.params.get("state")
|
|
||||||
insecure = module.params.get("insecure")
|
|
||||||
username = module.params.get("username")
|
|
||||||
password = module.params.get("password")
|
|
||||||
key_file = module.params.get("key_file")
|
|
||||||
cert_file = module.params.get("cert_file")
|
|
||||||
ca_file = module.params.get("ca_file")
|
|
||||||
|
|
||||||
helm_cmd = module.get_helm_binary()
|
|
||||||
|
|
||||||
if state == "absent":
|
|
||||||
helm_cmd = logout(helm_cmd, host)
|
|
||||||
changed = True
|
|
||||||
elif state == "present":
|
|
||||||
helm_cmd = login(
|
|
||||||
helm_cmd, host, insecure, username, password, key_file, cert_file, ca_file
|
|
||||||
)
|
|
||||||
changed = True
|
|
||||||
|
|
||||||
if module.check_mode:
|
|
||||||
module.exit_json(changed=changed, command=helm_cmd)
|
|
||||||
|
|
||||||
rc, out, err = module.run_helm_command(
|
|
||||||
helm_cmd, data=password, fails_on_error=False
|
|
||||||
)
|
|
||||||
|
|
||||||
if rc != 0:
|
|
||||||
if state == "absent" and "Error: not logged in" in err:
|
|
||||||
changed = False
|
|
||||||
else:
|
|
||||||
module.fail_json(
|
|
||||||
msg="Failure when executing Helm command. Exited {0}.\nstdout: {1}\nstderr: {2}".format(
|
|
||||||
rc, out, err
|
|
||||||
),
|
|
||||||
stderr=err,
|
|
||||||
command=helm_cmd,
|
|
||||||
)
|
|
||||||
|
|
||||||
module.exit_json(changed=changed, stdout=out, stderr=err, command=helm_cmd)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
@@ -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,21 +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"
|
||||||
insecure_skip_tls_verify:
|
|
||||||
description:
|
|
||||||
- Skip tls certificate checks for the repository url.
|
|
||||||
type: bool
|
|
||||||
default: False
|
|
||||||
aliases: [ skip_tls_certs_check ]
|
|
||||||
version_added: "5.3.0"
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = r"""
|
EXAMPLES = r"""
|
||||||
@@ -173,8 +166,8 @@ msg:
|
|||||||
sample: 'Repository already have a repository named bitnami'
|
sample: 'Repository already have a repository named bitnami'
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import copy
|
|
||||||
import traceback
|
import traceback
|
||||||
|
import copy
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import yaml
|
import yaml
|
||||||
@@ -233,7 +226,6 @@ def install_repository(
|
|||||||
repository_password,
|
repository_password,
|
||||||
pass_credentials,
|
pass_credentials,
|
||||||
force_update,
|
force_update,
|
||||||
insecure_skip_tls_verify,
|
|
||||||
):
|
):
|
||||||
install_command = command + " repo add " + repository_name + " " + repository_url
|
install_command = command + " repo add " + repository_name + " " + repository_url
|
||||||
|
|
||||||
@@ -247,9 +239,6 @@ def install_repository(
|
|||||||
if force_update:
|
if force_update:
|
||||||
install_command += " --force-update"
|
install_command += " --force-update"
|
||||||
|
|
||||||
if insecure_skip_tls_verify:
|
|
||||||
install_command += " --insecure-skip-tls-verify"
|
|
||||||
|
|
||||||
return install_command
|
return install_command
|
||||||
|
|
||||||
|
|
||||||
@@ -273,9 +262,6 @@ def argument_spec():
|
|||||||
),
|
),
|
||||||
pass_credentials=dict(type="bool", default=False, no_log=True),
|
pass_credentials=dict(type="bool", default=False, no_log=True),
|
||||||
force_update=dict(type="bool", default=False, aliases=["force"]),
|
force_update=dict(type="bool", default=False, aliases=["force"]),
|
||||||
insecure_skip_tls_verify=dict(
|
|
||||||
type="bool", default=False, aliases=["skip_tls_certs_check"]
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return arg_spec
|
return arg_spec
|
||||||
@@ -304,7 +290,6 @@ def main():
|
|||||||
repo_state = module.params.get("repo_state")
|
repo_state = module.params.get("repo_state")
|
||||||
pass_credentials = module.params.get("pass_credentials")
|
pass_credentials = module.params.get("pass_credentials")
|
||||||
force_update = module.params.get("force_update")
|
force_update = module.params.get("force_update")
|
||||||
insecure_skip_tls_verify = module.params.get("insecure_skip_tls_verify")
|
|
||||||
|
|
||||||
helm_cmd = module.get_helm_binary()
|
helm_cmd = module.get_helm_binary()
|
||||||
|
|
||||||
@@ -323,7 +308,6 @@ def main():
|
|||||||
repo_password,
|
repo_password,
|
||||||
pass_credentials,
|
pass_credentials,
|
||||||
force_update,
|
force_update,
|
||||||
insecure_skip_tls_verify,
|
|
||||||
)
|
)
|
||||||
changed = True
|
changed = True
|
||||||
elif repository_status["url"] != repo_url:
|
elif repository_status["url"] != repo_url:
|
||||||
|
|||||||
@@ -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.
|
||||||
@@ -72,13 +72,6 @@ options:
|
|||||||
- If the directory already exists, it will be overwritten.
|
- If the directory already exists, it will be overwritten.
|
||||||
required: false
|
required: false
|
||||||
type: path
|
type: path
|
||||||
insecure_registry:
|
|
||||||
description:
|
|
||||||
- Skip TLS certificate checks for the chart download
|
|
||||||
required: false
|
|
||||||
type: bool
|
|
||||||
default: false
|
|
||||||
version_added: 5.1.0
|
|
||||||
release_name:
|
release_name:
|
||||||
description:
|
description:
|
||||||
- Release name to use in rendered templates.
|
- Release name to use in rendered templates.
|
||||||
@@ -105,7 +98,6 @@ options:
|
|||||||
required: false
|
required: false
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
default: []
|
|
||||||
version_added: 2.4.0
|
version_added: 2.4.0
|
||||||
values_files:
|
values_files:
|
||||||
description:
|
description:
|
||||||
@@ -146,7 +138,7 @@ options:
|
|||||||
- string
|
- string
|
||||||
- json
|
- json
|
||||||
- file
|
- file
|
||||||
version_added: 2.4.0
|
version_added: '2.4.0'
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = r"""
|
EXAMPLES = r"""
|
||||||
@@ -228,7 +220,6 @@ def template(
|
|||||||
dependency_update=None,
|
dependency_update=None,
|
||||||
disable_hook=None,
|
disable_hook=None,
|
||||||
output_dir=None,
|
output_dir=None,
|
||||||
insecure_registry=None,
|
|
||||||
show_only=None,
|
show_only=None,
|
||||||
release_name=None,
|
release_name=None,
|
||||||
release_namespace=None,
|
release_namespace=None,
|
||||||
@@ -259,9 +250,6 @@ def template(
|
|||||||
if output_dir:
|
if output_dir:
|
||||||
cmd += " --output-dir=" + output_dir
|
cmd += " --output-dir=" + output_dir
|
||||||
|
|
||||||
if insecure_registry:
|
|
||||||
cmd += " --insecure-skip-tls-verify"
|
|
||||||
|
|
||||||
if show_only:
|
if show_only:
|
||||||
for template in show_only:
|
for template in show_only:
|
||||||
cmd += " -s " + template
|
cmd += " -s " + template
|
||||||
@@ -300,7 +288,6 @@ def main():
|
|||||||
include_crds=dict(type="bool", default=False),
|
include_crds=dict(type="bool", default=False),
|
||||||
release_name=dict(type="str", aliases=["name"]),
|
release_name=dict(type="str", aliases=["name"]),
|
||||||
output_dir=dict(type="path"),
|
output_dir=dict(type="path"),
|
||||||
insecure_registry=dict(type="bool", default=False),
|
|
||||||
release_namespace=dict(type="str"),
|
release_namespace=dict(type="str"),
|
||||||
release_values=dict(type="dict", default={}, aliases=["values"]),
|
release_values=dict(type="dict", default={}, aliases=["values"]),
|
||||||
show_only=dict(type="list", default=[], elements="str"),
|
show_only=dict(type="list", default=[], elements="str"),
|
||||||
@@ -320,7 +307,6 @@ def main():
|
|||||||
include_crds = module.params.get("include_crds")
|
include_crds = module.params.get("include_crds")
|
||||||
release_name = module.params.get("release_name")
|
release_name = module.params.get("release_name")
|
||||||
output_dir = module.params.get("output_dir")
|
output_dir = module.params.get("output_dir")
|
||||||
insecure_registry = module.params.get("insecure_registry")
|
|
||||||
show_only = module.params.get("show_only")
|
show_only = module.params.get("show_only")
|
||||||
release_namespace = module.params.get("release_namespace")
|
release_namespace = module.params.get("release_namespace")
|
||||||
release_values = module.params.get("release_values")
|
release_values = module.params.get("release_values")
|
||||||
@@ -350,7 +336,6 @@ def main():
|
|||||||
disable_hook=disable_hook,
|
disable_hook=disable_hook,
|
||||||
release_name=release_name,
|
release_name=release_name,
|
||||||
output_dir=output_dir,
|
output_dir=output_dir,
|
||||||
insecure_registry=insecure_registry,
|
|
||||||
release_namespace=release_namespace,
|
release_namespace=release_namespace,
|
||||||
release_values=release_values,
|
release_values=release_values,
|
||||||
show_only=show_only,
|
show_only=show_only,
|
||||||
|
|||||||
@@ -57,14 +57,15 @@ options:
|
|||||||
- Whether to override the default patch merge approach with a specific type. By default, the strategic
|
- Whether to override the default patch merge approach with a specific type. By default, the strategic
|
||||||
merge will typically be used.
|
merge will typically be used.
|
||||||
- For example, Custom Resource Definitions typically aren't updatable by the usual strategic merge. You may
|
- For example, Custom Resource Definitions typically aren't updatable by the usual strategic merge. You may
|
||||||
want to use C(merge) if you see "strategic merge patch format is not supported".
|
want to use C(merge) if you see "strategic merge patch format is not supported"
|
||||||
- See U(https://kubernetes.io/docs/tasks/run-application/update-api-object-kubectl-patch/#use-a-json-merge-patch-to-update-a-deployment)
|
- See U(https://kubernetes.io/docs/tasks/run-application/update-api-object-kubectl-patch/#use-a-json-merge-patch-to-update-a-deployment)
|
||||||
- If more than one C(merge_type) is given, the merge_types will be tried in order. This defaults to
|
- If more than one C(merge_type) is given, the merge_types will be tried in order. This defaults to
|
||||||
C(['strategic-merge', 'merge']), which is ideal for using the same parameters on resource kinds that
|
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) has been removed in version 4.0.0. Please use M(kubernetes.core.k8s_json_patch) instead.
|
- I(merge_type=json) is deprecated and will be removed in version 3.0.0. Please use M(kubernetes.core.k8s_json_patch) instead.
|
||||||
choices:
|
choices:
|
||||||
|
- json
|
||||||
- merge
|
- merge
|
||||||
- strategic-merge
|
- strategic-merge
|
||||||
type: list
|
type: list
|
||||||
@@ -100,7 +101,7 @@ options:
|
|||||||
- C(apply) compares the desired resource definition with the previously supplied resource definition,
|
- C(apply) compares the desired resource definition with the previously supplied resource definition,
|
||||||
ignoring properties that are automatically generated
|
ignoring properties that are automatically generated
|
||||||
- C(apply) works better with Services than 'force=yes'
|
- C(apply) works better with Services than 'force=yes'
|
||||||
- Mutually exclusive with C(merge_type).
|
- mutually exclusive with C(merge_type)
|
||||||
default: False
|
default: False
|
||||||
type: bool
|
type: bool
|
||||||
template:
|
template:
|
||||||
@@ -171,32 +172,10 @@ 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])
|
|
||||||
or V(hidden_fields=[spec.containers[0].env[3].value])
|
|
||||||
or V(hidden_fields=[metadata.annotations[kubectl.kubernetes.io/last-applied-configuration]])
|
|
||||||
type: list
|
|
||||||
elements: str
|
|
||||||
version_added: 3.0.0
|
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "python >= 3.9"
|
- "python >= 3.6"
|
||||||
- "kubernetes >= 24.2.0"
|
- "kubernetes >= 12.0.0"
|
||||||
- "PyYAML >= 3.11"
|
- "PyYAML >= 3.11"
|
||||||
- "jsonpatch"
|
- "jsonpatch"
|
||||||
"""
|
"""
|
||||||
@@ -278,10 +257,10 @@ EXAMPLES = r"""
|
|||||||
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:
|
||||||
@@ -364,14 +343,6 @@ 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"""
|
||||||
@@ -423,10 +394,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,
|
||||||
DELETE_OPTS_ARG_SPEC,
|
WAIT_ARG_SPEC,
|
||||||
NAME_ARG_SPEC,
|
NAME_ARG_SPEC,
|
||||||
RESOURCE_ARG_SPEC,
|
RESOURCE_ARG_SPEC,
|
||||||
WAIT_ARG_SPEC,
|
DELETE_OPTS_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,
|
||||||
@@ -460,7 +431,7 @@ def argspec():
|
|||||||
argument_spec.update(copy.deepcopy(AUTH_ARG_SPEC))
|
argument_spec.update(copy.deepcopy(AUTH_ARG_SPEC))
|
||||||
argument_spec.update(copy.deepcopy(WAIT_ARG_SPEC))
|
argument_spec.update(copy.deepcopy(WAIT_ARG_SPEC))
|
||||||
argument_spec["merge_type"] = dict(
|
argument_spec["merge_type"] = dict(
|
||||||
type="list", elements="str", choices=["merge", "strategic-merge"]
|
type="list", elements="str", choices=["json", "merge", "strategic-merge"]
|
||||||
)
|
)
|
||||||
argument_spec["validate"] = dict(type="dict", default=None, options=validate_spec())
|
argument_spec["validate"] = dict(type="dict", default=None, options=validate_spec())
|
||||||
argument_spec["append_hash"] = dict(type="bool", default=False)
|
argument_spec["append_hash"] = dict(type="bool", default=False)
|
||||||
@@ -479,8 +450,6 @@ 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.9"
|
- "python >= 3.6"
|
||||||
- "kubernetes >= 24.2.0"
|
- "kubernetes >= 12.0.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.9"
|
- "python >= 3.6"
|
||||||
- "kubernetes >= 24.2.0"
|
- "kubernetes >= 12.0.0"
|
||||||
|
|
||||||
options:
|
options:
|
||||||
namespace:
|
namespace:
|
||||||
@@ -139,18 +139,9 @@ 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,
|
||||||
)
|
)
|
||||||
@@ -164,6 +155,16 @@ 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,18 +41,8 @@ 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).
|
||||||
@@ -97,8 +87,8 @@ options:
|
|||||||
type: int
|
type: int
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- python >= 3.9
|
- python >= 3.6
|
||||||
- kubernetes >= 24.2.0
|
- kubernetes >= 12.0.0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = r"""
|
EXAMPLES = r"""
|
||||||
@@ -106,15 +96,14 @@ EXAMPLES = r"""
|
|||||||
kubernetes.core.k8s_drain:
|
kubernetes.core.k8s_drain:
|
||||||
state: drain
|
state: drain
|
||||||
name: foo
|
name: foo
|
||||||
delete_options:
|
force: yes
|
||||||
force: yes
|
|
||||||
|
|
||||||
- name: Drain node "foo", but abort if there are pods not managed by a ReplicationController, Job, or DaemonSet, and use a grace period of 15 minutes.
|
- name: Drain node "foo", but abort if there are pods not managed by a ReplicationController, Job, or DaemonSet, and use a grace period of 15 minutes.
|
||||||
kubernetes.core.k8s_drain:
|
kubernetes.core.k8s_drain:
|
||||||
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:
|
||||||
@@ -126,13 +115,6 @@ EXAMPLES = r"""
|
|||||||
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"""
|
||||||
@@ -144,12 +126,10 @@ result:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
import json
|
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
from ansible.module_utils._text import to_native
|
from datetime import datetime
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.ansiblemodule import (
|
||||||
AnsibleModule,
|
AnsibleModule,
|
||||||
)
|
)
|
||||||
@@ -166,10 +146,12 @@ 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.exceptions import ApiException
|
|
||||||
from kubernetes.client.models import V1DeleteOptions, V1ObjectMeta
|
from kubernetes.client.models import V1DeleteOptions, V1ObjectMeta
|
||||||
|
from kubernetes.client.exceptions import ApiException
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# ImportError are managed by the common module already.
|
# ImportError are managed by the common module already.
|
||||||
pass
|
pass
|
||||||
@@ -189,17 +171,6 @@ 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 = [], [], [], [], []
|
||||||
@@ -304,19 +275,16 @@ class K8sDrainAnsible(object):
|
|||||||
return (datetime.now() - start).seconds
|
return (datetime.now() - start).seconds
|
||||||
|
|
||||||
response = None
|
response = None
|
||||||
pod = None
|
pod = pods.pop()
|
||||||
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[-1]
|
pod = pods.pop()
|
||||||
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 or response.spec.node_name != self._module.params.get(
|
if not response:
|
||||||
"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":
|
||||||
@@ -324,7 +292,6 @@ 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:
|
||||||
@@ -351,7 +318,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, to_native(format_dynamic_api_exc(exc))
|
namespace, name, exc.reason
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
@@ -361,17 +328,6 @@ 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 = []
|
||||||
@@ -394,7 +350,12 @@ class K8sDrainAnsible(object):
|
|||||||
self.patch_node(unschedulable=False)
|
self.patch_node(unschedulable=False)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pod_list = self.list_pods()
|
field_selector = "spec.nodeName={name}".format(
|
||||||
|
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)
|
||||||
@@ -445,6 +406,7 @@ 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(
|
||||||
@@ -456,6 +418,7 @@ 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:
|
||||||
@@ -523,11 +486,6 @@ 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.9"
|
- "python >= 3.6"
|
||||||
- "kubernetes >= 24.2.0"
|
- "kubernetes >= 12.0.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_collections.kubernetes.core.plugins.module_utils.args_common import (
|
from ansible.module_utils._text import to_native
|
||||||
|
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.client import (
|
|
||||||
get_api_client,
|
|
||||||
)
|
|
||||||
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.client import (
|
||||||
|
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,
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from kubernetes.client.apis import core_v1_api
|
from kubernetes.client.apis import core_v1_api
|
||||||
from kubernetes.client.exceptions import ApiException
|
|
||||||
from kubernetes.stream import stream
|
from kubernetes.stream import stream
|
||||||
|
from kubernetes.client.exceptions import ApiException
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# ImportError are managed by the common module already.
|
# ImportError are managed by the common module already.
|
||||||
pass
|
pass
|
||||||
@@ -219,6 +219,12 @@ def execute_module(module, client):
|
|||||||
else:
|
else:
|
||||||
rc = int(err["details"]["causes"][0]["message"])
|
rc = int(err["details"]["causes"][0]["message"])
|
||||||
|
|
||||||
|
module.deprecate(
|
||||||
|
"The 'return_code' return key is being renamed to 'rc'. "
|
||||||
|
"Both keys are being returned for now to allow users to migrate their automation.",
|
||||||
|
version="4.0.0",
|
||||||
|
collection_name="kubernetes.core",
|
||||||
|
)
|
||||||
module.exit_json(
|
module.exit_json(
|
||||||
# Some command might change environment, but ultimately failing at end
|
# Some command might change environment, but ultimately failing at end
|
||||||
changed=True,
|
changed=True,
|
||||||
|
|||||||
@@ -38,21 +38,10 @@ options:
|
|||||||
description: List of label selectors to use to filter results
|
description: List of label selectors to use to filter results
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
default: []
|
|
||||||
field_selectors:
|
field_selectors:
|
||||||
description: List of field selectors to use to filter results
|
description: List of field selectors to use to filter results
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
default: []
|
|
||||||
hidden_fields:
|
|
||||||
description:
|
|
||||||
- Hide fields matching any of the field definitions in the result
|
|
||||||
- An example might be C(hidden_fields=[metadata.managedFields])
|
|
||||||
or V(hidden_fields=[spec.containers[0].env[3].value])
|
|
||||||
or V(hidden_fields=[metadata.annotations[kubectl.kubernetes.io/last-applied-configuration]])
|
|
||||||
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
|
||||||
@@ -60,8 +49,8 @@ extends_documentation_fragment:
|
|||||||
- kubernetes.core.k8s_wait_options
|
- kubernetes.core.k8s_wait_options
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "python >= 3.9"
|
- "python >= 3.6"
|
||||||
- "kubernetes >= 24.2.0"
|
- "kubernetes >= 12.0.0"
|
||||||
- "PyYAML >= 3.11"
|
- "PyYAML >= 3.11"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -166,12 +155,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.client import (
|
|
||||||
get_api_client,
|
|
||||||
)
|
|
||||||
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.client import (
|
||||||
|
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,
|
||||||
)
|
)
|
||||||
@@ -192,7 +181,6 @@ 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)
|
||||||
|
|
||||||
@@ -208,7 +196,6 @@ 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.9"
|
- "python >= 3.6"
|
||||||
- "kubernetes >= 24.2.0"
|
- "kubernetes >= 12.0.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._text import to_native
|
|
||||||
from ansible.module_utils.basic import missing_required_lib
|
from ansible.module_utils.basic import missing_required_lib
|
||||||
|
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,
|
||||||
)
|
)
|
||||||
@@ -152,6 +152,7 @@ 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)"
|
||||||
@@ -47,7 +47,6 @@ options:
|
|||||||
- Only one of I(name) or I(label_selectors) may be provided.
|
- Only one of I(name) or I(label_selectors) may be provided.
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
default: []
|
|
||||||
container:
|
container:
|
||||||
description:
|
description:
|
||||||
- Use to specify the container within a pod to grab the log from.
|
- Use to specify the container within a pod to grab the log from.
|
||||||
@@ -61,30 +60,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.9"
|
- "python >= 3.6"
|
||||||
- "kubernetes >= 24.2.0"
|
- "kubernetes >= 12.0.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:
|
||||||
@@ -24,18 +24,16 @@ options:
|
|||||||
description: List of label selectors to use to filter results.
|
description: List of label selectors to use to filter results.
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
default: []
|
|
||||||
field_selectors:
|
field_selectors:
|
||||||
description: List of field selectors to use to filter results.
|
description: List of field selectors to use to filter results.
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
default: []
|
|
||||||
extends_documentation_fragment:
|
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.9"
|
- "python >= 3.6"
|
||||||
- "kubernetes >= 24.2.0"
|
- "kubernetes >= 12.0.0"
|
||||||
- "PyYAML >= 3.11"
|
- "PyYAML >= 3.11"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
|
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
@@ -35,7 +36,6 @@ options:
|
|||||||
description: List of label selectors to use to filter results.
|
description: List of label selectors to use to filter results.
|
||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
default: []
|
|
||||||
version_added: 2.0.0
|
version_added: 2.0.0
|
||||||
continue_on_error:
|
continue_on_error:
|
||||||
description:
|
description:
|
||||||
@@ -45,8 +45,8 @@ options:
|
|||||||
version_added: 2.0.0
|
version_added: 2.0.0
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "python >= 3.9"
|
- "python >= 3.6"
|
||||||
- "kubernetes >= 24.2.0"
|
- "kubernetes >= 12.0.0"
|
||||||
- "PyYAML >= 3.11"
|
- "PyYAML >= 3.11"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -150,13 +150,14 @@ 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,
|
||||||
NAME_ARG_SPEC,
|
|
||||||
RESOURCE_ARG_SPEC,
|
RESOURCE_ARG_SPEC,
|
||||||
|
NAME_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,
|
||||||
@@ -168,15 +169,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},
|
||||||
@@ -389,7 +390,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.9
|
- python >= 3.6
|
||||||
- kubernetes >= 24.2.0
|
- kubernetes >= 12.0.0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = r"""
|
EXAMPLES = r"""
|
||||||
@@ -143,6 +143,7 @@ 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 (
|
||||||
@@ -153,24 +154,25 @@ 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.client import (
|
|
||||||
get_api_client,
|
|
||||||
)
|
|
||||||
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.client import (
|
||||||
|
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,
|
||||||
)
|
)
|
||||||
|
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.9
|
- python >= 3.6
|
||||||
- kubernetes >= 24.2.0
|
- kubernetes >= 12.0.0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = r"""
|
EXAMPLES = r"""
|
||||||
@@ -127,6 +127,7 @@ 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>=24.2.0
|
kubernetes>=12.0.0
|
||||||
requests-oauthlib
|
requests-oauthlib
|
||||||
jsonpatch
|
jsonpatch
|
||||||
|
|||||||
@@ -5,5 +5,3 @@ pytest
|
|||||||
pytest-xdist
|
pytest-xdist
|
||||||
pytest-mock
|
pytest-mock
|
||||||
pytest-forked
|
pytest-forked
|
||||||
virtualenv
|
|
||||||
pytest-ansible
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ helm_default_archive_name: "helm-{{ helm_version }}-{{ ansible_system | lower }}
|
|||||||
helm_binary: "/tmp/helm/{{ ansible_system | lower }}-amd64/helm"
|
helm_binary: "/tmp/helm/{{ ansible_system | lower }}-amd64/helm"
|
||||||
|
|
||||||
chart_test: "ingress-nginx"
|
chart_test: "ingress-nginx"
|
||||||
chart_test_oci: "oci://registry-1.docker.io/bitnamicharts/redis"
|
|
||||||
chart_test_local_path: "nginx-ingress"
|
chart_test_local_path: "nginx-ingress"
|
||||||
chart_test_version: 4.2.4
|
chart_test_version: 4.2.4
|
||||||
chart_test_version_local_path: 1.32.0
|
chart_test_version_local_path: 1.32.0
|
||||||
@@ -25,7 +24,3 @@ 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"
|
|
||||||
- "helm-reset-then-reuse-values"
|
|
||||||
- "helm-insecure"
|
|
||||||
|
|||||||
@@ -1,130 +0,0 @@
|
|||||||
#!/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(
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
- connection: local
|
|
||||||
gather_facts: true
|
|
||||||
hosts: localhost
|
|
||||||
|
|
||||||
roles:
|
|
||||||
- helm
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -eux
|
|
||||||
export ANSIBLE_CALLBACKS_ENABLED=profile_tasks
|
|
||||||
export ANSIBLE_ROLES_PATH=../
|
|
||||||
ansible-playbook playbook.yaml "$@"
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user