mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-11-21 14:48:37 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11b861f77e | ||
|
|
536eded7d0 | ||
|
|
408802cb67 | ||
|
|
782672d2fd | ||
|
|
ebb0d7f087 | ||
|
|
b7e1ed5661 | ||
|
|
f650940f0a | ||
|
|
4314ad6091 | ||
|
|
177297fdae | ||
|
|
10584acdbb | ||
|
|
094240ab77 | ||
|
|
f42c78ce83 | ||
|
|
c46180bb6f | ||
|
|
8a9dd54fe7 | ||
|
|
031bc475fa | ||
|
|
c098ecc8c8 | ||
|
|
732925b986 | ||
|
|
cb00cf3c9e | ||
|
|
7df5e01974 | ||
|
|
a7922e498c | ||
|
|
d9e0218dba | ||
|
|
0bc99117af | ||
|
|
c643719085 | ||
|
|
e475d06403 | ||
|
|
f31ecce59c | ||
|
|
3e58e3a9ad | ||
|
|
d4ef10fc80 | ||
|
|
ec8942dd90 | ||
|
|
08a761fc17 | ||
|
|
dd4ca7a8b0 | ||
|
|
b1d809d9f3 | ||
|
|
18f8894a22 | ||
|
|
3876bc1a21 | ||
|
|
470c042690 | ||
|
|
75a5560aec | ||
|
|
a80e2d067c | ||
|
|
6bb9cce51b | ||
|
|
4b3e24bf02 | ||
|
|
bc17b33d44 | ||
|
|
3634105366 | ||
|
|
ceeafa8c6d | ||
|
|
a4fc40732a | ||
|
|
0836e96c2d | ||
|
|
d211f316ad | ||
|
|
bb80dde66d | ||
|
|
8bf31513f5 | ||
|
|
ae90b60fd6 | ||
|
|
1c20b53bdc | ||
|
|
f69761f37c | ||
|
|
cb7a932951 | ||
|
|
248e0d7db9 | ||
|
|
53c6c0ee80 | ||
|
|
b58b2ca70e | ||
|
|
8a58d3b6de | ||
|
|
e79ed52a4d | ||
|
|
4d7dc2a7d1 | ||
|
|
c2cfa51655 | ||
|
|
fb10b41918 | ||
|
|
210467b26d | ||
|
|
11f619b69e | ||
|
|
16e92a20e8 | ||
|
|
58f8f2e6e9 | ||
|
|
52f9a5b54b | ||
|
|
e6076e5568 | ||
|
|
42acb4f52b | ||
|
|
d239adbbbc | ||
|
|
6d942f5e45 | ||
|
|
bc0406cf02 | ||
|
|
23b6cec173 | ||
|
|
34beacf32b | ||
|
|
3e32c12c40 | ||
|
|
13791ec7bf | ||
|
|
452fb3d7cb | ||
|
|
12abc9bda9 | ||
|
|
987c029c87 | ||
|
|
6c00f7c7de | ||
|
|
bd1cacc0cf | ||
|
|
9cfa9038fc | ||
|
|
1c16a2d2b5 | ||
|
|
798f5493f9 | ||
|
|
4fa36487ab | ||
|
|
34467d42b3 | ||
|
|
ae624cfa44 | ||
|
|
05e5e0a5ac | ||
|
|
87344b93fc | ||
|
|
200d64f5ea | ||
|
|
ec35c74e2e | ||
|
|
027700c3f4 | ||
|
|
da93cce1fa | ||
|
|
448d3fe156 | ||
|
|
6158300062 | ||
|
|
3160e4aad6 | ||
|
|
93734fcefc | ||
|
|
a861079dc1 | ||
|
|
5148ee5f74 | ||
|
|
c48778d709 | ||
|
|
cf3c3a9dcc | ||
|
|
1705ced1b5 | ||
|
|
6a0635a2bb | ||
|
|
f568c9da62 | ||
|
|
94e42354cd | ||
|
|
642eb936c0 | ||
|
|
775959c3f9 | ||
|
|
77627bb8d9 | ||
|
|
b1fbd38352 | ||
|
|
a06b2c3969 | ||
|
|
34fd40d46a | ||
|
|
94c1f57f36 | ||
|
|
d0b97319a5 | ||
|
|
38d5c81051 | ||
|
|
914a16ec5c | ||
|
|
cb2070c93f | ||
|
|
b594d35931 | ||
|
|
00699ac3e5 | ||
|
|
d329e7ee42 | ||
|
|
d4fc22c74e | ||
|
|
b648f45e90 | ||
|
|
2cb5d6c316 | ||
|
|
0e7229cf8d | ||
|
|
9ec6912325 | ||
|
|
7cdf0d03f5 | ||
|
|
91df2f10bc | ||
|
|
1943dfc3d9 | ||
|
|
eb731cd3a5 | ||
|
|
ecc64cace1 | ||
|
|
bc0de24cba | ||
|
|
9f60b151ba | ||
|
|
159a63af97 | ||
|
|
6efabd3418 | ||
|
|
aee847431a | ||
|
|
6609abdd5a | ||
|
|
219c747a24 | ||
|
|
7559b65946 | ||
|
|
c8a33c7180 | ||
|
|
52f2cb5587 | ||
|
|
513ff66fcf | ||
|
|
fca0dc0485 | ||
|
|
cd686316e9 | ||
|
|
b8e9873f64 | ||
|
|
4c305e73f0 | ||
|
|
c8a9326306 | ||
|
|
445d367059 | ||
|
|
fdb8af7ca9 | ||
|
|
a89f19b4e5 | ||
|
|
5bc53dba7c | ||
|
|
b07fbd6271 | ||
|
|
44a2fc392a | ||
|
|
6265a3e7ce | ||
|
|
0afd257dd0 | ||
|
|
d192157ed8 | ||
|
|
6a04f42d0b | ||
|
|
5064d722c3 | ||
|
|
fb80d973c4 | ||
|
|
8363a4debf | ||
|
|
0c5233a650 | ||
|
|
c0666a5137 |
@@ -1,6 +1,9 @@
|
|||||||
---
|
---
|
||||||
profile: production
|
profile: production
|
||||||
|
|
||||||
|
warn_list:
|
||||||
|
- no-log-password
|
||||||
|
|
||||||
exclude_paths:
|
exclude_paths:
|
||||||
- .ansible/
|
- .ansible/
|
||||||
- .github/
|
- .github/
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
# https://docs.ansible.com/ansible-lint/docs/rules/
|
# https://docs.ansible.com/ansible-lint/docs/rules/
|
||||||
# no-changed-when is not requried for examples
|
|
||||||
plugins/connection/kubectl.py no-changed-when
|
|
||||||
# false positive result
|
|
||||||
plugins/connection/kubectl.py var-naming[no-reserved]
|
|
||||||
plugins/connection/kubectl.py jinja[invalid]
|
plugins/connection/kubectl.py jinja[invalid]
|
||||||
# collection EE metadata is not an ansible-builder definition file
|
# collection EE metadata is not an ansible-builder definition file
|
||||||
meta/execution-environment.yml schema[execution-environment]
|
meta/execution-environment.yml schema[execution-environment]
|
||||||
|
|||||||
@@ -81,8 +81,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- run: |
|
- run: |
|
||||||
python -c "
|
python -c "
|
||||||
import sys
|
|
||||||
|
|
||||||
required = ['sanity', 'units', 'coverage']
|
required = ['sanity', 'units', 'coverage']
|
||||||
if '${{ github.event_name }}' == 'pull_request':
|
if '${{ github.event_name }}' == 'pull_request':
|
||||||
required = ['security-check', 'linters', 'sanity', 'units', 'coverage']
|
required = ['security-check', 'linters', 'sanity', 'units', 'coverage']
|
||||||
@@ -93,29 +91,7 @@ jobs:
|
|||||||
'units': '${{ needs.units.result }}',
|
'units': '${{ needs.units.result }}',
|
||||||
'coverage': '${{ needs.coverage.result }}',
|
'coverage': '${{ needs.coverage.result }}',
|
||||||
}
|
}
|
||||||
|
ok = all(results[j] == 'success' for j in required)
|
||||||
for name in required:
|
skipped_ok = all(results[j] in ('success', 'skipped') for j in results)
|
||||||
if results[name] == 'failure':
|
assert ok and skipped_ok, f'required={required} results={results}'
|
||||||
print(f'all_green: required job failed: {name} results={results}', file=sys.stderr)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
# cancel-in-progress superseded this run; do not fail (newer run is authoritative)
|
|
||||||
if any(v == 'cancelled' for v in results.values()):
|
|
||||||
print(
|
|
||||||
'all_green: one or more jobs cancelled (usually concurrency); skipping strict gate.',
|
|
||||||
results,
|
|
||||||
)
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
not_ok = [j for j in required if results[j] != 'success']
|
|
||||||
if not_ok:
|
|
||||||
print(f'all_green: required jobs not success: {not_ok} results={results}', file=sys.stderr)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
for job, status in results.items():
|
|
||||||
if job not in required and status not in ('success', 'skipped'):
|
|
||||||
print(f'all_green: unexpected {job}={status} results={results}', file=sys.stderr)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
print('all_green OK', results)
|
|
||||||
"
|
"
|
||||||
|
|||||||
@@ -0,0 +1,210 @@
|
|||||||
|
name: Integration tests Helm
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: integration-tests-helm-${{ github.head_ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- reopened
|
||||||
|
- labeled
|
||||||
|
- unlabeled
|
||||||
|
- synchronize
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- stable-*
|
||||||
|
|
||||||
|
permissions: {}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
splitter:
|
||||||
|
env:
|
||||||
|
source_dir: "./source"
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
helm_targets: ${{ steps.select-targets.outputs.targets }}
|
||||||
|
permissions:
|
||||||
|
pull-requests: read
|
||||||
|
contents: read
|
||||||
|
steps:
|
||||||
|
- name: Checkout the collection repository
|
||||||
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
with:
|
||||||
|
path: ${{ env.source_dir }}
|
||||||
|
fetch-depth: "0"
|
||||||
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
persist-credentials: false
|
||||||
|
|
||||||
|
- name: list changes for pull request
|
||||||
|
id: splitter
|
||||||
|
uses: ansible-network/github_actions/.github/actions/ansible_test_splitter@4678c74a7d712d55e663c88f66eec6d9c3642550
|
||||||
|
with:
|
||||||
|
collections_to_test: ${{ env.source_dir }}
|
||||||
|
total_jobs: 8
|
||||||
|
|
||||||
|
- name: Select Helm targets
|
||||||
|
id: select-targets
|
||||||
|
run: |
|
||||||
|
import os, json
|
||||||
|
with open(os.environ.get('GITHUB_OUTPUT'), "a", encoding="utf-8") as fh:
|
||||||
|
data = os.environ.get("ALL_TEST_TARGETS")
|
||||||
|
targets = []
|
||||||
|
for target in data.split(";"):
|
||||||
|
if target and ':' in target:
|
||||||
|
targets.extend([v for v in target.split(':', maxsplit=1)[1].split(',') if v.startswith('helm')])
|
||||||
|
fh.write(f'targets={json.dumps(targets)}\n')
|
||||||
|
shell: python
|
||||||
|
env:
|
||||||
|
ALL_TEST_TARGETS: ${{ steps.splitter.outputs.test_targets }}
|
||||||
|
|
||||||
|
integration:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 60
|
||||||
|
needs:
|
||||||
|
- splitter
|
||||||
|
if: ${{ needs.splitter.outputs.helm_targets != '' && needs.splitter.outputs.helm_targets != '[]' }}
|
||||||
|
env:
|
||||||
|
source: "./source"
|
||||||
|
ansible_posix: "./ansible_posix"
|
||||||
|
community_general: "./community_general"
|
||||||
|
ansible-version: "milestone"
|
||||||
|
python-version: "3.13"
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
helm-version:
|
||||||
|
- v3.0.0
|
||||||
|
- v3.1.0
|
||||||
|
- v3.8.0
|
||||||
|
- v3.10.3
|
||||||
|
- v3.15.4
|
||||||
|
- v3.16.0
|
||||||
|
- v3.17.0
|
||||||
|
- v3.22.0
|
||||||
|
- v4.0.0
|
||||||
|
- v4.2.1
|
||||||
|
- latest
|
||||||
|
ansible_test_target: ${{ fromJson(needs.splitter.outputs.helm_targets) }}
|
||||||
|
exclude:
|
||||||
|
# helm_registry_auth: only test against recent versions to reduce CI cost
|
||||||
|
- ansible_test_target: "helm_registry_auth"
|
||||||
|
helm-version: "v3.0.0"
|
||||||
|
- ansible_test_target: "helm_registry_auth"
|
||||||
|
helm-version: "v3.1.0"
|
||||||
|
- ansible_test_target: "helm_registry_auth"
|
||||||
|
helm-version: "v3.8.0"
|
||||||
|
- ansible_test_target: "helm_registry_auth"
|
||||||
|
helm-version: "v3.10.3"
|
||||||
|
- ansible_test_target: "helm_registry_auth"
|
||||||
|
helm-version: "v3.15.4"
|
||||||
|
- ansible_test_target: "helm_registry_auth"
|
||||||
|
helm-version: "v3.16.0"
|
||||||
|
# helm install/upgrade --create-namespace requires helm >= 3.2.0
|
||||||
|
- ansible_test_target: "helm_diff"
|
||||||
|
helm-version: "v3.0.0"
|
||||||
|
- ansible_test_target: "helm_diff"
|
||||||
|
helm-version: "v3.1.0"
|
||||||
|
- ansible_test_target: "helm_diff"
|
||||||
|
helm-version: "v3.8.0"
|
||||||
|
- ansible_test_target: "helm_diff"
|
||||||
|
helm-version: "v3.10.3"
|
||||||
|
# UPGRADE FAILED: conflict occurred while applying object helm-diff/test-chart-another-configmap /v1
|
||||||
|
- ansible_test_target: "helm_diff"
|
||||||
|
helm-version: "v4.0.0"
|
||||||
|
- ansible_test_target: "helm_repository"
|
||||||
|
helm-version: "v3.0.0"
|
||||||
|
- ansible_test_target: "helm_repository"
|
||||||
|
helm-version: "v3.1.0"
|
||||||
|
- ansible_test_target: "helm_kubeconfig"
|
||||||
|
helm-version: "v3.0.0"
|
||||||
|
- ansible_test_target: "helm_kubeconfig"
|
||||||
|
helm-version: "v3.1.0"
|
||||||
|
- ansible_test_target: "helm_set_values"
|
||||||
|
helm-version: "v3.0.0"
|
||||||
|
- ansible_test_target: "helm_set_values"
|
||||||
|
helm-version: "v3.1.0"
|
||||||
|
- ansible_test_target: "helm_set_values"
|
||||||
|
helm-version: "v3.8.0"
|
||||||
|
- ansible_test_target: "helm"
|
||||||
|
helm-version: "v3.0.0"
|
||||||
|
- ansible_test_target: "helm"
|
||||||
|
helm-version: "v3.1.0"
|
||||||
|
- ansible_test_target: "helm_uninstall"
|
||||||
|
helm-version: "v3.0.0"
|
||||||
|
- ansible_test_target: "helm_uninstall"
|
||||||
|
helm-version: "v3.1.0"
|
||||||
|
name: "${{ matrix.ansible_test_target }}-${{ matrix.helm-version }}"
|
||||||
|
steps:
|
||||||
|
- name: Checkout kubernetes.core repository
|
||||||
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
with:
|
||||||
|
path: ${{ env.source }}
|
||||||
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
persist-credentials: false
|
||||||
|
|
||||||
|
- name: Set up Python ${{ env.python-version }}
|
||||||
|
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
||||||
|
with:
|
||||||
|
python-version: ${{ env.python-version }}
|
||||||
|
|
||||||
|
# install ansible
|
||||||
|
- name: Install ansible-core (${{ env.ansible-version }})
|
||||||
|
env:
|
||||||
|
ANSIBLE_VERSION: ${{ env.ansible-version }}
|
||||||
|
run: |
|
||||||
|
curl -sSL --proto '=https' --tlsv1.2 --retry 5 --retry-delay 10 --retry-all-errors \
|
||||||
|
"https://github.com/ansible/ansible/archive/${ANSIBLE_VERSION}.tar.gz" \
|
||||||
|
-o ansible.tar.gz
|
||||||
|
python3 -m pip install --disable-pip-version-check ./ansible.tar.gz
|
||||||
|
rm ansible.tar.gz
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Build and install collection
|
||||||
|
id: install-src
|
||||||
|
uses: ansible-network/github_actions/.github/actions/build_install_collection@4678c74a7d712d55e663c88f66eec6d9c3642550
|
||||||
|
with:
|
||||||
|
install_python_dependencies: true
|
||||||
|
source_path: ${{ env.source }}
|
||||||
|
|
||||||
|
- name: create kubernetes cluster
|
||||||
|
uses: helm/kind-action@ef37e7f390d99f746eb8b610417061a60e82a6cc # v1.14.0
|
||||||
|
with:
|
||||||
|
node_image: "kindest/node:v1.29.2"
|
||||||
|
|
||||||
|
- name: "Install Helm version ${{ matrix.helm-version }}"
|
||||||
|
uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1
|
||||||
|
with:
|
||||||
|
version: '${{ matrix.helm-version }}'
|
||||||
|
|
||||||
|
- name: Verify Helm Installation
|
||||||
|
run: helm version
|
||||||
|
|
||||||
|
- name: Disable selinux with selinux_please_lie_to_me
|
||||||
|
run: |
|
||||||
|
python3 -m pip uninstall -y selinux
|
||||||
|
python3 -m pip install --only-binary=:all: selinux_please_lie_to_me==1.0.1
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Install python requirements
|
||||||
|
run: python3 -m pip install -r requirements.txt -r test-requirements.txt
|
||||||
|
shell: bash
|
||||||
|
working-directory: ${{ steps.install-src.outputs.collection_path }}
|
||||||
|
|
||||||
|
- name: Run integration tests
|
||||||
|
run: >-
|
||||||
|
ansible-test integration
|
||||||
|
--diff
|
||||||
|
--no-temp-workdir
|
||||||
|
--color
|
||||||
|
--skip-tags False
|
||||||
|
--retry-on-error
|
||||||
|
--continue-on-error
|
||||||
|
--python ${{ env.python-version }}
|
||||||
|
-v
|
||||||
|
${{ matrix.ansible_test_target }}
|
||||||
|
shell: bash
|
||||||
|
working-directory: ${{ steps.install-src.outputs.collection_path }}
|
||||||
@@ -17,9 +17,8 @@ jobs:
|
|||||||
source_dir: "./source"
|
source_dir: "./source"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
test_targets: ${{ steps.splitter.outputs.test_targets }}
|
test_targets: ${{ steps.select-targets.outputs.targets }}
|
||||||
test_targets_json: ${{ steps.splitter.outputs.test_targets_json }}
|
test_jobs: ${{ steps.select-targets.outputs.jobs }}
|
||||||
test_jobs: ${{ steps.splitter.outputs.test_jobs }}
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout the collection repository
|
- name: Checkout the collection repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
@@ -35,18 +34,40 @@ jobs:
|
|||||||
collections_to_test: ${{ env.source_dir }}
|
collections_to_test: ${{ env.source_dir }}
|
||||||
total_jobs: 8
|
total_jobs: 8
|
||||||
|
|
||||||
- name: Display splitter output
|
- name: Remove all Helm related targets
|
||||||
|
id: select-targets
|
||||||
run: |
|
run: |
|
||||||
echo "test_targets=${{ steps.splitter.outputs.test_targets }}"
|
import os, json
|
||||||
echo "test_targets_json=${{ steps.splitter.outputs.test_targets_json }}"
|
with open(os.environ.get('GITHUB_OUTPUT'), "a", encoding="utf-8") as fh:
|
||||||
echo "test_jobs=${{ steps.splitter.outputs.test_jobs }}"
|
data = os.environ.get("ALL_TEST_TARGETS")
|
||||||
|
index = 0
|
||||||
|
result = {}
|
||||||
|
for target in data.split(";"):
|
||||||
|
if target and ':' in target:
|
||||||
|
k8s = [v for v in target.split(':', maxsplit=1)[1].split(',') if not v.startswith('helm')]
|
||||||
|
if k8s:
|
||||||
|
result[index] = ' '.join(k8s)
|
||||||
|
index += 1
|
||||||
|
fh.write(f'targets={json.dumps(result)}\n')
|
||||||
|
fh.write(f'jobs={json.dumps(list(result.keys()))}\n')
|
||||||
|
shell: python
|
||||||
|
env:
|
||||||
|
ALL_TEST_TARGETS: ${{ steps.splitter.outputs.test_targets }}
|
||||||
|
|
||||||
|
- name: Display splitter output
|
||||||
|
env:
|
||||||
|
TARGETS: ${{ steps.select-targets.outputs.targets }}
|
||||||
|
JOBS: ${{ steps.select-targets.outputs.jobs }}
|
||||||
|
run: |
|
||||||
|
echo "targets => $TARGETS"
|
||||||
|
echo "jobs => $JOBS"
|
||||||
shell: bash
|
shell: bash
|
||||||
integration:
|
integration:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 60
|
timeout-minutes: 60
|
||||||
needs:
|
needs:
|
||||||
- splitter
|
- splitter
|
||||||
if: ${{ needs.splitter.outputs.test_targets != '' }}
|
if: ${{ needs.splitter.outputs.test_jobs != '' && needs.splitter.outputs.test_jobs != '[]' }}
|
||||||
env:
|
env:
|
||||||
source: "./source"
|
source: "./source"
|
||||||
cloud_common: "./cloudcommon"
|
cloud_common: "./cloudcommon"
|
||||||
@@ -87,12 +108,14 @@ jobs:
|
|||||||
fh.write(f'ansible_test_targets={json.loads(os.environ.get("ALL_TEST_TARGETS")).get(os.environ.get("WORKFLOW_ID"))}\n')
|
fh.write(f'ansible_test_targets={json.loads(os.environ.get("ALL_TEST_TARGETS")).get(os.environ.get("WORKFLOW_ID"))}\n')
|
||||||
shell: python
|
shell: python
|
||||||
env:
|
env:
|
||||||
ALL_TEST_TARGETS: ${{ needs.splitter.outputs.test_targets_json }}
|
ALL_TEST_TARGETS: ${{ needs.splitter.outputs.test_targets }}
|
||||||
WORKFLOW_ID: ${{ matrix.workflow-id }}
|
WORKFLOW_ID: ${{ matrix.workflow-id }}
|
||||||
|
|
||||||
- name: Display ansible test targets
|
- name: Display ansible test targets
|
||||||
|
env:
|
||||||
|
ANSIBLE_TEST_TARGETS: ${{ steps.read-targets.outputs.ansible_test_targets }}
|
||||||
run: |
|
run: |
|
||||||
echo "ansible_test_targets -> ${{ steps.read-targets.outputs.ansible_test_targets }}"
|
echo "ansible_test_targets -> $ANSIBLE_TEST_TARGETS"
|
||||||
|
|
||||||
- name: Checkout kubernetes.core repository
|
- name: Checkout kubernetes.core repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
name: label new issues
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- reopened
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
add_label:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
issues: write
|
||||||
|
steps:
|
||||||
|
- uses: actions-ecosystem/action-add-labels@v1
|
||||||
|
with:
|
||||||
|
labels: needs_triage
|
||||||
+3
-1
@@ -16,11 +16,13 @@ tests/integration/cloud-config-*
|
|||||||
.ansible
|
.ansible
|
||||||
|
|
||||||
# Helm charts
|
# Helm charts
|
||||||
tests/integration/*-chart-*.tgz
|
tests/integration/*.tgz
|
||||||
|
tests/integration/targets/*/*.tgz
|
||||||
|
|
||||||
# ansible-test generated file
|
# ansible-test generated file
|
||||||
tests/integration/inventory
|
tests/integration/inventory
|
||||||
tests/integration/*-*.yml
|
tests/integration/*-*.yml
|
||||||
|
tests/integration/integration_config.yml
|
||||||
|
|
||||||
# IDE and editor settings
|
# IDE and editor settings
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/ansible/cloud-content-ci-automation
|
- repo: https://github.com/ansible/cloud-content-ci-automation
|
||||||
rev: precommit_hook
|
rev: 77f45b0357b6b3c27b04e934f0f51c9b50b7aa25
|
||||||
hooks:
|
hooks:
|
||||||
- id: block-ide-ai-files
|
- id: block-ide-ai-files
|
||||||
always_run: true
|
always_run: true
|
||||||
|
|||||||
+192
-1
@@ -4,6 +4,197 @@ Kubernetes Collection Release Notes
|
|||||||
|
|
||||||
.. contents:: Topics
|
.. contents:: Topics
|
||||||
|
|
||||||
|
v6.6.0
|
||||||
|
======
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- Remove the remaining ``ansible.module_utils.six`` import to avoid deprecation warnings, replacing it with the Python standard library equivalent (https://github.com/ansible-collections/kubernetes.core/pull/1197).
|
||||||
|
- helm - Add ``wait_for_jobs`` option to wait for all Jobs to complete before marking a Helm release as successful. Requires Helm >= 3.5.0 (https://github.com/ansible-collections/kubernetes.core/pull/1140).
|
||||||
|
- helm - add the ``cleanup_on_fail`` option, mapping to the ``--cleanup-on-fail`` flag, to allow deletion of new resources created during a failed upgrade. It complements ``atomic`` and can be combined with it, but cannot be used with ``replace``, since that deploys through ``helm install`` which does not accept the flag (https://github.com/ansible-collections/kubernetes.core/pull/1206).
|
||||||
|
- helm - warn when ``reuse_values`` or ``reset_then_reuse_values`` is requested in a combination helm ignores, which happens by default because ``reset_values`` defaults to ``true``, and whenever either is combined with ``replace``. The option descriptions and the examples now state that ``reset_values`` has to be set to ``false`` for either option to take effect (https://github.com/ansible-collections/kubernetes.core/pull/1230).
|
||||||
|
- k8s lookup - warn when ``ENABLE_TURBO_MODE`` is set but the ``cloud.common`` collection is not installed, instead of silently falling back to the standard lookup base (https://github.com/ansible-collections/kubernetes.core/pull/1242).
|
||||||
|
- k8s_cp - Add the ``copy_timeout`` option (default 300 seconds) bounding how long the module will spend streaming an archive to a pod and waiting for the remote ``tar`` to finish, so that a stalled copy fails instead of hanging indefinitely (https://github.com/ansible-collections/kubernetes.core/pull/1217).
|
||||||
|
- k8s_cp - Stream the tar archive to the pod chunk by chunk instead of building the whole archive in memory first, which cuts peak memory use when copying large files (https://github.com/ansible-collections/kubernetes.core/pull/1217).
|
||||||
|
- k8s_cp - When copying to a pod, the module now also uses ``/bin/sh`` and ``head`` in the container, when present, to confirm the copy completed. Containers without them keep the previous behaviour and get a warning that completion could not be verified (https://github.com/ansible-collections/kubernetes.core/pull/1217).
|
||||||
|
- k8s_info - Support for metadata-only fetches in k8s_info module (https://github.com/ansible-collections/kubernetes.core/pull/1030)
|
||||||
|
- meta - Add ``helm_plugin`` and ``helm_plugin_info`` to the ``helm`` action group, and ``k8s_taint`` to the ``k8s`` action group, so that ``module_defaults`` set on those groups applies to them (https://github.com/ansible-collections/kubernetes.core/pull/1216).
|
||||||
|
- use `collections.abc` instead of deprecated `ansible.module_utils.common._collections_compat` (https://github.com/ansible-collections/kubernetes.core/pull/1057).
|
||||||
|
- waiter - Add ``job_complete`` predicate to support waiting for Job resources to reach ``Complete`` or ``Failed`` condition (https://github.com/ansible-collections/kubernetes.core/issues/1201).
|
||||||
|
|
||||||
|
Deprecated Features
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
- Ansible Turbo mode (``ENABLE_TURBO_MODE``) has been deprecated and will be removed in release 8.0.0, as it depends on the ``cloud.common`` collection, which is being retired (https://github.com/ansible-collections/kubernetes.core/pull/1242).
|
||||||
|
- helm - the ``status.values`` return value has been deprecated and will be removed in version 8.0.0. Use ``status.release_values`` instead (https://github.com/ansible-collections/kubernetes.core/issues/1239).
|
||||||
|
- helm - the ``wait_timeout`` parameter has been deprecated and will be removed in version 7.0.0. Use ``timeout`` instead (https://github.com/ansible-collections/kubernetes.core/issues/1239).
|
||||||
|
- helm_info - the ``status.values`` return value has been deprecated and will be removed in version 8.0.0. Use ``status.release_values`` instead (https://github.com/ansible-collections/kubernetes.core/issues/1239).
|
||||||
|
- k8s_exec - the ``return_code`` return value has been deprecated and will be removed in version 7.0.0. Use ``rc`` instead (https://github.com/ansible-collections/kubernetes.core/issues/1239).
|
||||||
|
- k8s_service - the ``merge_type=json`` option has been deprecated and will be removed in version 7.0.0. Use ``kubernetes.core.k8s_json_patch`` module instead (https://github.com/ansible-collections/kubernetes.core/issues/1239).
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
--------
|
||||||
|
|
||||||
|
- Ansible Turbo mode - ignore ``ENABLE_TURBO_MODE`` on ansible-core 2.19.0 and later, where the ``cloud.common`` collection is not supported, and fall back to the standard ``AnsibleModule`` instead of failing with ``byte indices must be integers or slices, not str`` (https://github.com/ansible-collections/kubernetes.core/pull/1242).
|
||||||
|
- helm - do not pass the upgrade-only ``--reuse-values`` and ``--reset-then-reuse-values`` flags to ``helm install``, which rejected them with ``unknown flag`` whenever ``reuse_values`` or ``reset_then_reuse_values`` was combined with ``replace`` (https://github.com/ansible-collections/kubernetes.core/pull/1230).
|
||||||
|
- helm - fix the ``reuse_values`` example, which set only ``reuse_values=true``. ``reset_values`` defaults to ``true`` and helm ignores ``--reuse-values`` whenever ``--reset-values`` is passed, so following the example reset the release values instead of reusing them (https://github.com/ansible-collections/kubernetes.core/pull/1230).
|
||||||
|
- helm - skip Helm's OCI registry progress messages when parsing the output of ``helm show chart``. As of Helm 4.2.1 these are printed to stdout instead of stderr (https://github.com/helm/helm/pull/32056), which made installing a chart from an OCI registry fail with a YAML scanner error when the chart version contained a ``+`` (https://github.com/ansible-collections/kubernetes.core/pull/1223).
|
||||||
|
- helm_repository - normalize both sides of the repository URL comparison, so that a repository already registered with a trailing slash is recognized as matching instead of failing with ``Repository already have a repository named <name>`` (https://github.com/ansible-collections/kubernetes.core/pull/1236).
|
||||||
|
- helm_template - strip Helm's OCI registry progress messages from the returned ``stdout``, which is documented to contain only the rendered templates (https://github.com/ansible-collections/kubernetes.core/pull/1223).
|
||||||
|
- k8s lookup - ignore ``ENABLE_TURBO_MODE`` on ansible-core 2.19.0 and later, where the ``cloud.common`` collection is not supported. Fall back to the standard ``LookupBase`` instead of failing with a traceback (https://github.com/ansible-collections/kubernetes.core/pull/1253).
|
||||||
|
- k8s_cp - Fix silent truncation when copying to a pod. The module closed the exec connection immediately after writing the last chunk of the tar archive, which killed the remote ``tar`` before it had finished extracting, and never checked the process exit status, so a partial copy was reported as a success. The archive is now bounded with ``head -c`` so ``tar`` gets a clean EOF and exits on its own, and the module waits for that exit and fails on a non-zero status (https://github.com/ansible-collections/kubernetes.core/pull/1217).
|
||||||
|
- k8s_info - Handle empty template output gracefully by returning ``changed=false`` instead of failing when Jinja2 template renders to an empty string (https://github.com/ansible-collections/kubernetes.core/issues/1042).
|
||||||
|
|
||||||
|
v6.5.0
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
This release implements minor changes and bug fixes such as a new ``remove`` value to the ``behavior`` option of the ``kubeconfig`` module, allowing entries to be deleted from the kubeconfig file by name, as well as Helm v4 compatibility across the Helm modules.
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- helm - add the ``server_side`` and ``force_conflicts`` options to control Helm v4 server-side apply when installing or upgrading a release (https://github.com/ansible-collections/kubernetes.core/pull/1164).
|
||||||
|
- helm_plugin - add ``--keyring`` argument to allow changing the keyring default location. The option is only accepted with ``state=present`` (the ``helm plugin install`` subcommand), as that is the only implemented subcommand that supports ``--keyring`` (https://github.com/ansible-collections/kubernetes.core/pull/1150).
|
||||||
|
- helm_registry_auth - document that, as of Helm 4.2.1, registry success messages such as ``Login Succeeded`` are printed to stdout instead of stderr (https://github.com/ansible-collections/kubernetes.core/pull/1147).
|
||||||
|
- kubeconfig - add ``remove`` value to the ``behavior`` option, allowing entries to be deleted from the kubeconfig file by name (https://github.com/ansible-collections/kubernetes.core/pull/1123).
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
--------
|
||||||
|
|
||||||
|
- ee - added ``meta/execution-environment.yml`` to decouple ansible-builder EE builds from the ``openshift-clients`` system dependency declared in ``bindep.txt``, which is not available in standard UBI repositories and caused builds to fail with ``No package matches 'openshift-clients'`` (https://github.com/ansible-collections/kubernetes.core/issues/1141).
|
||||||
|
- helm - use ``--server-side=false --force-replace`` instead of the deprecated/removed ``--force`` flag when ``force=true`` is used with Helm v4, preserving the Helm v3 client-side replacement behaviour and avoiding the server-side apply conflict (https://github.com/ansible-collections/kubernetes.core/pull/1164).
|
||||||
|
- helm - use the ``--rollback-on-failure`` flag instead of the deprecated/removed ``--atomic`` flag when ``atomic=true`` is used with Helm v4 (https://github.com/ansible-collections/kubernetes.core/pull/1144).
|
||||||
|
- helm_repository - correct handling of repository URLs with trailing slashes (https://github.com/ansible-collections/kubernetes.core/pull/1121).
|
||||||
|
- k8s_drain - Fix logic for handling pods with local storage to correctly check for empty_dir volumes in replicated pods and pods managed by DaemonSets (https://github.com/ansible-collections/kubernetes.core/pull/1095).
|
||||||
|
|
||||||
|
New Modules
|
||||||
|
-----------
|
||||||
|
|
||||||
|
- kubeconfig - Generate, update, and optionally write Kubernetes kubeconfig files
|
||||||
|
|
||||||
|
v6.4.0
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
This release adds Helm v4 compatibility across the Helm modules and improves ``k8s_drain`` with check mode. When you explicitly allow evicting unmanaged pods, pods with local storage, or pods managed by a ``DaemonSet``, those cases are reported as informational output instead of module warnings.
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- helm_info - Ensure compatibility with Helm v4 (https://github.com/ansible-collections/kubernetes.core/issues/1038).
|
||||||
|
- helm_plugin - Ensure compatibility with Helm v4 (https://github.com/ansible-collections/kubernetes.core/issues/1038).
|
||||||
|
- helm_plugin_info - Ensure compatibility with Helm v4 (https://github.com/ansible-collections/kubernetes.core/issues/1038).
|
||||||
|
- helm_pull - Ensure compatibility with Helm v4 (https://github.com/ansible-collections/kubernetes.core/issues/1038).
|
||||||
|
- helm_registry_auth - Ensure compatibility with Helm v4 (https://github.com/ansible-collections/kubernetes.core/issues/1038).
|
||||||
|
- helm_registry_auth - add new option plain_http to allow insecure http connection when running ``helm registry login`` (https://github.com/ansible-collections/kubernetes.core/pull/1090).
|
||||||
|
- helm_repository - Ensure compatibility with Helm v4 (https://github.com/ansible-collections/kubernetes.core/issues/1038).
|
||||||
|
- k8s_drain - Add support for ``check_mode`` (https://github.com/ansible-collections/kubernetes.core/pull/1086).
|
||||||
|
- k8s_drain - Convert module warnings into informational displays when users explicitly request the deletion of unmanaged pods, pods with local storage, or those managed by a ``DaemonSet`` (https://github.com/ansible-collections/kubernetes.core/issues/1037).
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
--------
|
||||||
|
|
||||||
|
- Helm - Allow taking ownership of existing Kubernetes resources on the first installation of a Helm release. Previously, the ``take_ownership`` parameter was always disabled during the initial install, preventing resource adoption (https://github.com/ansible-collections/kubernetes.core/pull/1034).
|
||||||
|
|
||||||
|
v6.3.0
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
This release includes bugfixes such as implementing idempotency for the ``helm_pull`` module as well as a security update for selectively redacting sensitive information from kubeconfig.
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- Remove deprecated import from ``ansible.module_utils._text`` (https://github.com/ansible-collections/kubernetes.core/pull/1053).
|
||||||
|
- helm - add ``release_values`` key to ``status`` return value that can be accessed using Jinja2 dot notation (https://github.com/ansible-collections/kubernetes.core/pull/1056).
|
||||||
|
- helm_info - add ``release_values`` key to ``status`` return value that can be accessed using Jinja2 dot notation (https://github.com/ansible-collections/kubernetes.core/pull/1056).
|
||||||
|
|
||||||
|
Deprecated Features
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
- helm - the ``status.values`` return value has been deprecated and will be removed in a release after 2027-01-08. Use ``status.release_values`` instead (https://github.com/ansible-collections/kubernetes.core/pull/1056).
|
||||||
|
- helm_info - the ``status.values`` return value has been deprecated and will be removed in a release after 2027-01-08. Use ``status.release_values`` instead (https://github.com/ansible-collections/kubernetes.core/pull/1056).
|
||||||
|
|
||||||
|
Security Fixes
|
||||||
|
--------------
|
||||||
|
|
||||||
|
- Selectively redact sensitive info from kubeconfig instead of applying blanket ``no_log=True`` (https://github.com/ansible-collections/kubernetes.core/pull/1014).
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
--------
|
||||||
|
|
||||||
|
- Add idempotency for ``helm_pull`` module (https://github.com/ansible-collections/kubernetes.core/pull/1055).
|
||||||
|
- Fixed a bug where setting ``K8S_AUTH_VERIFY_SSL=true`` (or any string value) caused the value to be treated as a separate ``kubectl`` command argument. (https://github.com/ansible-collections/kubernetes.core/pull/1049).
|
||||||
|
- Limit supported versions of Helm to <4.0.0 (https://github.com/ansible-collections/kubernetes.core/pull/1039).
|
||||||
|
- Replace passing ``warnings`` to ``exit_json`` with ``AnsibleModule.warn`` in the ``k8s_drain``, ``k8s_rollback.py`` and ``k8s_scale.py`` modules as it deprecated in ``ansible-core>=2.19.0`` and will be removed in ``ansible-core>=2.23.0`` (https://github.com/ansible-collections/kubernetes.core/pull/1033).
|
||||||
|
- k8s - Fix return block from the module documentation (https://github.com/ansible-collections/kubernetes.core/pull/1056).
|
||||||
|
- meta - Add ``k8s_cluster_info``, ``k8s_json_patch`` and ``k8s_rollback`` to k8s action group (https://github.com/ansible-collections/kubernetes.core/pull/992).
|
||||||
|
|
||||||
|
v6.2.0
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
This release adds minor changes and bugfixes, including support of skip-schema-validation in ``helm`` module and removing deprecated ``ansible.module_utils.six`` imports.
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- Add support of skip-schema-validation in ``helm`` module (https://github.com/ansible-collections/kubernetes.core/pull/995)
|
||||||
|
- kustomize - Add support of local environ (https://github.com/ansible-collections/kubernetes.core/pull/786).
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
--------
|
||||||
|
|
||||||
|
- Remove ``ansible.module_utils.six`` imports to avoid warnings (https://github.com/ansible-collections/kubernetes.core/pull/998).
|
||||||
|
- Update the ``k8s_cp`` module to also work for init containers (https://github.com/ansible-collections/kubernetes.core/pull/971).
|
||||||
|
|
||||||
|
v6.1.0
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
This release adds ``plain_http`` and ``take_ownership`` parameters for helm modules, support for ``hidden_fields`` in ``k8s_json_patch``, documented lack of idempotency support in ``helm_registry_auth`` with ``helm ≥ 3.18.0``, and improved ``k8s_rollback`` test coverage.
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- Module ``helm_registry_auth`` does not support idempotency with `helm >= 3.18.0` (https://github.com/ansible-collections/kubernetes.core/pull/946).
|
||||||
|
- Module k8s_json_patch - Add support for ``hidden_fields`` (https://github.com/ansible-collections/kubernetes.core/pull/964).
|
||||||
|
- helm - Parameter plain_http added for working with insecure OCI registries (https://github.com/ansible-collections/kubernetes.core/pull/934).
|
||||||
|
- helm - Parameter take_ownership added (https://github.com/ansible-collections/kubernetes.core/pull/957).
|
||||||
|
- helm_pull - Parameter plain_http added for working with insecure OCI registries (https://github.com/ansible-collections/kubernetes.core/pull/934).
|
||||||
|
- helm_template - Parameter plain_http added for working with insecure OCI registries (https://github.com/ansible-collections/kubernetes.core/pull/934).
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
--------
|
||||||
|
|
||||||
|
- module_utils/k8s/service - hide fields first before creating diffs (https://github.com/ansible-collections/kubernetes.core/pull/915).
|
||||||
|
|
||||||
|
v6.0.0
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
This major release removes the deprecated ``k8s`` inventory plugin and also removes ``ansible-core<2.16`` support.
|
||||||
|
|
||||||
|
Breaking Changes / Porting Guide
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
- Remove deprecated ``k8s`` invetory plugin (https://github.com/ansible-collections/kubernetes.core/pull/867).
|
||||||
|
- Remove support for ``ansible-core<2.16`` (https://github.com/ansible-collections/kubernetes.core/pull/867).
|
||||||
|
|
||||||
v5.5.0
|
v5.5.0
|
||||||
======
|
======
|
||||||
|
|
||||||
@@ -111,7 +302,7 @@ Bugfixes
|
|||||||
--------
|
--------
|
||||||
|
|
||||||
- Remove ``ansible.module_utils.six`` imports to avoid warnings (https://github.com/ansible-collections/kubernetes.core/pull/998).
|
- Remove ``ansible.module_utils.six`` imports to avoid warnings (https://github.com/ansible-collections/kubernetes.core/pull/998).
|
||||||
- Update the `k8s_cp` module to also work for init containers (https://github.com/ansible-collections/kubernetes.core/pull/971).
|
- Update the ``k8s_cp`` module to also work for init containers (https://github.com/ansible-collections/kubernetes.core/pull/971).
|
||||||
- module_utils/k8s/service - hide fields first before creating diffs (https://github.com/ansible-collections/kubernetes.core/pull/915).
|
- module_utils/k8s/service - hide fields first before creating diffs (https://github.com/ansible-collections/kubernetes.core/pull/915).
|
||||||
|
|
||||||
v5.4.0
|
v5.4.0
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Also needs to be updated in galaxy.yml
|
# Also needs to be updated in galaxy.yml
|
||||||
VERSION = 5.5.0
|
VERSION = 7.0.0-dev0
|
||||||
|
|
||||||
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]))'`
|
||||||
|
|||||||
@@ -22,47 +22,43 @@ Click on the name of a plugin or module to view that content's documentation:
|
|||||||
### Connection plugins
|
### Connection plugins
|
||||||
Name | Description
|
Name | Description
|
||||||
--- | ---
|
--- | ---
|
||||||
[kubernetes.core.kubectl](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/kubernetes.core.kubectl_connection.rst)|Execute tasks in pods running on Kubernetes.
|
[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
|
|
||||||
Name | Description
|
|
||||||
--- | ---
|
|
||||||
[kubernetes.core.k8s](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/kubernetes.core.k8s_inventory.rst)|Kubernetes (K8s) inventory source
|
|
||||||
|
|
||||||
### Lookup plugins
|
### Lookup plugins
|
||||||
Name | Description
|
Name | Description
|
||||||
--- | ---
|
--- | ---
|
||||||
[kubernetes.core.k8s](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/kubernetes.core.k8s_lookup.rst)|Query the K8s API
|
[kubernetes.core.k8s](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_lookup.rst)|Query the K8s API
|
||||||
[kubernetes.core.kustomize](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/kubernetes.core.kustomize_lookup.rst)|Build a set of kubernetes resources using a 'kustomization.yaml' file.
|
[kubernetes.core.kustomize](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.kustomize_lookup.rst)|Build a set of kubernetes resources using a 'kustomization.yaml' file.
|
||||||
|
|
||||||
### Modules
|
### Modules
|
||||||
Name | Description
|
Name | Description
|
||||||
--- | ---
|
--- | ---
|
||||||
[kubernetes.core.helm](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/kubernetes.core.helm_module.rst)|Manages Kubernetes packages with the Helm package manager
|
[kubernetes.core.helm](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.helm_module.rst)|Manages Kubernetes packages with the Helm package manager
|
||||||
[kubernetes.core.helm_info](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/kubernetes.core.helm_info_module.rst)|Get information from Helm package deployed inside the cluster
|
[kubernetes.core.helm_info](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.helm_info_module.rst)|Get information from Helm package deployed inside the cluster
|
||||||
[kubernetes.core.helm_plugin](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/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/stable-5/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/stable-5/docs/kubernetes.core.helm_pull_module.rst)|download a chart from a repository and (optionally) unpack it in local directory.
|
[kubernetes.core.helm_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/stable-5/docs/kubernetes.core.helm_registry_auth_module.rst)|Helm registry authentication module
|
[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/stable-5/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/stable-5/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/stable-5/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
|
||||||
[kubernetes.core.k8s_cluster_info](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/kubernetes.core.k8s_cluster_info_module.rst)|Describe Kubernetes (K8s) cluster, APIs available and their respective versions
|
[kubernetes.core.k8s_cluster_info](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_cluster_info_module.rst)|Describe Kubernetes (K8s) cluster, APIs available and their respective versions
|
||||||
[kubernetes.core.k8s_cp](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/kubernetes.core.k8s_cp_module.rst)|Copy files and directories to and from pod.
|
[kubernetes.core.k8s_cp](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_cp_module.rst)|Copy files and directories to and from pod.
|
||||||
[kubernetes.core.k8s_drain](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/kubernetes.core.k8s_drain_module.rst)|Drain, Cordon, or Uncordon node in k8s cluster
|
[kubernetes.core.k8s_drain](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_drain_module.rst)|Drain, Cordon, or Uncordon node in k8s cluster
|
||||||
[kubernetes.core.k8s_exec](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/kubernetes.core.k8s_exec_module.rst)|Execute command in Pod
|
[kubernetes.core.k8s_exec](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_exec_module.rst)|Execute command in Pod
|
||||||
[kubernetes.core.k8s_info](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/kubernetes.core.k8s_info_module.rst)|Describe Kubernetes (K8s) objects
|
[kubernetes.core.k8s_info](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_info_module.rst)|Describe Kubernetes (K8s) objects
|
||||||
[kubernetes.core.k8s_json_patch](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/kubernetes.core.k8s_json_patch_module.rst)|Apply JSON patch operations to existing objects
|
[kubernetes.core.k8s_json_patch](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_json_patch_module.rst)|Apply JSON patch operations to existing objects
|
||||||
[kubernetes.core.k8s_log](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/kubernetes.core.k8s_log_module.rst)|Fetch logs from Kubernetes resources
|
[kubernetes.core.k8s_log](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_log_module.rst)|Fetch logs from Kubernetes resources
|
||||||
[kubernetes.core.k8s_rollback](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/kubernetes.core.k8s_rollback_module.rst)|Rollback Kubernetes (K8S) Deployments and DaemonSets
|
[kubernetes.core.k8s_rollback](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_rollback_module.rst)|Rollback Kubernetes (K8S) Deployments and DaemonSets
|
||||||
[kubernetes.core.k8s_scale](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/kubernetes.core.k8s_scale_module.rst)|Set a new size for a Deployment, ReplicaSet, Replication Controller, or Job.
|
[kubernetes.core.k8s_scale](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_scale_module.rst)|Set a new size for a Deployment, ReplicaSet, Replication Controller, or Job.
|
||||||
[kubernetes.core.k8s_service](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/kubernetes.core.k8s_service_module.rst)|Manage Services on Kubernetes
|
[kubernetes.core.k8s_service](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_service_module.rst)|Manage Services on Kubernetes
|
||||||
[kubernetes.core.k8s_taint](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/kubernetes.core.k8s_taint_module.rst)|Taint a node in a Kubernetes/OpenShift cluster
|
[kubernetes.core.k8s_taint](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_taint_module.rst)|Taint a node in a Kubernetes/OpenShift cluster
|
||||||
|
[kubernetes.core.kubeconfig](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.kubeconfig_module.rst)|Generate, update, and optionally write Kubernetes kubeconfig files
|
||||||
|
|
||||||
<!--end collection content-->
|
<!--end collection content-->
|
||||||
|
|
||||||
@@ -80,7 +76,7 @@ PEP440 is the schema used to describe the versions of Ansible.
|
|||||||
|
|
||||||
### Helm Version Compatibility
|
### Helm Version Compatibility
|
||||||
|
|
||||||
Helm modules in this collection are compatible with Helm v3.x and are not yet compatible with Helm v4. Individual modules and their parameters may support a more specific range of Helm versions.
|
This collection supports Helm v3.x and newer. Please note that specific modules or certain parameters may have additional version requirements.
|
||||||
|
|
||||||
### Python Support
|
### Python Support
|
||||||
|
|
||||||
@@ -98,23 +94,27 @@ Before using the Kubernetes collection, you need to install it with the Ansible
|
|||||||
|
|
||||||
ansible-galaxy collection install kubernetes.core
|
ansible-galaxy collection install kubernetes.core
|
||||||
|
|
||||||
|
Red Hat customers can install certified content from [Ansible Automation Hub](https://console.redhat.com/ansible/automation-hub). Configure Automation Hub as the primary content source for the Ansible Galaxy CLI by following the [Red Hat configuration guide](https://docs.redhat.com/en/documentation/red_hat_ansible_automation_platform/2.4/html/getting_started_with_automation_hub/configure-hub-primary), then install the collection with `ansible-galaxy collection install kubernetes.core`.
|
||||||
|
|
||||||
You can also include it in a `requirements.yml` file and install it via `ansible-galaxy collection install -r requirements.yml`, using the format:
|
You can also include it in a `requirements.yml` file and install it via `ansible-galaxy collection install -r requirements.yml`, using the format:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
---
|
---
|
||||||
collections:
|
collections:
|
||||||
- name: kubernetes.core
|
- name: kubernetes.core
|
||||||
version: 5.5.0
|
version: 6.6.0
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installing the Kubernetes Python Library
|
### Installing the Kubernetes Python Library
|
||||||
|
|
||||||
Content in this collection requires the [Kubernetes Python client](https://pypi.org/project/kubernetes/) to interact with Kubernetes' APIs. You can install it with:
|
Content in this collection requires the [Kubernetes Python client](https://pypi.org/project/kubernetes/) to interact with Kubernetes' APIs. For installs outside an execution environment, install it with:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip3 install kubernetes
|
pip3 install kubernetes
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Execution environments install this dependency when they are built with `ansible-builder`; you do not need to install it separately with `pip3` in that case.
|
||||||
|
|
||||||
## Use Cases
|
## Use Cases
|
||||||
|
|
||||||
It's preferable to use content in this collection using their Fully Qualified Collection Namespace (FQCN), for example `kubernetes.core.k8s_info`:
|
It's preferable to use content in this collection using their Fully Qualified Collection Namespace (FQCN), for example `kubernetes.core.k8s_info`:
|
||||||
@@ -203,7 +203,7 @@ The ``kubernetes.core`` collection supports Ansible Turbo mode as a tech preview
|
|||||||
To enable Turbo mode for k8s lookup plugin, set the environment variable `ENABLE_TURBO_MODE=1` on the managed node. This is not working when
|
To enable Turbo mode for k8s lookup plugin, set the environment variable `ENABLE_TURBO_MODE=1` on the managed node. This is not working when
|
||||||
defined in the playbook using `environment` keyword as above, you must set it using `export ENABLE_TURBO_MODE=1`.
|
defined in the playbook using `environment` keyword as above, you must set it using `export ENABLE_TURBO_MODE=1`.
|
||||||
|
|
||||||
Please read more about Ansible Turbo mode - [here](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/ansible_turbo_mode.rst).
|
Please read more about Ansible Turbo mode - [here](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/ansible_turbo_mode.rst).
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
@@ -219,6 +219,8 @@ You can run the collection's test suites with the commands:
|
|||||||
make test-integration
|
make test-integration
|
||||||
make test-unit
|
make test-unit
|
||||||
|
|
||||||
|
For instructions on running Helm integration tests locally, see the [integration tests README](https://github.com/ansible-collections/kubernetes.core/blob/main/tests/integration/README.md).
|
||||||
|
|
||||||
### Testing with `molecule`
|
### Testing with `molecule`
|
||||||
|
|
||||||
There are also integration tests in the `molecule` directory which are meant to be run against a local Kubernetes cluster, e.g. using [KinD](https://kind.sigs.k8s.io) or [Minikube](https://minikube.sigs.k8s.io). To set up a local cluster using KinD and run Molecule:
|
There are also integration tests in the `molecule` directory which are meant to be run against a local Kubernetes cluster, e.g. using [KinD](https://kind.sigs.k8s.io) or [Minikube](https://minikube.sigs.k8s.io). To set up a local cluster using KinD and run Molecule:
|
||||||
@@ -230,7 +232,7 @@ There are also integration tests in the `molecule` directory which are meant to
|
|||||||
|
|
||||||
If you want to develop new content for this collection or improve what is already here, clone the Git repository into one of the configured [`COLLECTIONS_PATHS`](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#collections-paths) and work on it there.
|
If you want to develop new content for this collection or improve what is already here, clone the Git repository into one of the configured [`COLLECTIONS_PATHS`](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#collections-paths) and work on it there.
|
||||||
|
|
||||||
See [Contributing to kubernetes.core](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/CONTRIBUTING.md).
|
See [Contributing to kubernetes.core](https://github.com/ansible-collections/kubernetes.core/blob/main/CONTRIBUTING.md).
|
||||||
|
|
||||||
Join the Ansible community:
|
Join the Ansible community:
|
||||||
|
|
||||||
@@ -247,6 +249,8 @@ This project follows the [Ansible Code of Conduct](https://docs.ansible.com/ansi
|
|||||||
|
|
||||||
## Support
|
## Support
|
||||||
|
|
||||||
|
This collection is maintained by Red Hat Ansible Cloud Content.
|
||||||
|
|
||||||
As Red Hat Ansible Certified Content, this collection is entitled to support through the Ansible Automation Platform (AAP) using the **Create issue** button on the top right corner. If a support case cannot be opened with Red Hat and the collection has been obtained either from Galaxy or GitHub, there may be community help available on the [Ansible Forum](https://forum.ansible.com/).
|
As Red Hat Ansible Certified Content, this collection is entitled to support through the Ansible Automation Platform (AAP) using the **Create issue** button on the top right corner. If a support case cannot be opened with Red Hat and the collection has been obtained either from Galaxy or GitHub, there may be community help available on the [Ansible Forum](https://forum.ansible.com/).
|
||||||
|
|
||||||
> **Note:** The `stable-4` branch (all `4.x.y` releases) is no longer supported. No backports or releases are performed on `stable-4`.
|
> **Note:** The `stable-4` branch (all `4.x.y` releases) is no longer supported. No backports or releases are performed on `stable-4`.
|
||||||
@@ -255,7 +259,7 @@ We announce releases and important changes through Ansible's [The Bullhorn newsl
|
|||||||
|
|
||||||
We take part in the global quarterly [Ansible Contributor Summit](https://github.com/ansible/community/wiki/Contributor-Summit). Track The Bullhorn and join when announced.
|
We take part in the global quarterly [Ansible Contributor Summit](https://github.com/ansible/community/wiki/Contributor-Summit). Track The Bullhorn and join when announced.
|
||||||
|
|
||||||
For the latest supported versions, see [Release Notes and Roadmap](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/README.md#release-notes-and-roadmap).
|
For the latest supported versions, see [Release Notes and Roadmap](https://github.com/ansible-collections/kubernetes.core/blob/main/README.md#release-notes-and-roadmap).
|
||||||
|
|
||||||
Report bugs, request features, or ask questions by opening an issue in the [GitHub repository](https://github.com/ansible-collections/kubernetes.core/).
|
Report bugs, request features, or ask questions by opening an issue in the [GitHub repository](https://github.com/ansible-collections/kubernetes.core/).
|
||||||
|
|
||||||
@@ -267,7 +271,7 @@ Releases are automatically built and pushed to Ansible Galaxy for any new tag. B
|
|||||||
1. The `version` in `galaxy.yml`
|
1. The `version` in `galaxy.yml`
|
||||||
2. This README's `requirements.yml` example
|
2. This README's `requirements.yml` example
|
||||||
3. The `VERSION` in `Makefile`
|
3. The `VERSION` in `Makefile`
|
||||||
2. Update the CHANGELOG:
|
2. Update the [CHANGELOG](CHANGELOG.rst):
|
||||||
1. Make sure you have [`antsibull-changelog`](https://pypi.org/project/antsibull-changelog/) installed.
|
1. Make sure you have [`antsibull-changelog`](https://pypi.org/project/antsibull-changelog/) installed.
|
||||||
2. Make sure there are fragments for all known changes in `changelogs/fragments`.
|
2. Make sure there are fragments for all known changes in `changelogs/fragments`.
|
||||||
3. Run `antsibull-changelog release`.
|
3. Run `antsibull-changelog release`.
|
||||||
@@ -282,9 +286,9 @@ The process for [uploading a supported release to Automation Hub](https://docs.r
|
|||||||
|
|
||||||
* [Using Ansible collections](https://docs.ansible.com/ansible/devel/user_guide/collections_using.html)
|
* [Using Ansible collections](https://docs.ansible.com/ansible/devel/user_guide/collections_using.html)
|
||||||
* [Ansible communication guide](https://docs.ansible.com/ansible/devel/community/communication.html)
|
* [Ansible communication guide](https://docs.ansible.com/ansible/devel/community/communication.html)
|
||||||
* [Continuous integration (CI) overview](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/CI.md)
|
* [Continuous integration (CI) overview](https://github.com/ansible-collections/kubernetes.core/blob/main/CI.md)
|
||||||
* [SonarCloud integration](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/SONARCLOUD.md)
|
* [SonarCloud integration](https://github.com/ansible-collections/kubernetes.core/blob/main/SONARCLOUD.md)
|
||||||
* [Ansible Turbo mode (tech preview)](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/docs/ansible_turbo_mode.rst)
|
* [Ansible Turbo mode (tech preview)](https://github.com/ansible-collections/kubernetes.core/blob/main/docs/ansible_turbo_mode.rst)
|
||||||
|
|
||||||
### Code of conduct
|
### Code of conduct
|
||||||
|
|
||||||
@@ -296,4 +300,4 @@ If you encounter abusive behavior, please refer to the [policy violations](https
|
|||||||
|
|
||||||
GNU General Public License v3.0 or later
|
GNU General Public License v3.0 or later
|
||||||
|
|
||||||
See [LICENSE](https://github.com/ansible-collections/kubernetes.core/blob/stable-5/LICENSE) to see the full text.
|
See [LICENSE](https://github.com/ansible-collections/kubernetes.core/blob/main/LICENSE) to see the full text.
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ Workflow files:
|
|||||||
|
|
||||||
Scanner configuration lives in [sonar-project.properties](sonar-project.properties).
|
Scanner configuration lives in [sonar-project.properties](sonar-project.properties).
|
||||||
|
|
||||||
The **coverage** job (in **`all_green`**) uses **`ansible-test`** (`units --coverage`, then **`coverage combine`** / **`coverage xml`**) with **ansible-core `stable-2.18`** on **`stable-5`**, then writes **`coverage.xml`** with workspace paths normalized for Sonar. **`pytest-cov`** is listed in **`tests/unit/requirements.txt`** for parity and any direct pytest runs; **`ansible-test`** still owns the coverage data used in CI.
|
The **coverage** job (in **`all_green`**) uses **`ansible-test`** (`units --coverage`, then **`coverage combine`** / **`coverage xml`**), then writes **`coverage.xml`** with workspace paths normalized for Sonar. **`pytest-cov`** is listed in **`tests/unit/requirements.txt`** for parity and any direct pytest runs; **`ansible-test`** still owns the coverage data used in CI.
|
||||||
|
|
||||||
**`sonarcloud.yml`** declares a required secret **`ANSIBLE_COLLECTIONS_ORG_SONAR_TOKEN_CICD_BOT`** and **`permissions: contents: read`**, **`pull-requests: read`**.
|
**`sonarcloud.yml`** declares a required secret **`ANSIBLE_COLLECTIONS_ORG_SONAR_TOKEN_CICD_BOT`** and **`permissions: contents: read`**, **`pull-requests: read`**.
|
||||||
|
|
||||||
|
|||||||
+291
-5
@@ -1027,14 +1027,13 @@ releases:
|
|||||||
changes:
|
changes:
|
||||||
bugfixes:
|
bugfixes:
|
||||||
- module_utils/k8s/service - fix issue when trying to delete resource using
|
- 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).
|
``delete_options`` and ``check_mode=true`` (https://github.com/ansible-collections/kubernetes.core/issues/892).
|
||||||
minor_changes:
|
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
|
- action/k8s_info - update templating mechanism with changes from ``ansible-core
|
||||||
2.19`` (https://github.com/ansible-collections/kubernetes.core/pull/888).
|
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 ``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``
|
- helm - add support for ``insecure_skip_tls_verify`` option to helm and helm_repository(https://github.com/ansible-collections/kubernetes.core/issues/694).
|
||||||
(https://github.com/ansible-collections/kubernetes.core/issues/694).
|
|
||||||
- kubernetes.core - Bump version of ``ansible-lint`` to ``25.1.2`` (https://github.com/ansible-collections/kubernetes.core/pull/919).
|
|
||||||
release_summary: This release includes minor changes, bug fixes and also bumps
|
release_summary: This release includes minor changes, bug fixes and also bumps
|
||||||
``ansible-lint`` version to ``25.1.2``.
|
``ansible-lint`` version to ``25.1.2``.
|
||||||
fragments:
|
fragments:
|
||||||
@@ -1063,7 +1062,7 @@ releases:
|
|||||||
changes:
|
changes:
|
||||||
bugfixes:
|
bugfixes:
|
||||||
- Remove ``ansible.module_utils.six`` imports to avoid warnings (https://github.com/ansible-collections/kubernetes.core/pull/998).
|
- Remove ``ansible.module_utils.six`` imports to avoid warnings (https://github.com/ansible-collections/kubernetes.core/pull/998).
|
||||||
- Update the `k8s_cp` module to also work for init containers (https://github.com/ansible-collections/kubernetes.core/pull/971).
|
- Update the ``k8s_cp`` module to also work for init containers (https://github.com/ansible-collections/kubernetes.core/pull/971).
|
||||||
- module_utils/k8s/service - hide fields first before creating diffs (https://github.com/ansible-collections/kubernetes.core/pull/915).
|
- module_utils/k8s/service - hide fields first before creating diffs (https://github.com/ansible-collections/kubernetes.core/pull/915).
|
||||||
release_summary: This release includes bugfixes for k8s service field handling,
|
release_summary: This release includes bugfixes for k8s service field handling,
|
||||||
k8s_cp init containers support, and removes deprecated ansible.module_utils.six
|
k8s_cp init containers support, and removes deprecated ansible.module_utils.six
|
||||||
@@ -1200,3 +1199,290 @@ releases:
|
|||||||
- deprecate-enable-turbo-mode.yml
|
- deprecate-enable-turbo-mode.yml
|
||||||
- fix-ansible-lint-warnings.yaml
|
- fix-ansible-lint-warnings.yaml
|
||||||
release_date: '2026-09-15'
|
release_date: '2026-09-15'
|
||||||
|
6.0.0:
|
||||||
|
changes:
|
||||||
|
breaking_changes:
|
||||||
|
- Remove deprecated ``k8s`` invetory plugin (https://github.com/ansible-collections/kubernetes.core/pull/867).
|
||||||
|
- Remove support for ``ansible-core<2.16`` (https://github.com/ansible-collections/kubernetes.core/pull/867).
|
||||||
|
fragments:
|
||||||
|
- 20250121-breaking-changes-6.0.0.yml
|
||||||
|
release_date: '2025-05-19'
|
||||||
|
6.1.0:
|
||||||
|
changes:
|
||||||
|
bugfixes:
|
||||||
|
- module_utils/k8s/service - hide fields first before creating diffs (https://github.com/ansible-collections/kubernetes.core/pull/915).
|
||||||
|
minor_changes:
|
||||||
|
- Module ``helm_registry_auth`` does not support idempotency with `helm >= 3.18.0`
|
||||||
|
(https://github.com/ansible-collections/kubernetes.core/pull/946).
|
||||||
|
- Module k8s_json_patch - Add support for ``hidden_fields`` (https://github.com/ansible-collections/kubernetes.core/pull/964).
|
||||||
|
- helm - Parameter plain_http added for working with insecure OCI registries
|
||||||
|
(https://github.com/ansible-collections/kubernetes.core/pull/934).
|
||||||
|
- helm - Parameter take_ownership added (https://github.com/ansible-collections/kubernetes.core/pull/957).
|
||||||
|
- helm_pull - Parameter plain_http added for working with insecure OCI registries
|
||||||
|
(https://github.com/ansible-collections/kubernetes.core/pull/934).
|
||||||
|
- helm_template - Parameter plain_http added for working with insecure OCI registries
|
||||||
|
(https://github.com/ansible-collections/kubernetes.core/pull/934).
|
||||||
|
release_summary: "This release adds ``plain_http`` and ``take_ownership`` parameters
|
||||||
|
for helm modules, support for ``hidden_fields`` in ``k8s_json_patch``, documented
|
||||||
|
lack of idempotency support in ``helm_registry_auth`` with ``helm \u2265 3.18.0``,
|
||||||
|
and improved ``k8s_rollback`` test coverage."
|
||||||
|
fragments:
|
||||||
|
- 20250411-kubeconfig-no_log-revert.yaml
|
||||||
|
- 20250428-k8s-service-hide-fields-first.yaml
|
||||||
|
- 20250522-add-plain-http-for-oci-registries.yaml
|
||||||
|
- 20250605-fix-helm_registry_auth-integration_test.yaml
|
||||||
|
- 20250704-k8s-rollback-integration-test-coverage.yaml
|
||||||
|
- 20250720-k8s-patch-add-hidden-fields.yaml
|
||||||
|
- 20250911-add-support-helm-take-ownership.yaml
|
||||||
|
- release_summary.yml
|
||||||
|
release_date: '2025-08-12'
|
||||||
|
6.2.0:
|
||||||
|
changes:
|
||||||
|
bugfixes:
|
||||||
|
- Remove ``ansible.module_utils.six`` imports to avoid warnings (https://github.com/ansible-collections/kubernetes.core/pull/998).
|
||||||
|
- Update the ``k8s_cp`` module to also work for init containers (https://github.com/ansible-collections/kubernetes.core/pull/971).
|
||||||
|
minor_changes:
|
||||||
|
- Add support of skip-schema-validation in ``helm`` module (https://github.com/ansible-collections/kubernetes.core/pull/995)
|
||||||
|
- kustomize - Add support of local environ (https://github.com/ansible-collections/kubernetes.core/pull/786).
|
||||||
|
release_summary: This release adds minor changes and bugfixes, including support
|
||||||
|
of skip-schema-validation in ``helm`` module and removing deprecated ``ansible.module_utils.six``
|
||||||
|
imports.
|
||||||
|
fragments:
|
||||||
|
- 20241030-support-of-evrion-for-kustomize-lookup-plugin.yaml
|
||||||
|
- 20250731-fix-k8s_cp-initcontainers.yaml
|
||||||
|
- 20250916-skip-schema-validation.yaml
|
||||||
|
- 20250922-remove-ansible-six-imports.yaml
|
||||||
|
- 6_2_0.yml
|
||||||
|
release_date: '2025-10-07'
|
||||||
|
6.3.0:
|
||||||
|
changes:
|
||||||
|
bugfixes:
|
||||||
|
- Add idempotency for ``helm_pull`` module (https://github.com/ansible-collections/kubernetes.core/pull/1055).
|
||||||
|
- Fixed a bug where setting ``K8S_AUTH_VERIFY_SSL=true`` (or any string value)
|
||||||
|
caused the value to be treated as a separate ``kubectl`` command argument.
|
||||||
|
(https://github.com/ansible-collections/kubernetes.core/pull/1049).
|
||||||
|
- Limit supported versions of Helm to <4.0.0 (https://github.com/ansible-collections/kubernetes.core/pull/1039).
|
||||||
|
- Replace passing ``warnings`` to ``exit_json`` with ``AnsibleModule.warn``
|
||||||
|
in the ``k8s_drain``, ``k8s_rollback.py`` and ``k8s_scale.py`` modules as
|
||||||
|
it deprecated in ``ansible-core>=2.19.0`` and will be removed in ``ansible-core>=2.23.0``
|
||||||
|
(https://github.com/ansible-collections/kubernetes.core/pull/1033).
|
||||||
|
- k8s - Fix return block from the module documentation (https://github.com/ansible-collections/kubernetes.core/pull/1056).
|
||||||
|
- meta - Add ``k8s_cluster_info``, ``k8s_json_patch`` and ``k8s_rollback`` to
|
||||||
|
k8s action group (https://github.com/ansible-collections/kubernetes.core/pull/992).
|
||||||
|
deprecated_features:
|
||||||
|
- helm - the ``status.values`` return value has been deprecated and will be
|
||||||
|
removed in a release after 2027-01-08. Use ``status.release_values`` instead
|
||||||
|
(https://github.com/ansible-collections/kubernetes.core/pull/1056).
|
||||||
|
- helm_info - the ``status.values`` return value has been deprecated and will
|
||||||
|
be removed in a release after 2027-01-08. Use ``status.release_values`` instead
|
||||||
|
(https://github.com/ansible-collections/kubernetes.core/pull/1056).
|
||||||
|
minor_changes:
|
||||||
|
- Remove deprecated import from ``ansible.module_utils._text`` (https://github.com/ansible-collections/kubernetes.core/pull/1053).
|
||||||
|
- helm - add ``release_values`` key to ``status`` return value that can be accessed
|
||||||
|
using Jinja2 dot notation (https://github.com/ansible-collections/kubernetes.core/pull/1056).
|
||||||
|
- helm_info - add ``release_values`` key to ``status`` return value that can
|
||||||
|
be accessed using Jinja2 dot notation (https://github.com/ansible-collections/kubernetes.core/pull/1056).
|
||||||
|
release_summary: This release includes bugfixes such as implementing idempotency
|
||||||
|
for the ``helm_pull`` module as well as a security update for selectively
|
||||||
|
redacting sensitive information from kubeconfig.
|
||||||
|
security_fixes:
|
||||||
|
- Selectively redact sensitive info from kubeconfig instead of applying blanket
|
||||||
|
``no_log=True`` (https://github.com/ansible-collections/kubernetes.core/pull/1014).
|
||||||
|
fragments:
|
||||||
|
- 1033-warnings-deprecations.yaml
|
||||||
|
- 20251002-fix-k8s-actiongroup.yaml
|
||||||
|
- 20251007-selective-kubeconfig-redaction.yaml
|
||||||
|
- 20251115-limit-versions-of-helm.yaml
|
||||||
|
- 20251220-fix-K8S_AUTH_VERIFY_SSL-in-kubectl-connecton-plugion.yaml
|
||||||
|
- 20251228-1053-remove-deprecated-import.yaml
|
||||||
|
- 20260107-add-idempodency-for-helm-pull.yaml
|
||||||
|
- 20260108-fix-sanity-failures.yml
|
||||||
|
- 6-3-0.yaml
|
||||||
|
release_date: '2026-02-03'
|
||||||
|
6.4.0:
|
||||||
|
changes:
|
||||||
|
bugfixes:
|
||||||
|
- Helm - Allow taking ownership of existing Kubernetes resources on the first
|
||||||
|
installation of a Helm release. Previously, the ``take_ownership`` parameter
|
||||||
|
was always disabled during the initial install, preventing resource adoption
|
||||||
|
(https://github.com/ansible-collections/kubernetes.core/pull/1034).
|
||||||
|
minor_changes:
|
||||||
|
- helm_info - Ensure compatibility with Helm v4 (https://github.com/ansible-collections/kubernetes.core/issues/1038).
|
||||||
|
- helm_plugin - Ensure compatibility with Helm v4 (https://github.com/ansible-collections/kubernetes.core/issues/1038).
|
||||||
|
- helm_plugin_info - Ensure compatibility with Helm v4 (https://github.com/ansible-collections/kubernetes.core/issues/1038).
|
||||||
|
- helm_pull - Ensure compatibility with Helm v4 (https://github.com/ansible-collections/kubernetes.core/issues/1038).
|
||||||
|
- helm_registry_auth - Ensure compatibility with Helm v4 (https://github.com/ansible-collections/kubernetes.core/issues/1038).
|
||||||
|
- helm_registry_auth - add new option plain_http to allow insecure http connection
|
||||||
|
when running ``helm registry login`` (https://github.com/ansible-collections/kubernetes.core/pull/1090).
|
||||||
|
- helm_repository - Ensure compatibility with Helm v4 (https://github.com/ansible-collections/kubernetes.core/issues/1038).
|
||||||
|
- k8s_drain - Add support for ``check_mode`` (https://github.com/ansible-collections/kubernetes.core/pull/1086).
|
||||||
|
- k8s_drain - Convert module warnings into informational displays when users
|
||||||
|
explicitly request the deletion of unmanaged pods, pods with local storage,
|
||||||
|
or those managed by a ``DaemonSet`` (https://github.com/ansible-collections/kubernetes.core/issues/1037).
|
||||||
|
release_summary: This release adds Helm v4 compatibility across the Helm modules
|
||||||
|
and improves ``k8s_drain`` with check mode. When you explicitly allow evicting
|
||||||
|
unmanaged pods, pods with local storage, or pods managed by a ``DaemonSet``,
|
||||||
|
those cases are reported as informational output instead of module warnings.
|
||||||
|
fragments:
|
||||||
|
- 20251224-take-ownership-helm-initialization.yaml
|
||||||
|
- 20260203-k8s_drain-warning-fixes.yaml
|
||||||
|
- 20260213-support-helm-v4-for-helm-plugin-modules.yaml
|
||||||
|
- release-6-4-0.yml
|
||||||
|
release_date: '2026-04-22'
|
||||||
|
6.5.0:
|
||||||
|
changes:
|
||||||
|
bugfixes:
|
||||||
|
- ee - added ``meta/execution-environment.yml`` to decouple ansible-builder
|
||||||
|
EE builds from the ``openshift-clients`` system dependency declared in ``bindep.txt``,
|
||||||
|
which is not available in standard UBI repositories and caused builds to fail
|
||||||
|
with ``No package matches 'openshift-clients'`` (https://github.com/ansible-collections/kubernetes.core/issues/1141).
|
||||||
|
- helm - use ``--server-side=false --force-replace`` instead of the deprecated/removed
|
||||||
|
``--force`` flag when ``force=true`` is used with Helm v4, preserving the
|
||||||
|
Helm v3 client-side replacement behaviour and avoiding the server-side apply
|
||||||
|
conflict (https://github.com/ansible-collections/kubernetes.core/pull/1164).
|
||||||
|
- helm - use the ``--rollback-on-failure`` flag instead of the deprecated/removed
|
||||||
|
``--atomic`` flag when ``atomic=true`` is used with Helm v4 (https://github.com/ansible-collections/kubernetes.core/pull/1144).
|
||||||
|
- helm_repository - correct handling of repository URLs with trailing slashes
|
||||||
|
(https://github.com/ansible-collections/kubernetes.core/pull/1121).
|
||||||
|
- k8s_drain - Fix logic for handling pods with local storage to correctly check
|
||||||
|
for empty_dir volumes in replicated pods and pods managed by DaemonSets (https://github.com/ansible-collections/kubernetes.core/pull/1095).
|
||||||
|
minor_changes:
|
||||||
|
- helm - add the ``server_side`` and ``force_conflicts`` options to control
|
||||||
|
Helm v4 server-side apply when installing or upgrading a release (https://github.com/ansible-collections/kubernetes.core/pull/1164).
|
||||||
|
- helm_plugin - add ``--keyring`` argument to allow changing the keyring default
|
||||||
|
location. The option is only accepted with ``state=present`` (the ``helm plugin
|
||||||
|
install`` subcommand), as that is the only implemented subcommand that supports
|
||||||
|
``--keyring`` (https://github.com/ansible-collections/kubernetes.core/pull/1150).
|
||||||
|
- helm_registry_auth - document that, as of Helm 4.2.1, registry success messages
|
||||||
|
such as ``Login Succeeded`` are printed to stdout instead of stderr (https://github.com/ansible-collections/kubernetes.core/pull/1147).
|
||||||
|
- kubeconfig - add ``remove`` value to the ``behavior`` option, allowing entries
|
||||||
|
to be deleted from the kubeconfig file by name (https://github.com/ansible-collections/kubernetes.core/pull/1123).
|
||||||
|
release_summary: This release implements minor changes and bug fixes such as
|
||||||
|
a new ``remove`` value to the ``behavior`` option of the ``kubeconfig`` module,
|
||||||
|
allowing entries to be deleted from the kubeconfig file by name, as well as
|
||||||
|
Helm v4 compatibility across the Helm modules.
|
||||||
|
fragments:
|
||||||
|
- 1123-kubeconfig-remove-behavior.yml
|
||||||
|
- 1173-security-check-workflow.yml
|
||||||
|
- 20260306-k8s_drain-delete-logic-fixes-for-daemonsets.yaml
|
||||||
|
- 20260506-improve_idempotency_for_helm_repository.yaml
|
||||||
|
- 20260611-helm-atomic-helm-v4.yml
|
||||||
|
- 20260612-helm-registry-output-stream.yml
|
||||||
|
- 20260620-add-plugin-keyring-option.yaml
|
||||||
|
- 20260629-helm-force-helm-v4.yml
|
||||||
|
- 6-5-0.yml
|
||||||
|
- fix-openshift-clients-ee-dependency.yaml
|
||||||
|
modules:
|
||||||
|
- description: Generate, update, and optionally write Kubernetes kubeconfig files
|
||||||
|
name: kubeconfig
|
||||||
|
namespace: ''
|
||||||
|
release_date: '2026-07-08'
|
||||||
|
6.6.0:
|
||||||
|
changes:
|
||||||
|
bugfixes:
|
||||||
|
- Ansible Turbo mode - ignore ``ENABLE_TURBO_MODE`` on ansible-core 2.19.0 and
|
||||||
|
later, where the ``cloud.common`` collection is not supported, and fall back
|
||||||
|
to the standard ``AnsibleModule`` instead of failing with ``byte indices must
|
||||||
|
be integers or slices, not str`` (https://github.com/ansible-collections/kubernetes.core/pull/1242).
|
||||||
|
- helm - do not pass the upgrade-only ``--reuse-values`` and ``--reset-then-reuse-values``
|
||||||
|
flags to ``helm install``, which rejected them with ``unknown flag`` whenever
|
||||||
|
``reuse_values`` or ``reset_then_reuse_values`` was combined with ``replace``
|
||||||
|
(https://github.com/ansible-collections/kubernetes.core/pull/1230).
|
||||||
|
- helm - fix the ``reuse_values`` example, which set only ``reuse_values=true``.
|
||||||
|
``reset_values`` defaults to ``true`` and helm ignores ``--reuse-values``
|
||||||
|
whenever ``--reset-values`` is passed, so following the example reset the
|
||||||
|
release values instead of reusing them (https://github.com/ansible-collections/kubernetes.core/pull/1230).
|
||||||
|
- helm - skip Helm's OCI registry progress messages when parsing the output
|
||||||
|
of ``helm show chart``. As of Helm 4.2.1 these are printed to stdout instead
|
||||||
|
of stderr (https://github.com/helm/helm/pull/32056), which made installing
|
||||||
|
a chart from an OCI registry fail with a YAML scanner error when the chart
|
||||||
|
version contained a ``+`` (https://github.com/ansible-collections/kubernetes.core/pull/1223).
|
||||||
|
- helm_repository - normalize both sides of the repository URL comparison, so
|
||||||
|
that a repository already registered with a trailing slash is recognized as
|
||||||
|
matching instead of failing with ``Repository already have a repository named
|
||||||
|
<name>`` (https://github.com/ansible-collections/kubernetes.core/pull/1236).
|
||||||
|
- helm_template - strip Helm's OCI registry progress messages from the returned
|
||||||
|
``stdout``, which is documented to contain only the rendered templates (https://github.com/ansible-collections/kubernetes.core/pull/1223).
|
||||||
|
- k8s lookup - ignore ``ENABLE_TURBO_MODE`` on ansible-core 2.19.0 and later,
|
||||||
|
where the ``cloud.common`` collection is not supported. Fall back to the standard
|
||||||
|
``LookupBase`` instead of failing with a traceback (https://github.com/ansible-collections/kubernetes.core/pull/1253).
|
||||||
|
- k8s_cp - Fix silent truncation when copying to a pod. The module closed the
|
||||||
|
exec connection immediately after writing the last chunk of the tar archive,
|
||||||
|
which killed the remote ``tar`` before it had finished extracting, and never
|
||||||
|
checked the process exit status, so a partial copy was reported as a success.
|
||||||
|
The archive is now bounded with ``head -c`` so ``tar`` gets a clean EOF and
|
||||||
|
exits on its own, and the module waits for that exit and fails on a non-zero
|
||||||
|
status (https://github.com/ansible-collections/kubernetes.core/pull/1217).
|
||||||
|
- k8s_info - Handle empty template output gracefully by returning ``changed=false``
|
||||||
|
instead of failing when Jinja2 template renders to an empty string (https://github.com/ansible-collections/kubernetes.core/issues/1042).
|
||||||
|
deprecated_features:
|
||||||
|
- Ansible Turbo mode (``ENABLE_TURBO_MODE``) has been deprecated and will be
|
||||||
|
removed in release 8.0.0, as it depends on the ``cloud.common`` collection,
|
||||||
|
which is being retired (https://github.com/ansible-collections/kubernetes.core/pull/1242).
|
||||||
|
- helm - the ``status.values`` return value has been deprecated and will be
|
||||||
|
removed in version 8.0.0. Use ``status.release_values`` instead (https://github.com/ansible-collections/kubernetes.core/issues/1239).
|
||||||
|
- helm - the ``wait_timeout`` parameter has been deprecated and will be removed
|
||||||
|
in version 7.0.0. Use ``timeout`` instead (https://github.com/ansible-collections/kubernetes.core/issues/1239).
|
||||||
|
- helm_info - the ``status.values`` return value has been deprecated and will
|
||||||
|
be removed in version 8.0.0. Use ``status.release_values`` instead (https://github.com/ansible-collections/kubernetes.core/issues/1239).
|
||||||
|
- k8s_exec - the ``return_code`` return value has been deprecated and will be
|
||||||
|
removed in version 7.0.0. Use ``rc`` instead (https://github.com/ansible-collections/kubernetes.core/issues/1239).
|
||||||
|
- k8s_service - the ``merge_type=json`` option has been deprecated and will
|
||||||
|
be removed in version 7.0.0. Use ``kubernetes.core.k8s_json_patch`` module
|
||||||
|
instead (https://github.com/ansible-collections/kubernetes.core/issues/1239).
|
||||||
|
minor_changes:
|
||||||
|
- Remove the remaining ``ansible.module_utils.six`` import to avoid deprecation
|
||||||
|
warnings, replacing it with the Python standard library equivalent (https://github.com/ansible-collections/kubernetes.core/pull/1197).
|
||||||
|
- helm - Add ``wait_for_jobs`` option to wait for all Jobs to complete before
|
||||||
|
marking a Helm release as successful. Requires Helm >= 3.5.0 (https://github.com/ansible-collections/kubernetes.core/pull/1140).
|
||||||
|
- helm - add the ``cleanup_on_fail`` option, mapping to the ``--cleanup-on-fail``
|
||||||
|
flag, to allow deletion of new resources created during a failed upgrade.
|
||||||
|
It complements ``atomic`` and can be combined with it, but cannot be used
|
||||||
|
with ``replace``, since that deploys through ``helm install`` which does not
|
||||||
|
accept the flag (https://github.com/ansible-collections/kubernetes.core/pull/1206).
|
||||||
|
- helm - warn when ``reuse_values`` or ``reset_then_reuse_values`` is requested
|
||||||
|
in a combination helm ignores, which happens by default because ``reset_values``
|
||||||
|
defaults to ``true``, and whenever either is combined with ``replace``. The
|
||||||
|
option descriptions and the examples now state that ``reset_values`` has to
|
||||||
|
be set to ``false`` for either option to take effect (https://github.com/ansible-collections/kubernetes.core/pull/1230).
|
||||||
|
- k8s lookup - warn when ``ENABLE_TURBO_MODE`` is set but the ``cloud.common``
|
||||||
|
collection is not installed, instead of silently falling back to the standard
|
||||||
|
lookup base (https://github.com/ansible-collections/kubernetes.core/pull/1242).
|
||||||
|
- k8s_cp - Add the ``copy_timeout`` option (default 300 seconds) bounding how
|
||||||
|
long the module will spend streaming an archive to a pod and waiting for the
|
||||||
|
remote ``tar`` to finish, so that a stalled copy fails instead of hanging
|
||||||
|
indefinitely (https://github.com/ansible-collections/kubernetes.core/pull/1217).
|
||||||
|
- k8s_cp - Stream the tar archive to the pod chunk by chunk instead of building
|
||||||
|
the whole archive in memory first, which cuts peak memory use when copying
|
||||||
|
large files (https://github.com/ansible-collections/kubernetes.core/pull/1217).
|
||||||
|
- k8s_cp - When copying to a pod, the module now also uses ``/bin/sh`` and ``head``
|
||||||
|
in the container, when present, to confirm the copy completed. Containers
|
||||||
|
without them keep the previous behaviour and get a warning that completion
|
||||||
|
could not be verified (https://github.com/ansible-collections/kubernetes.core/pull/1217).
|
||||||
|
- k8s_info - Support for metadata-only fetches in k8s_info module (https://github.com/ansible-collections/kubernetes.core/pull/1030)
|
||||||
|
- meta - Add ``helm_plugin`` and ``helm_plugin_info`` to the ``helm`` action
|
||||||
|
group, and ``k8s_taint`` to the ``k8s`` action group, so that ``module_defaults``
|
||||||
|
set on those groups applies to them (https://github.com/ansible-collections/kubernetes.core/pull/1216).
|
||||||
|
- use `collections.abc` instead of deprecated `ansible.module_utils.common._collections_compat`
|
||||||
|
(https://github.com/ansible-collections/kubernetes.core/pull/1057).
|
||||||
|
- waiter - Add ``job_complete`` predicate to support waiting for Job resources
|
||||||
|
to reach ``Complete`` or ``Failed`` condition (https://github.com/ansible-collections/kubernetes.core/issues/1201).
|
||||||
|
fragments:
|
||||||
|
- 1253-k8s-lookup-turbo-version-check.yml
|
||||||
|
- 20250108-fix-empty-template-output.yaml
|
||||||
|
- 20251027-metadata-only-fetches.yaml
|
||||||
|
- 20260109-fix-deprecated-calls.yaml
|
||||||
|
- 20260723-remove-module-utils-six.yaml
|
||||||
|
- 20260805-add-job-wait-condition.yaml
|
||||||
|
- 20260807-helm-cleanup-on-fail.yaml
|
||||||
|
- 20260807-helm-wait-for-jobs.yaml
|
||||||
|
- 20260812-action-groups.yaml
|
||||||
|
- 20260813-k8s-cp-truncation.yaml
|
||||||
|
- 20260817-helm-oci-registry-progress-on-stdout.yml
|
||||||
|
- 20260826-helm-value-reuse-options.yaml
|
||||||
|
- 20260908-helm-repository-trailing-slash.yaml
|
||||||
|
- 20260911-deprecate-status-values.yaml
|
||||||
|
- 20260911-update-deprecation-notices.yaml
|
||||||
|
- deprecate-enable-turbo-mode.yml
|
||||||
|
- fix-ansible-lint-warnings.yaml
|
||||||
|
release_date: '2026-09-16'
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
bugfixes:
|
||||||
|
- helm - Remove `--plain-http` option from `helm diff upgrade`, as it is not supported by the helm-diff plugin (https://github.com/ansible-collections/kubernetes.core/pull/1232).
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
bugfixes:
|
||||||
|
- k8s, k8s_service - emit warnings through ``AnsibleModule.warn`` instead of putting them in the result dict that is unpacked into ``exit_json``/``fail_json``. Passing ``warnings`` that way is deprecated since ansible-core 2.19 and will be removed in 2.23, so every run that produced a warning (for example the "No meaningful diff was generated" hint, warnings returned by the Kubernetes API, or ``validate`` findings) also emitted a deprecation warning (https://github.com/ansible-collections/kubernetes.core/pull/1267).
|
||||||
|
- k8s - warnings raised while processing a multi-document manifest are now shown to the user. They were previously nested under ``result.results[*].warnings``, where ansible-core never picked them up, so they were silently dropped whenever more than one resource was processed (https://github.com/ansible-collections/kubernetes.core/pull/1267).
|
||||||
@@ -34,8 +34,9 @@ Synopsis
|
|||||||
Requirements
|
Requirements
|
||||||
------------
|
------------
|
||||||
|
|
||||||
The following requirement is needed on the host that executes this module.
|
The following requirements are needed on the host that executes this module.
|
||||||
|
|
||||||
|
- ``ansible-core`` version lower than 2.19.
|
||||||
- The ``cloud.common`` collection (https://github.com/ansible-collections/cloud.common)
|
- The ``cloud.common`` collection (https://github.com/ansible-collections/cloud.common)
|
||||||
|
|
||||||
You will also need to set the environment variable ``ENABLE_TURBO_MODE=1`` on the managed host. This can be done in the same ways you would usually do so, for example::
|
You will also need to set the environment variable ``ENABLE_TURBO_MODE=1`` on the managed host. This can be done in the same ways you would usually do so, for example::
|
||||||
@@ -158,4 +159,4 @@ You may want to manually start the server. This can be done with the following c
|
|||||||
|
|
||||||
PYTHONPATH=$HOME/.ansible/collections python -m ansible_collections.cloud.common.plugins.module_utils.turbo.server --socket-path $HOME/.ansible/tmp/turbo_mode.kubernetes.core.socket
|
PYTHONPATH=$HOME/.ansible/collections python -m ansible_collections.cloud.common.plugins.module_utils.turbo.server --socket-path $HOME/.ansible/tmp/turbo_mode.kubernetes.core.socket
|
||||||
|
|
||||||
You can use the ``--help`` argument to get a list of the optional parameters.
|
You can use the ``--help`` argument to get a list of the optional parameters.
|
||||||
@@ -17,7 +17,7 @@ Requirements
|
|||||||
|
|
||||||
To use the modules, you'll need the following:
|
To use the modules, you'll need the following:
|
||||||
|
|
||||||
- Ansible 2.9.17 or latest installed
|
- Ansible 2.16.0 or latest installed
|
||||||
- `Kubernetes Python client <https://pypi.org/project/kubernetes/>`_ installed on the host that will execute the modules.
|
- `Kubernetes Python client <https://pypi.org/project/kubernetes/>`_ installed on the host that will execute the modules.
|
||||||
|
|
||||||
|
|
||||||
@@ -42,6 +42,92 @@ Basic authentication is also supported using the ``username`` and ``password`` o
|
|||||||
|
|
||||||
To disable SSL certificate verification, set ``verify_ssl`` to false.
|
To disable SSL certificate verification, set ``verify_ssl`` to false.
|
||||||
|
|
||||||
|
Sharing options across tasks with action groups
|
||||||
|
===============================================
|
||||||
|
|
||||||
|
Repeating the same authentication options on every task gets verbose quickly. The collection
|
||||||
|
defines two `action groups <https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_module_defaults.html#module-defaults-groups>`_
|
||||||
|
so you can set them once with ``module_defaults``:
|
||||||
|
|
||||||
|
``kubernetes.core.k8s``
|
||||||
|
Modules that talk to the Kubernetes API and accept the standard authentication options
|
||||||
|
(``kubeconfig``, ``context``, ``host``, ``api_key``, ``validate_certs``, and so on):
|
||||||
|
``k8s``, ``k8s_cluster_info``, ``k8s_cp``, ``k8s_drain``, ``k8s_exec``, ``k8s_info``,
|
||||||
|
``k8s_json_patch``, ``k8s_log``, ``k8s_rollback``, ``k8s_scale``, ``k8s_service``, and
|
||||||
|
``k8s_taint``.
|
||||||
|
|
||||||
|
``kubernetes.core.helm``
|
||||||
|
Modules that shell out to the ``helm`` binary and accept its shared authentication
|
||||||
|
options (``binary_path``, ``kubeconfig``, ``context``, ``host``, ``api_key``,
|
||||||
|
``ca_cert``, ``validate_certs``): ``helm``, ``helm_info``, ``helm_plugin``,
|
||||||
|
``helm_plugin_info``, and ``helm_repository``.
|
||||||
|
|
||||||
|
Prefix the group name with ``group/`` to use it:
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
- hosts: localhost
|
||||||
|
module_defaults:
|
||||||
|
group/kubernetes.core.k8s:
|
||||||
|
kubeconfig: /path/to/kubeconfig
|
||||||
|
context: staging
|
||||||
|
group/kubernetes.core.helm:
|
||||||
|
binary_path: /path/to/helm
|
||||||
|
kubeconfig: /path/to/kubeconfig
|
||||||
|
context: staging
|
||||||
|
tasks:
|
||||||
|
- name: Create a namespace
|
||||||
|
kubernetes.core.k8s:
|
||||||
|
definition:
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: monitoring
|
||||||
|
|
||||||
|
- name: Read it back
|
||||||
|
kubernetes.core.k8s_info:
|
||||||
|
kind: Namespace
|
||||||
|
name: monitoring
|
||||||
|
|
||||||
|
- name: Add the prometheus chart repository
|
||||||
|
kubernetes.core.helm_repository:
|
||||||
|
name: prometheus-community
|
||||||
|
repo_url: https://prometheus-community.github.io/helm-charts
|
||||||
|
|
||||||
|
- name: Deploy the kube-prometheus-stack chart
|
||||||
|
kubernetes.core.helm:
|
||||||
|
name: kube-prometheus-stack
|
||||||
|
chart_ref: prometheus-community/kube-prometheus-stack
|
||||||
|
release_namespace: monitoring
|
||||||
|
|
||||||
|
- name: Collect the releases in that namespace
|
||||||
|
kubernetes.core.helm_info:
|
||||||
|
name: kube-prometheus-stack
|
||||||
|
release_namespace: monitoring
|
||||||
|
|
||||||
|
Every task picks up ``kubeconfig`` and ``context`` from its group without repeating them, the
|
||||||
|
``helm`` modules additionally pick up ``binary_path``, and an option set on an individual task
|
||||||
|
still wins over the group default.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
Always write the group name fully qualified as ``group/kubernetes.core.k8s``. A bare
|
||||||
|
``group/k8s`` refers to the legacy ``k8s`` group that ansible-core defined back when the
|
||||||
|
Kubernetes modules shipped in core itself. The two are not the same group, and the legacy
|
||||||
|
one does not cover the modules in this collection.
|
||||||
|
|
||||||
|
Some modules are deliberately **not** in these groups because they do not accept the shared
|
||||||
|
authentication options, and including them would make ``module_defaults`` fail for everyone
|
||||||
|
using the group:
|
||||||
|
|
||||||
|
- ``helm_pull`` and ``helm_template`` accept only ``binary_path``.
|
||||||
|
- ``helm_registry_auth`` accepts ``binary_path`` and its own ``host``, which is an OCI
|
||||||
|
registry URL rather than a Kubernetes API server.
|
||||||
|
- ``kubeconfig`` writes a kubeconfig file locally and takes no cluster connection options.
|
||||||
|
|
||||||
|
Pass options to those modules directly, or give them their own per-module ``module_defaults``
|
||||||
|
entry.
|
||||||
|
|
||||||
Reporting an issue
|
Reporting an issue
|
||||||
==================
|
==================
|
||||||
|
|
||||||
|
|||||||
@@ -1,88 +0,0 @@
|
|||||||
.. _ansible_collections.kubernetes.core.docsite.k8s_ansible_inventory:
|
|
||||||
|
|
||||||
*****************************************
|
|
||||||
Using Kubernetes dynamic inventory plugin
|
|
||||||
*****************************************
|
|
||||||
|
|
||||||
.. contents::
|
|
||||||
:local:
|
|
||||||
|
|
||||||
Kubernetes dynamic inventory plugin
|
|
||||||
===================================
|
|
||||||
|
|
||||||
|
|
||||||
The best way to interact with your Pods is to use the Kubernetes dynamic inventory plugin, which queries Kubernetes APIs using ``kubectl`` command line available on controller node and tells Ansible what Pods can be managed.
|
|
||||||
|
|
||||||
Requirements
|
|
||||||
------------
|
|
||||||
|
|
||||||
To use the Kubernetes dynamic inventory plugins, you must install `Kubernetes Python client <https://github.com/kubernetes-client/python>`_, `kubectl <https://github.com/kubernetes/kubectl>`_ on your control node (the host running Ansible).
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ pip install kubernetes
|
|
||||||
|
|
||||||
Please refer to Kubernetes official documentation for `installing kubectl <https://kubernetes.io/docs/tasks/tools/install-kubectl/>`_ on the given operating systems.
|
|
||||||
|
|
||||||
To use this Kubernetes dynamic inventory plugin, you need to enable it first by specifying the following in the ``ansible.cfg`` file:
|
|
||||||
|
|
||||||
.. code-block:: ini
|
|
||||||
|
|
||||||
[inventory]
|
|
||||||
enable_plugins = kubernetes.core.k8s
|
|
||||||
|
|
||||||
Then, create a file that ends in ``.k8s.yml`` or ``.k8s.yaml`` in your working directory.
|
|
||||||
|
|
||||||
The ``kubernetes.core.k8s`` inventory plugin takes in the same authentication information as any other Kubernetes modules.
|
|
||||||
|
|
||||||
Here's an example of a valid inventory file:
|
|
||||||
|
|
||||||
.. code-block:: yaml
|
|
||||||
|
|
||||||
plugin: kubernetes.core.k8s
|
|
||||||
|
|
||||||
Executing ``ansible-inventory --list -i <filename>.k8s.yml`` will create a list of Pods that are ready to be configured using Ansible.
|
|
||||||
|
|
||||||
You can also provide the namespace to gather information about specific pods from the given namespace. For example, to gather information about Pods under the ``test`` namespace you will specify the ``namespaces`` parameter:
|
|
||||||
|
|
||||||
.. code-block:: yaml
|
|
||||||
|
|
||||||
plugin: kubernetes.core.k8s
|
|
||||||
connections:
|
|
||||||
- namespaces:
|
|
||||||
- test
|
|
||||||
|
|
||||||
Using vaulted configuration files
|
|
||||||
=================================
|
|
||||||
|
|
||||||
Since the inventory configuration file contains Kubernetes related sensitive information in plain text, a security risk, you may want to
|
|
||||||
encrypt your entire inventory configuration file.
|
|
||||||
|
|
||||||
You can encrypt a valid inventory configuration file as follows:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ ansible-vault encrypt <filename>.k8s.yml
|
|
||||||
New Vault password:
|
|
||||||
Confirm New Vault password:
|
|
||||||
Encryption successful
|
|
||||||
|
|
||||||
$ echo "MySuperSecretPassw0rd!" > /path/to/vault_password_file
|
|
||||||
|
|
||||||
And you can use this vaulted inventory configuration file using:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ ansible-inventory -i <filename>.k8s.yml --list --vault-password-file=/path/to/vault_password_file
|
|
||||||
|
|
||||||
|
|
||||||
.. seealso::
|
|
||||||
|
|
||||||
`Kubernetes Python client - Issue Tracker <https://github.com/kubernetes-client/python/issues>`_
|
|
||||||
The issue tracker for Kubernetes Python client
|
|
||||||
`Kubectl installation <https://kubernetes.io/docs/tasks/tools/install-kubectl/>`_
|
|
||||||
Installation guide for installing Kubectl
|
|
||||||
:ref:`working_with_playbooks`
|
|
||||||
An introduction to playbooks
|
|
||||||
:ref:`playbooks_vault`
|
|
||||||
Using Vault in playbooks
|
|
||||||
@@ -13,6 +13,5 @@ To get started, please select one of the following topics.
|
|||||||
:maxdepth: 1
|
:maxdepth: 1
|
||||||
|
|
||||||
kubernetes_scenarios/k8s_intro
|
kubernetes_scenarios/k8s_intro
|
||||||
kubernetes_scenarios/k8s_inventory
|
|
||||||
kubernetes_scenarios/k8s_scenarios
|
kubernetes_scenarios/k8s_scenarios
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ 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.
|
||||||
|
|
||||||
- helm (https://github.com/helm/helm/releases)
|
- helm >= 3.0.0 (https://github.com/helm/helm/releases)
|
||||||
- yaml (https://pypi.org/project/PyYAML/)
|
- yaml (https://pypi.org/project/PyYAML/)
|
||||||
|
|
||||||
|
|
||||||
@@ -427,6 +427,23 @@ Common return values are documented `here <https://docs.ansible.com/projects/ans
|
|||||||
<br/>
|
<br/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"> </td>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="return-"></div>
|
||||||
|
<b>release_values</b>
|
||||||
|
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">dictionary</span>
|
||||||
|
</div>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 6.3.0</div>
|
||||||
|
</td>
|
||||||
|
<td>always</td>
|
||||||
|
<td>
|
||||||
|
<div>Dict of Values used to deploy.</div>
|
||||||
|
<br/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="elbow-placeholder"> </td>
|
<td class="elbow-placeholder"> </td>
|
||||||
<td colspan="1">
|
<td colspan="1">
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ 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.
|
||||||
|
|
||||||
- helm (https://github.com/helm/helm/releases)
|
- helm >= 3.0.0 (https://github.com/helm/helm/releases)
|
||||||
- yaml (https://pypi.org/project/PyYAML/)
|
- yaml (https://pypi.org/project/PyYAML/)
|
||||||
|
|
||||||
|
|
||||||
@@ -73,6 +73,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>If set, the installation process deletes the installation on failure.</div>
|
<div>If set, the installation process deletes the installation on failure.</div>
|
||||||
|
<div>With Helm v4 this is translated to the <code>--rollback-on-failure</code> flag, since <code>--atomic</code> was renamed; with Helm v3 the <code>--atomic</code> flag is used. The O(atomic) option works the same way regardless of the installed Helm version.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -156,6 +157,29 @@ Parameters
|
|||||||
<div>Chart version to install. If this is not specified, the latest version is installed.</div>
|
<div>Chart version to install. If this is not specified, the latest version is installed.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>cleanup_on_fail</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.6.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>Allow deletion of new resources created during a failed upgrade.</div>
|
||||||
|
<div>Maps to the <code>--cleanup-on-fail</code> flag, which is available since helm 3.0.0 and was not renamed in Helm v4.</div>
|
||||||
|
<div>Complements O(atomic) rather than replacing it, and the two can be combined so that a rollback also drops resources orphaned by the failed upgrade.</div>
|
||||||
|
<div>Helm only accepts this flag on <code>helm upgrade</code>, so it cannot be used together with O(replace), which deploys through <code>helm install</code>.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -254,6 +278,30 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>Helm option to force reinstall, ignore on new install.</div>
|
<div>Helm option to force reinstall, ignore on new install.</div>
|
||||||
|
<div>With Helm v4 this performs a client-side replacement. Helm v4 deprecated <code>--force</code> (split into <code>--force-replace</code> and <code>--force-conflicts</code>) and enables server-side apply by default, so for Helm v4 the module emits <code>--server-side=false --force-replace</code> to preserve the Helm v3 behaviour. With Helm v3 the <code>--force</code> flag is used. The O(force) option works the same way regardless of the installed Helm version.</div>
|
||||||
|
<div>Mutually exclusive with O(server_side) and O(force_conflicts).</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<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>
|
||||||
|
<div style="font-style: italic; font-size: small; color: darkgreen">added in 6.5.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 server-side apply is enabled (the Helm v4 default), force changes against conflicts instead of failing.</div>
|
||||||
|
<div>Maps to the <code>--force-conflicts</code> flag.</div>
|
||||||
|
<div>This option requires Helm v4, cannot be combined with O(server_side=false), and is mutually exclusive with O(force).</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -330,6 +378,27 @@ Parameters
|
|||||||
<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>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>plain_http</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.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>Use HTTP instead of HTTPS when working with OCI registries</div>
|
||||||
|
<div>Requires Helm >= 3.13.0</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -476,7 +545,9 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
<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>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>Helm ignores this when <code>--reset-values</code> or <code>--reuse-values</code> is passed. Since O(reset_values) defaults to V(true), it has to be set to V(false), and O(reuse_values) left unset or V(false), for this option to take any effect.</div>
|
||||||
|
<div><code>helm install</code> does not accept <code>--reset-then-reuse-values</code>, so this option is ignored when O(replace) is set.</div>
|
||||||
|
<div>The module warns whenever one of those combinations makes this option a no-op.</div>
|
||||||
<div>This feature requires helm diff >= 3.9.12.</div>
|
<div>This feature requires helm diff >= 3.9.12.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -498,6 +569,7 @@ Parameters
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>When upgrading package, reset the values to the ones built into the chart.</div>
|
<div>When upgrading package, reset the values to the ones built into the chart.</div>
|
||||||
|
<div>Defaults to V(true), which makes helm ignore O(reuse_values) and O(reset_then_reuse_values). Set it to V(false) to use either of them.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -517,8 +589,33 @@ Parameters
|
|||||||
</ul>
|
</ul>
|
||||||
</td>
|
</td>
|
||||||
<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>When upgrading package, specifies whether to reuse 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 <em>reset_values</em> is set to <code>True</code>, this is ignored.</div>
|
<div>Helm ignores this when <code>--reset-values</code> is passed. Since O(reset_values) defaults to V(true), it has to be set to V(false) for this option to take any effect.</div>
|
||||||
|
<div><code>helm install</code> does not accept <code>--reuse-values</code>, so this option is ignored when O(replace) is set.</div>
|
||||||
|
<div>The module warns whenever one of those combinations makes this option a no-op.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>server_side</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 6.5.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
||||||
|
<li>auto</li>
|
||||||
|
<li>true</li>
|
||||||
|
<li>false</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Control Helm v4 server-side apply when installing or upgrading a release.</div>
|
||||||
|
<div>Maps to the <code>--server-side</code> flag, which accepts <code>true</code>, <code>false</code> or <code>auto</code>.</div>
|
||||||
|
<div>This option requires Helm v4 and is mutually exclusive with O(force).</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -601,6 +698,48 @@ Parameters
|
|||||||
<div>Skip custom resource definitions when installing or upgrading.</div>
|
<div>Skip custom resource definitions when installing or upgrading.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>skip_schema_validation</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.2.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>Disables JSON schema validation for Chart and values.</div>
|
||||||
|
<div>This feature requires helm >= 3.16.0</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>take_ownership</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.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>Helm will ignore the check for helm annotations and take ownership of the existing resources</div>
|
||||||
|
<div>This feature requires helm >= 3.17.0</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -700,6 +839,28 @@ Parameters
|
|||||||
<div>When <em>release_state</em> is set to <code>absent</code>, will wait until all the resources are deleted before returning. It will wait for as long as <em>wait_timeout</em>. This feature requires helm>=3.7.0. Added in version 2.3.0.</div>
|
<div>When <em>release_state</em> is set to <code>absent</code>, will wait until all the resources are deleted before returning. It will wait for as long as <em>wait_timeout</em>. This feature requires helm>=3.7.0. Added in version 2.3.0.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>wait_for_jobs</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.6.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 <em>release_state</em> is set to <code>present</code>, and <em>wait</em> is set to <code>True</code>, wait until all jobs are in a completed state before marking the release as successful.</div>
|
||||||
|
<div>Ignored when used without O(wait).</div>
|
||||||
|
<div>Requires Helm >= 3.5.0</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -810,6 +971,12 @@ Examples
|
|||||||
chart_ref: "https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz"
|
chart_ref: "https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz"
|
||||||
release_namespace: monitoring
|
release_namespace: monitoring
|
||||||
|
|
||||||
|
- name: Deploy Bitnami's MongoDB latest chart from OCI registry
|
||||||
|
kubernetes.core.helm:
|
||||||
|
name: test
|
||||||
|
chart_ref: "oci://registry-1.docker.io/bitnamicharts/mongodb"
|
||||||
|
release_namespace: database
|
||||||
|
|
||||||
# Using complex Values
|
# Using complex Values
|
||||||
- name: Deploy new-relic client chart
|
- name: Deploy new-relic client chart
|
||||||
kubernetes.core.helm:
|
kubernetes.core.helm:
|
||||||
@@ -818,6 +985,7 @@ Examples
|
|||||||
release_namespace: default
|
release_namespace: default
|
||||||
force: True
|
force: True
|
||||||
wait: True
|
wait: True
|
||||||
|
wait_for_jobs: True
|
||||||
replace: True
|
replace: True
|
||||||
update_repo_cache: True
|
update_repo_cache: True
|
||||||
disable_hook: True
|
disable_hook: True
|
||||||
@@ -837,21 +1005,37 @@ Examples
|
|||||||
enabled: True
|
enabled: True
|
||||||
|
|
||||||
# Deploy latest version
|
# Deploy latest version
|
||||||
|
# 'reset_values' defaults to true and helm ignores '--reuse-values' when it is set,
|
||||||
|
# so it has to be turned off explicitly.
|
||||||
- name: Deploy latest version of Grafana chart using reuse_values
|
- name: Deploy latest version of Grafana chart using reuse_values
|
||||||
kubernetes.core.helm:
|
kubernetes.core.helm:
|
||||||
name: test
|
name: test
|
||||||
chart_ref: stable/grafana
|
chart_ref: stable/grafana
|
||||||
release_namespace: monitoring
|
release_namespace: monitoring
|
||||||
reuse_values: true
|
reuse_values: true
|
||||||
|
reset_values: false
|
||||||
values:
|
values:
|
||||||
replicas: 2
|
replicas: 2
|
||||||
version: 3e8ec0b2dffa40fb97d5342e4af887de95faa8c61a62480dd7f8aa03dffcf533
|
version: 3e8ec0b2dffa40fb97d5342e4af887de95faa8c61a62480dd7f8aa03dffcf533
|
||||||
|
|
||||||
|
# Same for 'reset_then_reuse_values', which helm ignores when either
|
||||||
|
# '--reset-values' or '--reuse-values' is set.
|
||||||
|
- name: Deploy latest version of Grafana chart using reset_then_reuse_values
|
||||||
|
kubernetes.core.helm:
|
||||||
|
name: test
|
||||||
|
chart_ref: stable/grafana
|
||||||
|
release_namespace: monitoring
|
||||||
|
reset_then_reuse_values: true
|
||||||
|
reset_values: false
|
||||||
|
values:
|
||||||
|
replicas: 2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Return Values
|
Return Values
|
||||||
-------------
|
-------------
|
||||||
Common return values are documented `here <https://docs.ansible.com/projects/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
|
Common return values are documented `here <https://docs.ansible.com/projects/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
|
||||||
|
Common return values are documented `here <https://docs.ansible.com/projects/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
|
||||||
|
|
||||||
.. raw:: html
|
.. raw:: html
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ 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.
|
||||||
|
|
||||||
- helm (https://github.com/helm/helm/releases)
|
- helm >= 3.0.0 (https://github.com/helm/helm/releases)
|
||||||
|
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ 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.
|
||||||
|
|
||||||
- helm (https://github.com/helm/helm/releases)
|
- helm >= 3.0.0 (https://github.com/helm/helm/releases)
|
||||||
|
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@@ -120,6 +120,24 @@ Parameters
|
|||||||
<div>Provide a URL for accessing the API. Can also be specified via <code>K8S_AUTH_HOST</code> environment variable.</div>
|
<div>Provide a URL for accessing the API. Can also be specified via <code>K8S_AUTH_HOST</code> environment variable.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>keyring</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 6.5.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Location of public keys used for verification.</div>
|
||||||
|
<div>Only valid with <code>state=present</code>, which maps to the <code>helm plugin install</code> subcommand.</div>
|
||||||
|
<div>This option requires helm version >= 4.0.0.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="1">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -231,6 +249,28 @@ Parameters
|
|||||||
<div style="font-size: small; color: darkgreen"><br/>aliases: verify_ssl</div>
|
<div style="font-size: small; color: darkgreen"><br/>aliases: verify_ssl</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>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 6.4.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>Verify the plugin signature before installing.</div>
|
||||||
|
<div>This option requires helm version >= 4.0.0</div>
|
||||||
|
<div>Used with <em>state=present</em>.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ 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.
|
||||||
|
|
||||||
- helm >= 3.0, <4.0.0 (https://github.com/helm/helm/releases)
|
- helm >= 3.0.0 (https://github.com/helm/helm/releases)
|
||||||
|
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@@ -215,6 +215,27 @@ Parameters
|
|||||||
<div>Pass credentials to all domains.</div>
|
<div>Pass credentials to all domains.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>plain_http</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.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>Use HTTP instead of HTTPS when working with OCI registries</div>
|
||||||
|
<div>Requires Helm >= 3.13.0</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="1">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ 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.
|
||||||
|
|
||||||
- helm (https://github.com/helm/helm/releases) >= 3.8.0, <4.0.0
|
- helm (https://github.com/helm/helm/releases) >= 3.8.0
|
||||||
|
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@@ -151,6 +151,27 @@ Parameters
|
|||||||
<div style="font-size: small; color: darkgreen"><br/>aliases: repo_password</div>
|
<div style="font-size: small; color: darkgreen"><br/>aliases: repo_password</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>plain_http</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.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>Use insecure HTTP connections for <code>helm registry login</code>.</div>
|
||||||
|
<div>Requires Helm >= 3.18.0</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="1">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -268,7 +289,9 @@ Common return values are documented `here <https://docs.ansible.com/projects/ans
|
|||||||
</td>
|
</td>
|
||||||
<td>always</td>
|
<td>always</td>
|
||||||
<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>
|
<div>Full <code>helm</code> command stderr, in case you want to display it or examine the event log.</div>
|
||||||
|
<div>Please note that the helm binary may print messages to stderr even if the command is successful.</div>
|
||||||
|
<div>On Helm versions earlier than 4.2.1, success messages such as <code>Login Succeeded</code> are printed here; as of Helm 4.2.1 they are printed to stdout (see <a href='https://github.com/helm/helm/pull/32056'>https://github.com/helm/helm/pull/32056</a>).</div>
|
||||||
<br/>
|
<br/>
|
||||||
<div style="font-size: smaller"><b>Sample:</b></div>
|
<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>
|
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">Login Succeeded\n</div>
|
||||||
@@ -300,14 +323,17 @@ Common return values are documented `here <https://docs.ansible.com/projects/ans
|
|||||||
</td>
|
</td>
|
||||||
<td>always</td>
|
<td>always</td>
|
||||||
<td>
|
<td>
|
||||||
<div>Full <code>helm</code> command stdout, in case you want to display it or examine the event log</div>
|
<div>Full <code>helm</code> command stdout, in case you want to display it or examine the event log.</div>
|
||||||
|
<div>As of Helm 4.2.1 success messages such as <code>Login Succeeded</code> are printed to stdout (see <a href='https://github.com/helm/helm/pull/32056'>https://github.com/helm/helm/pull/32056</a>). On earlier versions they are printed to stderr.</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;">Login Succeeded\n</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="1">
|
||||||
<div class="ansibleOptionAnchor" id="return-"></div>
|
<div class="ansibleOptionAnchor" id="return-"></div>
|
||||||
<b>stout_lines</b>
|
<b>stdout_lines</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">list</span>
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ 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.
|
||||||
|
|
||||||
- helm (https://github.com/helm/helm/releases)
|
- helm >= 3.0.0 (https://github.com/helm/helm/releases)
|
||||||
- yaml (https://pypi.org/project/PyYAML/)
|
- yaml (https://pypi.org/project/PyYAML/)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,13 @@ Synopsis
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
------------
|
||||||
|
The below requirements are needed on the host that executes this module.
|
||||||
|
|
||||||
|
- helm >= 3.0.0 (https://github.com/helm/helm/releases)
|
||||||
|
- yaml (https://pypi.org/project/PyYAML/)
|
||||||
|
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
@@ -194,6 +201,27 @@ Parameters
|
|||||||
<div>If the directory already exists, it will be overwritten.</div>
|
<div>If the directory already exists, it will be overwritten.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>plain_http</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.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>Use HTTP instead of HTTPS when working with OCI registries</div>
|
||||||
|
<div>Requires Helm >= 3.13.0</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
|||||||
@@ -152,6 +152,25 @@ Parameters
|
|||||||
<div>The name of a context found in the config file. Can also be specified via K8S_AUTH_CONTEXT environment variable.</div>
|
<div>The name of a context found in the config file. Can also be specified via K8S_AUTH_CONTEXT environment variable.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>copy_timeout</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 6.6.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<b>Default:</b><br/><div style="color: blue">300</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Maximum time in seconds to spend streaming the archive to the pod and waiting for the remote <code>tar</code> process to finish extracting it.</div>
|
||||||
|
<div>Raise this when copying large files over a slow connection.</div>
|
||||||
|
<div>This option is ignored when <em>state</em> is set to <code>from_pod</code>.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -512,6 +531,7 @@ Notes
|
|||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
- the tar binary is required on the container when copying from local filesystem to pod.
|
- the tar binary is required on the container when copying from local filesystem to pod.
|
||||||
|
- a POSIX shell at ``/bin/sh`` and ``head`` are also used, when present, to bound the archive sent to the container so that the module can confirm the copy finished. Without them the copy still runs but completion cannot be verified, and a warning is emitted.
|
||||||
- the (init) container has to be started before you copy files or directories to it.
|
- the (init) container has to be started before you copy files or directories to it.
|
||||||
- To avoid SSL certificate validation errors when ``validate_certs`` is *True*, the full certificate chain for the API server must be provided via ``ca_cert`` or in the kubeconfig file.
|
- To avoid SSL certificate validation errors when ``validate_certs`` is *True*, the full certificate chain for the API server must be provided via ``ca_cert`` or in the kubeconfig file.
|
||||||
|
|
||||||
|
|||||||
@@ -280,6 +280,29 @@ Parameters
|
|||||||
<div>List of label selectors to use to filter results</div>
|
<div>List of label selectors to use to filter results</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>metadata_only</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.6.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>Request metadata only response from the Kubernetes API server.</div>
|
||||||
|
<div>This feature is useful for clients that only need to check for the existence of an object,</div>
|
||||||
|
<div>or that only need to read its metadata.</div>
|
||||||
|
<div>It can significantly reduce the size of the response from the API server.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -716,6 +739,12 @@ Examples
|
|||||||
retries: 60
|
retries: 60
|
||||||
delay: 15
|
delay: 15
|
||||||
|
|
||||||
|
- name: Get a list of all pods metadata only
|
||||||
|
kubernetes.core.k8s_info:
|
||||||
|
kind: Pod
|
||||||
|
metadata_only: true
|
||||||
|
register: pod_metadata_list
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Return Values
|
Return Values
|
||||||
|
|||||||
@@ -1,372 +0,0 @@
|
|||||||
.. _kubernetes.core.k8s_inventory:
|
|
||||||
|
|
||||||
|
|
||||||
*******************
|
|
||||||
kubernetes.core.k8s
|
|
||||||
*******************
|
|
||||||
|
|
||||||
**Kubernetes (K8s) inventory source**
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.. contents::
|
|
||||||
:local:
|
|
||||||
: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
|
|
||||||
--------
|
|
||||||
- Fetch containers and services for one or more clusters.
|
|
||||||
- Groups by cluster name, namespace, namespace_services, namespace_pods, and labels.
|
|
||||||
- Uses the kubectl connection plugin to access the Kubernetes cluster.
|
|
||||||
- Uses k8s.(yml|yaml) YAML configuration file to set parameter values.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Requirements
|
|
||||||
------------
|
|
||||||
The below requirements are needed on the local Ansible controller node that executes this inventory.
|
|
||||||
|
|
||||||
- python >= 3.9
|
|
||||||
- kubernetes >= 24.2.0
|
|
||||||
- PyYAML >= 3.11
|
|
||||||
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
|
|
||||||
.. raw:: html
|
|
||||||
|
|
||||||
<table border=0 cellpadding=0 class="documentation-table">
|
|
||||||
<tr>
|
|
||||||
<th colspan="2">Parameter</th>
|
|
||||||
<th>Choices/<font color="blue">Defaults</font></th>
|
|
||||||
<th>Configuration</th>
|
|
||||||
<th width="100%">Comments</th>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="2">
|
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
||||||
<b>connections</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>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div>Optional list of cluster connection settings. If no connections are provided, the default <em>~/.kube/config</em> and active context will be used, and objects will be returned for all namespaces the active user is authorized to access.</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="elbow-placeholder"></td>
|
|
||||||
<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">-</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div>Token used to authenticate with the API. Can also be specified via K8S_AUTH_API_KEY environment variable.</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="elbow-placeholder"></td>
|
|
||||||
<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">-</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div>Path to a CA certificate used to authenticate with the API. Can also be specified via K8S_AUTH_SSL_CA_CERT environment variable.</div>
|
|
||||||
<div style="font-size: small; color: darkgreen"><br/>aliases: ssl_ca_cert</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="elbow-placeholder"></td>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
||||||
<b>client_cert</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>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div>Path to a certificate used to authenticate with the API. Can also be specified via K8S_AUTH_CERT_FILE environment variable.</div>
|
|
||||||
<div style="font-size: small; color: darkgreen"><br/>aliases: cert_file</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="elbow-placeholder"></td>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
||||||
<b>client_key</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>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div>Path to a key file used to authenticate with the API. Can also be specified via K8S_AUTH_KEY_FILE environment variable.</div>
|
|
||||||
<div style="font-size: small; color: darkgreen"><br/>aliases: key_file</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="elbow-placeholder"></td>
|
|
||||||
<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">-</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div>The name of a context found in the config file. Can also be specified via K8S_AUTH_CONTEXT environment variable.</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="elbow-placeholder"></td>
|
|
||||||
<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">-</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div>Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="elbow-placeholder"></td>
|
|
||||||
<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">-</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</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>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="elbow-placeholder"></td>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
||||||
<b>name</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>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div>Optional name to assign to the cluster. If not provided, a name is constructed from the server and port.</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="elbow-placeholder"></td>
|
|
||||||
<td colspan="1">
|
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
||||||
<b>namespaces</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>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div>List of namespaces. If not specified, will fetch all containers for all namespaces user is authorized to access.</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="elbow-placeholder"></td>
|
|
||||||
<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">-</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div>Provide a password for authenticating with the API. Can also be specified via K8S_AUTH_PASSWORD environment variable.</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="elbow-placeholder"></td>
|
|
||||||
<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">-</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div>Provide a username for authenticating with the API. Can also be specified via K8S_AUTH_USERNAME environment variable.</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="elbow-placeholder"></td>
|
|
||||||
<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>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
|
||||||
<li>no</li>
|
|
||||||
<li>yes</li>
|
|
||||||
</ul>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div>Whether or not to verify the API server's SSL certificates. Can also be specified via K8S_AUTH_VERIFY_SSL environment variable.</div>
|
|
||||||
<div style="font-size: small; color: darkgreen"><br/>aliases: verify_ssl</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td colspan="2">
|
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
|
||||||
<b>plugin</b>
|
|
||||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
|
||||||
<div style="font-size: small">
|
|
||||||
<span style="color: purple">-</span>
|
|
||||||
/ <span style="color: red">required</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
|
||||||
<li>kubernetes.core.k8s</li>
|
|
||||||
<li>k8s</li>
|
|
||||||
<li>community.kubernetes.k8s</li>
|
|
||||||
</ul>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div>token that ensures this is a source file for the 'k8s' plugin.</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Examples
|
|
||||||
--------
|
|
||||||
|
|
||||||
.. code-block:: yaml
|
|
||||||
|
|
||||||
# File must be named k8s.yaml or k8s.yml
|
|
||||||
|
|
||||||
- name: Authenticate with token, and return all pods and services for all namespaces
|
|
||||||
plugin: kubernetes.core.k8s
|
|
||||||
connections:
|
|
||||||
- host: https://192.168.64.4:8443
|
|
||||||
api_key: xxxxxxxxxxxxxxxx
|
|
||||||
validate_certs: false
|
|
||||||
|
|
||||||
- name: Use default config (~/.kube/config) file and active context, and return objects for a specific namespace
|
|
||||||
plugin: kubernetes.core.k8s
|
|
||||||
connections:
|
|
||||||
- namespaces:
|
|
||||||
- testing
|
|
||||||
|
|
||||||
- name: Use a custom config file, and a specific context.
|
|
||||||
plugin: kubernetes.core.k8s
|
|
||||||
connections:
|
|
||||||
- kubeconfig: /path/to/config
|
|
||||||
context: 'awx/192-168-64-4:8443/developer'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Status
|
|
||||||
------
|
|
||||||
|
|
||||||
|
|
||||||
- This inventory will be removed in version 6.0.0. *[deprecated]*
|
|
||||||
- For more information see `DEPRECATED`_.
|
|
||||||
|
|
||||||
|
|
||||||
Authors
|
|
||||||
~~~~~~~
|
|
||||||
|
|
||||||
- Chris Houseknecht (@chouseknecht)
|
|
||||||
- Fabian von Feilitzsch (@fabianvf)
|
|
||||||
|
|
||||||
|
|
||||||
.. hint::
|
|
||||||
Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.
|
|
||||||
@@ -140,6 +140,25 @@ Parameters
|
|||||||
<div>The name of a context found in the config file. Can also be specified via K8S_AUTH_CONTEXT environment variable.</div>
|
<div>The name of a context found in the config file. Can also be specified via K8S_AUTH_CONTEXT environment variable.</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 6.1.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<b>Default:</b><br/><div style="color: blue">[]</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>List of fields to hide from the diff output.</div>
|
||||||
|
<div>This is useful for fields that are not relevant to the patch operation, such as `metadata.managedFields`.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
|||||||
@@ -813,7 +813,7 @@ Parameters
|
|||||||
</ul>
|
</ul>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>Determines if an object should be created, patched, or deleted. When set to <code>present</code>, an object will be created, if it does not already exist. If set to <code>absent</code>, an existing object will be deleted. If set to <code>present</code>, an existing object will be patched, if its attributes differ from those specified using <em>resource_definition</em> or <em>src</em>.</div>
|
<div>Determines if an object should be created, patched, or deleted. When set to <code>present</code>, an object will be created if it does not already exist, and an existing object will be patched if its attributes differ from those specified using <em>resource_definition</em> or <em>src</em>. If set to <code>absent</code>, an existing object will be deleted.</div>
|
||||||
<div><code>patched</code> state is an existing resource that has a given patch applied. If the resource doesn't exist, silently skip it (do not raise an error).</div>
|
<div><code>patched</code> state is an existing resource that has a given patch applied. If the resource doesn't exist, silently skip it (do not raise an error).</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -509,7 +509,7 @@ Parameters
|
|||||||
</ul>
|
</ul>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>Determines if an object should be created, patched, or deleted. When set to <code>present</code>, an object will be created, if it does not already exist. If set to <code>absent</code>, an existing object will be deleted. If set to <code>present</code>, an existing object will be patched, if its attributes differ from those specified using <em>resource_definition</em> or <em>src</em>.</div>
|
<div>Determines if an object should be created, patched, or deleted. When set to <code>present</code>, an object will be created if it does not already exist, and an existing object will be patched if its attributes differ from those specified using <em>resource_definition</em> or <em>src</em>. If set to <code>absent</code>, an existing object will be deleted.</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -0,0 +1,863 @@
|
|||||||
|
.. _kubernetes.core.kubeconfig_module:
|
||||||
|
|
||||||
|
|
||||||
|
**************************
|
||||||
|
kubernetes.core.kubeconfig
|
||||||
|
**************************
|
||||||
|
|
||||||
|
**Generate, update, and optionally write Kubernetes kubeconfig files**
|
||||||
|
|
||||||
|
|
||||||
|
Version added: 6.5.0
|
||||||
|
|
||||||
|
.. contents::
|
||||||
|
:local:
|
||||||
|
:depth: 1
|
||||||
|
|
||||||
|
|
||||||
|
Synopsis
|
||||||
|
--------
|
||||||
|
- Build, update, and manage Kubernetes kubeconfig files using structured input.
|
||||||
|
- Supports loading an existing kubeconfig file and merging clusters, users, and contexts.
|
||||||
|
- Can optionally write the resulting kubeconfig to a destination path.
|
||||||
|
- Ensures idempotent behavior by only updating files when changes occur.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
------------
|
||||||
|
The below requirements are needed on the host that executes this module.
|
||||||
|
|
||||||
|
- PyYAML >= 5.1
|
||||||
|
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
|
||||||
|
.. raw:: html
|
||||||
|
|
||||||
|
<table border=0 cellpadding=0 class="documentation-table">
|
||||||
|
<tr>
|
||||||
|
<th colspan="3">Parameter</th>
|
||||||
|
<th>Choices/<font color="blue">Defaults</font></th>
|
||||||
|
<th width="100%">Comments</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>clusters</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>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<b>Default:</b><br/><div style="color: blue">[]</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>List of cluster definitions to merge into the kubeconfig.</div>
|
||||||
|
<div>Each cluster is identified by its <code>name</code>.</div>
|
||||||
|
<div>When <code>name</code> matches an existing cluster, the default <code>behavior</code> is V(merge).</div>
|
||||||
|
<div>See the <code>behavior</code> suboption for V(replace), V(keep), and V(remove).</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>behavior</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>merge</b> ←</div></li>
|
||||||
|
<li>replace</li>
|
||||||
|
<li>keep</li>
|
||||||
|
<li>remove</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>How to handle merging if a cluster with this name already exists.</div>
|
||||||
|
<div><code>merge</code> - Update only the specified fields, preserve others (default).</div>
|
||||||
|
<div><code>replace</code> - Replace the entire cluster definition.</div>
|
||||||
|
<div><code>keep</code> - Keep existing cluster, skip this entry.</div>
|
||||||
|
<div><code>remove</code> - Remove the cluster entry entirely. Silently skipped if the entry does not exist.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>cluster</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">dictionary</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Cluster configuration details.</div>
|
||||||
|
<div>Not required when <code>behavior</code> is V(remove).</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>certificate-authority</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>Path to a CA certificate file for validating the API server certificate.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>certificate-authority-data</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>Base64 encoded CA certificate data.</div>
|
||||||
|
<div>Use this instead of <code>certificate-authority</code> for embedded certificates.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<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>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
||||||
|
<li>no</li>
|
||||||
|
<li>yes</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>If true, the server's certificate will not be validated.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>proxy-url</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>Optional proxy URL for cluster connections.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>server</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>Kubernetes API server URL (e.g., <code>https://k8s.example.com:6443</code>).</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>tls-server-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>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Server name to use for server certificate validation.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>name</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>Unique name identifier for the cluster.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>contexts</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>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<b>Default:</b><br/><div style="color: blue">[]</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>List of context definitions linking users and clusters.</div>
|
||||||
|
<div>Each context is identified by its <code>name</code>.</div>
|
||||||
|
<div>When <code>name</code> matches an existing context, the default <code>behavior</code> is V(merge).</div>
|
||||||
|
<div>See the <code>behavior</code> suboption for V(replace), V(keep), and V(remove).</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>behavior</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>merge</b> ←</div></li>
|
||||||
|
<li>replace</li>
|
||||||
|
<li>keep</li>
|
||||||
|
<li>remove</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>How to handle merging if a context with this name already exists.</div>
|
||||||
|
<div><code>merge</code> - Update only the specified fields, preserve others (default).</div>
|
||||||
|
<div><code>replace</code> - Replace the entire context definition.</div>
|
||||||
|
<div><code>keep</code> - Keep existing context, skip this entry.</div>
|
||||||
|
<div><code>remove</code> - Remove the context entry entirely. Silently skipped if the entry does not exist.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="2">
|
||||||
|
<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">dictionary</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Context configuration linking cluster and user.</div>
|
||||||
|
<div>Not required when <code>behavior</code> is V(remove).</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>cluster</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 cluster to use (must match a cluster name in O(clusters)).</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>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>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Default namespace to use for this context.</div>
|
||||||
|
<div>If not specified, defaults to <code>default</code>.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>user</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 user to authenticate as (must match a user name in O(users)).</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>name</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>Unique name identifier for the context.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>current_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>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Name of the context to set as current/active.</div>
|
||||||
|
<div>This context will be used by default when using kubectl.</div>
|
||||||
|
<div>Must match one of the context names defined in O(contexts).</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>dest</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>Destination path where the final kubeconfig should be written.</div>
|
||||||
|
<div>If not specified, the kubeconfig will be saved to O(path).</div>
|
||||||
|
<div>Allows copying and modifying a kubeconfig to a new location.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>path</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>Path to an existing kubeconfig file to load and merge from.</div>
|
||||||
|
<div>If the file does not exist, a new kubeconfig will be created.</div>
|
||||||
|
<div>This becomes the default destination if O(dest) is not specified.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>preferences</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">dictionary</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<b>Default:</b><br/><div style="color: blue">{}</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Kubeconfig preferences.</div>
|
||||||
|
<div>Used for client-side settings like color output, default editor, etc.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>users</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>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<b>Default:</b><br/><div style="color: blue">[]</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>List of user authentication configurations.</div>
|
||||||
|
<div>Each user is identified by its <code>name</code>.</div>
|
||||||
|
<div>When <code>name</code> matches an existing user, the default <code>behavior</code> is V(merge).</div>
|
||||||
|
<div>See the <code>behavior</code> suboption for V(replace), V(keep), and V(remove).</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>behavior</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>merge</b> ←</div></li>
|
||||||
|
<li>replace</li>
|
||||||
|
<li>keep</li>
|
||||||
|
<li>remove</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>How to handle merging if a user with this name already exists.</div>
|
||||||
|
<div><code>merge</code> - Update only the specified fields, preserve others (default).</div>
|
||||||
|
<div><code>replace</code> - Replace the entire user definition.</div>
|
||||||
|
<div><code>keep</code> - Keep existing user, skip this entry.</div>
|
||||||
|
<div><code>remove</code> - Remove the user entry entirely. Silently skipped if the entry does not exist.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>name</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>Unique name identifier for the user.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>user</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">dictionary</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>User authentication configuration.</div>
|
||||||
|
<div>Not required when <code>behavior</code> is V(remove).</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>auth-provider</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">dictionary</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Authentication provider configuration (e.g., for GCP, Azure).</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>client-certificate</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>Path to client certificate file.</div>
|
||||||
|
<div>Used for certificate-based authentication.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>client-certificate-data</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>Base64 encoded client certificate.</div>
|
||||||
|
<div>Use instead of <code>client-certificate</code> for embedded certificates.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>client-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>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Path to client private key file.</div>
|
||||||
|
<div>Must be provided with <code>client-certificate</code>.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>client-key-data</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>Base64 encoded client private key.</div>
|
||||||
|
<div>Use instead of <code>client-key</code> for embedded keys.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>exec</b>
|
||||||
|
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">dictionary</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>Exec-based credential plugin configuration.</div>
|
||||||
|
<div>Used for external authentication providers.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<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 basic authentication.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>token</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>Bearer token for authentication.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<td class="elbow-placeholder"></td>
|
||||||
|
<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 basic authentication.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
</table>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
|
||||||
|
Notes
|
||||||
|
-----
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
- Input data is merged by resource name (cluster, user, context).
|
||||||
|
- Updates under O(clusters), O(users), and O(contexts) are matched by ``name`` against the kubeconfig loaded from O(path).
|
||||||
|
- For an existing ``name``, each entry's ``behavior`` suboption controls the update.
|
||||||
|
- The default is V(merge), which merges nested ``cluster``, ``user``, and ``context`` data so unspecified keys are preserved.
|
||||||
|
- With V(replace), the previous entry for that name is dropped and only the new definition is used.
|
||||||
|
- With V(keep), the existing entry is left unchanged.
|
||||||
|
- With V(remove), the existing entry is deleted from the kubeconfig entirely. If no entry with that name exists, the operation is silently skipped.
|
||||||
|
- This can be used to move kubeconfig files to a different location with different content.
|
||||||
|
- This module does not validate cluster connectivity or authentication.
|
||||||
|
- The module supports ``check_mode`` and will not write files when enabled.
|
||||||
|
- The structure follows standard Kubernetes kubeconfig format as defined in the Kubernetes documentation.
|
||||||
|
- Tokens and sensitive data should be protected using ansible-vault or environment variables.
|
||||||
|
|
||||||
|
|
||||||
|
See Also
|
||||||
|
--------
|
||||||
|
|
||||||
|
.. seealso::
|
||||||
|
|
||||||
|
`Kubernetes kubeconfig documentation <https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/>`_
|
||||||
|
Official Kubernetes documentation for kubeconfig files
|
||||||
|
`kubectl config documentation <https://kubernetes.io/docs/reference/kubectl/generated/kubectl_config/>`_
|
||||||
|
kubectl commands for working with kubeconfig files
|
||||||
|
|
||||||
|
|
||||||
|
Examples
|
||||||
|
--------
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
# Create a new kubeconfig file with a single cluster
|
||||||
|
- name: Create basic kubeconfig
|
||||||
|
kubernetes.core.kubeconfig:
|
||||||
|
path: /home/user/.kube/config
|
||||||
|
clusters:
|
||||||
|
- name: production-cluster
|
||||||
|
cluster:
|
||||||
|
server: https://prod.k8s.example.com:6443
|
||||||
|
certificate-authority-data: LS0tLS1CRUdJTi...
|
||||||
|
users:
|
||||||
|
- name: admin-user
|
||||||
|
user:
|
||||||
|
token: eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9...
|
||||||
|
contexts:
|
||||||
|
- name: prod-admin
|
||||||
|
context:
|
||||||
|
cluster: production-cluster
|
||||||
|
user: admin-user
|
||||||
|
namespace: production
|
||||||
|
current_context: prod-admin
|
||||||
|
|
||||||
|
- name: Add a second cluster to an existing kubeconfig without touching other entries
|
||||||
|
kubernetes.core.kubeconfig:
|
||||||
|
path: /home/user/.kube/config
|
||||||
|
clusters:
|
||||||
|
- name: staging-cluster
|
||||||
|
cluster:
|
||||||
|
server: https://staging.k8s.example.com:6443
|
||||||
|
insecure-skip-tls-verify: true
|
||||||
|
users:
|
||||||
|
- name: staging-user
|
||||||
|
user:
|
||||||
|
client-certificate: /path/to/staging.crt
|
||||||
|
client-key: /path/to/staging.key
|
||||||
|
contexts:
|
||||||
|
- name: staging-admin
|
||||||
|
context:
|
||||||
|
cluster: staging-cluster
|
||||||
|
user: staging-user
|
||||||
|
namespace: staging
|
||||||
|
|
||||||
|
- name: Update only the token for an existing user, preserving all other user fields
|
||||||
|
kubernetes.core.kubeconfig:
|
||||||
|
path: /home/user/.kube/config
|
||||||
|
users:
|
||||||
|
- name: admin-user
|
||||||
|
behavior: merge
|
||||||
|
user:
|
||||||
|
token: "{{ new_admin_token }}"
|
||||||
|
|
||||||
|
- name: Replace a cluster definition entirely.
|
||||||
|
kubernetes.core.kubeconfig:
|
||||||
|
path: /home/user/.kube/config
|
||||||
|
clusters:
|
||||||
|
- name: production-cluster
|
||||||
|
behavior: replace
|
||||||
|
cluster:
|
||||||
|
server: https://new-prod.k8s.example.com:6443
|
||||||
|
certificate-authority-data: LS0tLS1CRUdJTi...
|
||||||
|
|
||||||
|
- name: Remove a decommissioned cluster, user, and context
|
||||||
|
kubernetes.core.kubeconfig:
|
||||||
|
path: /home/user/.kube/config
|
||||||
|
clusters:
|
||||||
|
- name: old-cluster
|
||||||
|
behavior: remove
|
||||||
|
users:
|
||||||
|
- name: old-user
|
||||||
|
behavior: remove
|
||||||
|
contexts:
|
||||||
|
- name: old-context
|
||||||
|
behavior: remove
|
||||||
|
|
||||||
|
- name: Switch the active context
|
||||||
|
kubernetes.core.kubeconfig:
|
||||||
|
path: /home/user/.kube/config
|
||||||
|
current_context: staging-admin
|
||||||
|
|
||||||
|
- name: Copy a kubeconfig to a new location with an additional cluster merged in
|
||||||
|
kubernetes.core.kubeconfig:
|
||||||
|
path: /home/user/.kube/config
|
||||||
|
dest: /home/user/.kube/config-ci
|
||||||
|
clusters:
|
||||||
|
- name: ci-cluster
|
||||||
|
cluster:
|
||||||
|
server: https://ci.k8s.example.com:6443
|
||||||
|
insecure-skip-tls-verify: true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Return Values
|
||||||
|
-------------
|
||||||
|
Common return values are documented `here <https://docs.ansible.com/projects/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
|
||||||
|
|
||||||
|
.. 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>dest</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>The path where the kubeconfig was written.</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;">/home/user/.kube/config</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="return-"></div>
|
||||||
|
<b>kubeconfig</b>
|
||||||
|
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
||||||
|
<div style="font-size: small">
|
||||||
|
<span style="color: purple">dictionary</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>always</td>
|
||||||
|
<td>
|
||||||
|
<div>The complete kubeconfig data structure.</div>
|
||||||
|
<br/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br/><br/>
|
||||||
|
|
||||||
|
|
||||||
|
Status
|
||||||
|
------
|
||||||
|
|
||||||
|
|
||||||
|
Authors
|
||||||
|
~~~~~~~
|
||||||
|
|
||||||
|
- Youssef Khalid Ali (@YoussefKhalidAli)
|
||||||
@@ -95,6 +95,26 @@ Parameters
|
|||||||
<div>Enable the helm chart inflation generator</div>
|
<div>Enable the helm chart inflation generator</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="1">
|
||||||
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
|
<b>environment</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 6.2.0</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<b>Default:</b><br/><div style="color: blue">{}</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div>The environment variables to pass to the kustomize or kubectl command.</div>
|
||||||
|
<div>This can be a dictionary or a string in the format key=value, multiple pairs separated by space.</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1">
|
<td colspan="1">
|
||||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||||
@@ -145,6 +165,14 @@ Examples
|
|||||||
kubernetes.core.k8s:
|
kubernetes.core.k8s:
|
||||||
definition: "{{ lookup('kubernetes.core.kustomize', dir='/path/to/kustomization', enable_helm=True) }}"
|
definition: "{{ lookup('kubernetes.core.kustomize', dir='/path/to/kustomization', enable_helm=True) }}"
|
||||||
|
|
||||||
|
- name: Create kubernetes resources for lookup output with environment variables in string format
|
||||||
|
kubernetes.core.k8s:
|
||||||
|
definition: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kubectl', environment='HTTP_PROXY=http://proxy.example.com:3128') }}"
|
||||||
|
|
||||||
|
- name: Create kubernetes resources for lookup output with environment variables in dict format
|
||||||
|
kubernetes.core.k8s:
|
||||||
|
definition: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kubectl', environment={'HTTP_PROXY': 'http://proxy.example.com:3128'}) }}"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Return Values
|
Return Values
|
||||||
|
|||||||
+1
-1
@@ -25,7 +25,7 @@ tags:
|
|||||||
- openshift
|
- openshift
|
||||||
- okd
|
- okd
|
||||||
- cluster
|
- cluster
|
||||||
version: 5.5.0
|
version: 7.0.0-dev0
|
||||||
build_ignore:
|
build_ignore:
|
||||||
- .DS_Store
|
- .DS_Store
|
||||||
- "*.tar.gz"
|
- "*.tar.gz"
|
||||||
|
|||||||
+10
-3
@@ -1,10 +1,17 @@
|
|||||||
---
|
---
|
||||||
requires_ansible: '>=2.16.0'
|
requires_ansible: '>=2.16.0'
|
||||||
|
|
||||||
|
# Only modules that accept the shared authentication options belong in these
|
||||||
|
# groups: HELM_AUTH_ARG_SPEC for helm, AUTH_ARG_SPEC for k8s. Adding a module
|
||||||
|
# that does not accept them makes module_defaults fail for every user of the
|
||||||
|
# group. This excludes helm_pull, helm_registry_auth, helm_template and
|
||||||
|
# kubeconfig, which only take a subset (or none) of those options.
|
||||||
action_groups:
|
action_groups:
|
||||||
helm:
|
helm:
|
||||||
- helm
|
- helm
|
||||||
- helm_info
|
- helm_info
|
||||||
|
- helm_plugin
|
||||||
|
- helm_plugin_info
|
||||||
- helm_repository
|
- helm_repository
|
||||||
k8s:
|
k8s:
|
||||||
- k8s
|
- k8s
|
||||||
@@ -18,17 +25,17 @@ action_groups:
|
|||||||
- k8s_rollback
|
- k8s_rollback
|
||||||
- k8s_scale
|
- k8s_scale
|
||||||
- k8s_service
|
- k8s_service
|
||||||
|
- k8s_taint
|
||||||
|
|
||||||
plugin_routing:
|
plugin_routing:
|
||||||
inventory:
|
inventory:
|
||||||
openshift:
|
openshift:
|
||||||
redirect: community.okd.openshift
|
redirect: community.okd.openshift
|
||||||
k8s:
|
k8s:
|
||||||
deprecation:
|
tombstone:
|
||||||
removal_version: 6.0.0
|
removal_version: 6.0.0
|
||||||
warning_text: >-
|
warning_text: >-
|
||||||
The k8s inventory plugin has been deprecated and
|
The k8s inventory plugin was slated for deprecation in 3.3.0 and has been removed in release 6.0.0. Use kubernetes.core.k8s_info and ansible.builtin.add_host instead.
|
||||||
will be removed in release 6.0.0.
|
|
||||||
modules:
|
modules:
|
||||||
k8s_auth:
|
k8s_auth:
|
||||||
redirect: community.okd.k8s_auth
|
redirect: community.okd.k8s_auth
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ from ansible.errors import (
|
|||||||
AnsibleError,
|
AnsibleError,
|
||||||
AnsibleFileNotFound,
|
AnsibleFileNotFound,
|
||||||
)
|
)
|
||||||
from ansible.module_utils._text import to_bytes, to_native, to_text
|
from ansible.module_utils.common.text.converters 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.plugins.action import ActionBase
|
from ansible.plugins.action import ActionBase
|
||||||
|
|
||||||
|
|||||||
@@ -228,13 +228,13 @@ EXAMPLES = r"""
|
|||||||
gather_facts: no
|
gather_facts: no
|
||||||
vars:
|
vars:
|
||||||
kubeconfig: /root/.kube/config
|
kubeconfig: /root/.kube/config
|
||||||
namespace: my-namespace
|
k8s_namespace: my-namespace
|
||||||
my_app: my-app
|
my_app: my-app
|
||||||
tasks:
|
tasks:
|
||||||
- name: Get My App pod info based on label
|
- name: Get My App pod info based on label
|
||||||
kubernetes.core.k8s_info:
|
kubernetes.core.k8s_info:
|
||||||
kubeconfig: "{{ kubeconfig }}"
|
kubeconfig: "{{ kubeconfig }}"
|
||||||
namespace: "{{ namespace }}"
|
namespace: "{{ k8s_namespace }}"
|
||||||
kind: Pod
|
kind: Pod
|
||||||
label_selectors: app.kubernetes.io/name = "{{ my_app }}"
|
label_selectors: app.kubernetes.io/name = "{{ my_app }}"
|
||||||
register: my_app_pod
|
register: my_app_pod
|
||||||
@@ -249,7 +249,7 @@ EXAMPLES = r"""
|
|||||||
ansible_connection: kubernetes.core.kubectl
|
ansible_connection: kubernetes.core.kubectl
|
||||||
ansible_kubectl_kubeconfig: "{{ kubeconfig }}"
|
ansible_kubectl_kubeconfig: "{{ kubeconfig }}"
|
||||||
ansible_kubectl_pod: "{{ my_app_pod_name }}"
|
ansible_kubectl_pod: "{{ my_app_pod_name }}"
|
||||||
ansible_kubectl_namespace: "{{ namespace }}"
|
ansible_kubectl_namespace: "{{ k8s_namespace }}"
|
||||||
|
|
||||||
- name: Run a command in My App pod
|
- name: Run a command in My App pod
|
||||||
# be aware that the command is executed as the user that started the container
|
# be aware that the command is executed as the user that started the container
|
||||||
@@ -268,7 +268,7 @@ import tempfile
|
|||||||
from shlex import quote as shlex_quote
|
from shlex import quote as shlex_quote
|
||||||
|
|
||||||
from ansible.errors import AnsibleError, AnsibleFileNotFound
|
from ansible.errors import AnsibleError, AnsibleFileNotFound
|
||||||
from ansible.module_utils._text import to_bytes
|
from ansible.module_utils.common.text.converters import to_bytes
|
||||||
from ansible.module_utils.parsing.convert_bool import boolean
|
from ansible.module_utils.parsing.convert_bool import boolean
|
||||||
from ansible.parsing.yaml.loader import AnsibleLoader
|
from ansible.parsing.yaml.loader import AnsibleLoader
|
||||||
from ansible.plugins.connection import BUFSIZE, ConnectionBase
|
from ansible.plugins.connection import BUFSIZE, ConnectionBase
|
||||||
|
|||||||
@@ -16,9 +16,8 @@ options:
|
|||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- Determines if an object should be created, patched, or deleted. When set to C(present), an object will be
|
- Determines if an object should be created, patched, or deleted. When set to C(present), an object will be
|
||||||
created, if it does not already exist. If set to C(absent), an existing object will be deleted. If set to
|
created if it does not already exist, and an existing object will be patched if its attributes differ from
|
||||||
C(present), an existing object will be patched, if its attributes differ from those specified using
|
those specified using I(resource_definition) or I(src). If set to C(absent), an existing object will be deleted.
|
||||||
I(resource_definition) or I(src).
|
|
||||||
type: str
|
type: str
|
||||||
default: present
|
default: present
|
||||||
choices: [ absent, present ]
|
choices: [ absent, present ]
|
||||||
|
|||||||
@@ -1,476 +0,0 @@
|
|||||||
# Copyright (c) 2018 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 = """
|
|
||||||
name: k8s
|
|
||||||
author:
|
|
||||||
- Chris Houseknecht (@chouseknecht)
|
|
||||||
- Fabian von Feilitzsch (@fabianvf)
|
|
||||||
|
|
||||||
short_description: Kubernetes (K8s) inventory source
|
|
||||||
|
|
||||||
description:
|
|
||||||
- Fetch containers and services for one or more clusters.
|
|
||||||
- Groups by cluster name, namespace, namespace_services, namespace_pods, and labels.
|
|
||||||
- Uses the kubectl connection plugin to access the Kubernetes cluster.
|
|
||||||
- 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:
|
|
||||||
plugin:
|
|
||||||
description: token that ensures this is a source file for the 'k8s' plugin.
|
|
||||||
required: True
|
|
||||||
choices: ['kubernetes.core.k8s', 'k8s', 'community.kubernetes.k8s']
|
|
||||||
connections:
|
|
||||||
description:
|
|
||||||
- Optional list of cluster connection settings. If no connections are provided, the default
|
|
||||||
I(~/.kube/config) and active context will be used, and objects will be returned for all namespaces
|
|
||||||
the active user is authorized to access.
|
|
||||||
suboptions:
|
|
||||||
name:
|
|
||||||
description:
|
|
||||||
- Optional name to assign to the cluster. If not provided, a name is constructed from the server
|
|
||||||
and port.
|
|
||||||
kubeconfig:
|
|
||||||
description:
|
|
||||||
- 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 I(~/.kube/config). Can also be specified via K8S_AUTH_KUBECONFIG
|
|
||||||
environment variable.
|
|
||||||
context:
|
|
||||||
description:
|
|
||||||
- The name of a context found in the config file. Can also be specified via K8S_AUTH_CONTEXT environment
|
|
||||||
variable.
|
|
||||||
host:
|
|
||||||
description:
|
|
||||||
- Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.
|
|
||||||
api_key:
|
|
||||||
description:
|
|
||||||
- Token used to authenticate with the API. Can also be specified via K8S_AUTH_API_KEY environment
|
|
||||||
variable.
|
|
||||||
username:
|
|
||||||
description:
|
|
||||||
- Provide a username for authenticating with the API. Can also be specified via K8S_AUTH_USERNAME
|
|
||||||
environment variable.
|
|
||||||
password:
|
|
||||||
description:
|
|
||||||
- Provide a password for authenticating with the API. Can also be specified via K8S_AUTH_PASSWORD
|
|
||||||
environment variable.
|
|
||||||
client_cert:
|
|
||||||
description:
|
|
||||||
- Path to a certificate used to authenticate with the API. Can also be specified via K8S_AUTH_CERT_FILE
|
|
||||||
environment variable.
|
|
||||||
aliases: [ cert_file ]
|
|
||||||
client_key:
|
|
||||||
description:
|
|
||||||
- Path to a key file used to authenticate with the API. Can also be specified via K8S_AUTH_KEY_FILE
|
|
||||||
environment variable.
|
|
||||||
aliases: [ key_file ]
|
|
||||||
ca_cert:
|
|
||||||
description:
|
|
||||||
- Path to a CA certificate used to authenticate with the API. Can also be specified via
|
|
||||||
K8S_AUTH_SSL_CA_CERT environment variable.
|
|
||||||
aliases: [ ssl_ca_cert ]
|
|
||||||
validate_certs:
|
|
||||||
description:
|
|
||||||
- "Whether or not to verify the API server's SSL certificates. Can also be specified via
|
|
||||||
K8S_AUTH_VERIFY_SSL environment variable."
|
|
||||||
type: bool
|
|
||||||
aliases: [ verify_ssl ]
|
|
||||||
namespaces:
|
|
||||||
description:
|
|
||||||
- List of namespaces. If not specified, will fetch all containers for all namespaces user is authorized
|
|
||||||
to access.
|
|
||||||
|
|
||||||
requirements:
|
|
||||||
- "python >= 3.9"
|
|
||||||
- "kubernetes >= 24.2.0"
|
|
||||||
- "PyYAML >= 3.11"
|
|
||||||
"""
|
|
||||||
|
|
||||||
EXAMPLES = r"""
|
|
||||||
# File must be named k8s.yaml or k8s.yml
|
|
||||||
|
|
||||||
- name: Authenticate with token, and return all pods and services for all namespaces
|
|
||||||
plugin: kubernetes.core.k8s
|
|
||||||
connections:
|
|
||||||
- host: https://192.168.64.4:8443
|
|
||||||
api_key: xxxxxxxxxxxxxxxx
|
|
||||||
validate_certs: false
|
|
||||||
|
|
||||||
- name: Use default config (~/.kube/config) file and active context, and return objects for a specific namespace
|
|
||||||
plugin: kubernetes.core.k8s
|
|
||||||
connections:
|
|
||||||
- namespaces:
|
|
||||||
- testing
|
|
||||||
|
|
||||||
- name: Use a custom config file, and a specific context.
|
|
||||||
plugin: kubernetes.core.k8s
|
|
||||||
connections:
|
|
||||||
- kubeconfig: /path/to/config
|
|
||||||
context: 'awx/192-168-64-4:8443/developer'
|
|
||||||
"""
|
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
from ansible.errors import AnsibleError
|
|
||||||
from ansible.plugins.inventory import BaseInventoryPlugin, Cacheable, Constructable
|
|
||||||
|
|
||||||
try:
|
|
||||||
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 (
|
|
||||||
get_api_client,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
|
|
||||||
class K8sInventoryException(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
|
||||||
NAME = "kubernetes.core.k8s"
|
|
||||||
|
|
||||||
connection_plugin = "kubernetes.core.kubectl"
|
|
||||||
transport = "kubectl"
|
|
||||||
|
|
||||||
def parse(self, inventory, loader, path, cache=True):
|
|
||||||
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)
|
|
||||||
config_data = self._read_config_data(path)
|
|
||||||
self.setup(config_data, cache, cache_key)
|
|
||||||
|
|
||||||
def setup(self, config_data, cache, cache_key):
|
|
||||||
connections = config_data.get("connections")
|
|
||||||
|
|
||||||
if not HAS_K8S_MODULE_HELPER:
|
|
||||||
raise K8sInventoryException(
|
|
||||||
"This module requires the Kubernetes Python client. Try `pip install kubernetes`. Detail: {0}".format(
|
|
||||||
k8s_import_exception
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
source_data = None
|
|
||||||
if cache and cache_key in self._cache:
|
|
||||||
try:
|
|
||||||
source_data = self._cache[cache_key]
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if not source_data:
|
|
||||||
self.fetch_objects(connections)
|
|
||||||
|
|
||||||
def fetch_objects(self, connections):
|
|
||||||
if connections:
|
|
||||||
if not isinstance(connections, list):
|
|
||||||
raise K8sInventoryException("Expecting connections to be a list.")
|
|
||||||
|
|
||||||
for connection in connections:
|
|
||||||
if not isinstance(connection, dict):
|
|
||||||
raise K8sInventoryException(
|
|
||||||
"Expecting connection to be a dictionary."
|
|
||||||
)
|
|
||||||
client = get_api_client(**connection)
|
|
||||||
name = connection.get(
|
|
||||||
"name", self.get_default_host_name(client.configuration.host)
|
|
||||||
)
|
|
||||||
if connection.get("namespaces"):
|
|
||||||
namespaces = connection["namespaces"]
|
|
||||||
else:
|
|
||||||
namespaces = self.get_available_namespaces(client)
|
|
||||||
for namespace in namespaces:
|
|
||||||
self.get_pods_for_namespace(client, name, namespace)
|
|
||||||
self.get_services_for_namespace(client, name, namespace)
|
|
||||||
else:
|
|
||||||
client = get_api_client()
|
|
||||||
name = self.get_default_host_name(client.configuration.host)
|
|
||||||
namespaces = self.get_available_namespaces(client)
|
|
||||||
for namespace in namespaces:
|
|
||||||
self.get_pods_for_namespace(client, name, namespace)
|
|
||||||
self.get_services_for_namespace(client, name, namespace)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_default_host_name(host):
|
|
||||||
return (
|
|
||||||
host.replace("https://", "")
|
|
||||||
.replace("http://", "")
|
|
||||||
.replace(".", "-")
|
|
||||||
.replace(":", "_")
|
|
||||||
)
|
|
||||||
|
|
||||||
def get_available_namespaces(self, client):
|
|
||||||
v1_namespace = client.resources.get(api_version="v1", kind="Namespace")
|
|
||||||
try:
|
|
||||||
obj = v1_namespace.get()
|
|
||||||
except DynamicApiError as exc:
|
|
||||||
self.display.debug(exc)
|
|
||||||
raise K8sInventoryException(
|
|
||||||
"Error fetching Namespace list: %s" % format_dynamic_api_exc(exc)
|
|
||||||
)
|
|
||||||
return [namespace.metadata.name for namespace in obj.items]
|
|
||||||
|
|
||||||
def get_pods_for_namespace(self, client, name, namespace):
|
|
||||||
v1_pod = client.resources.get(api_version="v1", kind="Pod")
|
|
||||||
try:
|
|
||||||
obj = v1_pod.get(namespace=namespace)
|
|
||||||
except DynamicApiError as exc:
|
|
||||||
self.display.debug(exc)
|
|
||||||
raise K8sInventoryException(
|
|
||||||
"Error fetching Pod list: %s" % format_dynamic_api_exc(exc)
|
|
||||||
)
|
|
||||||
|
|
||||||
namespace_group = "namespace_{0}".format(namespace)
|
|
||||||
namespace_pods_group = "{0}_pods".format(namespace_group)
|
|
||||||
|
|
||||||
self.inventory.add_group(name)
|
|
||||||
self.inventory.add_group(namespace_group)
|
|
||||||
self.inventory.add_child(name, namespace_group)
|
|
||||||
self.inventory.add_group(namespace_pods_group)
|
|
||||||
self.inventory.add_child(namespace_group, namespace_pods_group)
|
|
||||||
|
|
||||||
for pod in obj.items:
|
|
||||||
pod_name = pod.metadata.name
|
|
||||||
pod_groups = []
|
|
||||||
pod_annotations = (
|
|
||||||
{} if not pod.metadata.annotations else dict(pod.metadata.annotations)
|
|
||||||
)
|
|
||||||
|
|
||||||
if pod.metadata.labels:
|
|
||||||
# create a group for each label_value
|
|
||||||
for key, value in pod.metadata.labels:
|
|
||||||
group_name = "label_{0}_{1}".format(key, value)
|
|
||||||
if group_name not in pod_groups:
|
|
||||||
pod_groups.append(group_name)
|
|
||||||
self.inventory.add_group(group_name)
|
|
||||||
pod_labels = dict(pod.metadata.labels)
|
|
||||||
else:
|
|
||||||
pod_labels = {}
|
|
||||||
|
|
||||||
if not pod.status.containerStatuses:
|
|
||||||
continue
|
|
||||||
|
|
||||||
for container in pod.status.containerStatuses:
|
|
||||||
# add each pod_container to the namespace group, and to each label_value group
|
|
||||||
container_name = "{0}_{1}".format(pod.metadata.name, container.name)
|
|
||||||
self.inventory.add_host(container_name)
|
|
||||||
self.inventory.add_child(namespace_pods_group, container_name)
|
|
||||||
if pod_groups:
|
|
||||||
for group in pod_groups:
|
|
||||||
self.inventory.add_child(group, container_name)
|
|
||||||
|
|
||||||
# Add hostvars
|
|
||||||
self.inventory.set_variable(container_name, "object_type", "pod")
|
|
||||||
self.inventory.set_variable(container_name, "labels", pod_labels)
|
|
||||||
self.inventory.set_variable(
|
|
||||||
container_name, "annotations", pod_annotations
|
|
||||||
)
|
|
||||||
self.inventory.set_variable(
|
|
||||||
container_name, "cluster_name", pod.metadata.clusterName
|
|
||||||
)
|
|
||||||
self.inventory.set_variable(
|
|
||||||
container_name, "pod_node_name", pod.spec.nodeName
|
|
||||||
)
|
|
||||||
self.inventory.set_variable(container_name, "pod_name", pod.spec.name)
|
|
||||||
self.inventory.set_variable(
|
|
||||||
container_name, "pod_host_ip", pod.status.hostIP
|
|
||||||
)
|
|
||||||
self.inventory.set_variable(
|
|
||||||
container_name, "pod_phase", pod.status.phase
|
|
||||||
)
|
|
||||||
self.inventory.set_variable(container_name, "pod_ip", pod.status.podIP)
|
|
||||||
self.inventory.set_variable(
|
|
||||||
container_name, "pod_self_link", pod.metadata.selfLink
|
|
||||||
)
|
|
||||||
self.inventory.set_variable(
|
|
||||||
container_name, "pod_resource_version", pod.metadata.resourceVersion
|
|
||||||
)
|
|
||||||
self.inventory.set_variable(container_name, "pod_uid", pod.metadata.uid)
|
|
||||||
self.inventory.set_variable(
|
|
||||||
container_name, "container_name", container.image
|
|
||||||
)
|
|
||||||
self.inventory.set_variable(
|
|
||||||
container_name, "container_image", container.image
|
|
||||||
)
|
|
||||||
if container.state.running:
|
|
||||||
self.inventory.set_variable(
|
|
||||||
container_name, "container_state", "Running"
|
|
||||||
)
|
|
||||||
if container.state.terminated:
|
|
||||||
self.inventory.set_variable(
|
|
||||||
container_name, "container_state", "Terminated"
|
|
||||||
)
|
|
||||||
if container.state.waiting:
|
|
||||||
self.inventory.set_variable(
|
|
||||||
container_name, "container_state", "Waiting"
|
|
||||||
)
|
|
||||||
self.inventory.set_variable(
|
|
||||||
container_name, "container_ready", container.ready
|
|
||||||
)
|
|
||||||
self.inventory.set_variable(
|
|
||||||
container_name, "ansible_remote_tmp", "/tmp/"
|
|
||||||
)
|
|
||||||
self.inventory.set_variable(
|
|
||||||
container_name, "ansible_connection", self.connection_plugin
|
|
||||||
)
|
|
||||||
self.inventory.set_variable(
|
|
||||||
container_name, "ansible_{0}_pod".format(self.transport), pod_name
|
|
||||||
)
|
|
||||||
self.inventory.set_variable(
|
|
||||||
container_name,
|
|
||||||
"ansible_{0}_container".format(self.transport),
|
|
||||||
container.name,
|
|
||||||
)
|
|
||||||
self.inventory.set_variable(
|
|
||||||
container_name,
|
|
||||||
"ansible_{0}_namespace".format(self.transport),
|
|
||||||
namespace,
|
|
||||||
)
|
|
||||||
|
|
||||||
def get_services_for_namespace(self, client, name, namespace):
|
|
||||||
v1_service = client.resources.get(api_version="v1", kind="Service")
|
|
||||||
try:
|
|
||||||
obj = v1_service.get(namespace=namespace)
|
|
||||||
except DynamicApiError as exc:
|
|
||||||
self.display.debug(exc)
|
|
||||||
raise K8sInventoryException(
|
|
||||||
"Error fetching Service list: %s" % format_dynamic_api_exc(exc)
|
|
||||||
)
|
|
||||||
|
|
||||||
namespace_group = "namespace_{0}".format(namespace)
|
|
||||||
namespace_services_group = "{0}_services".format(namespace_group)
|
|
||||||
|
|
||||||
self.inventory.add_group(name)
|
|
||||||
self.inventory.add_group(namespace_group)
|
|
||||||
self.inventory.add_child(name, namespace_group)
|
|
||||||
self.inventory.add_group(namespace_services_group)
|
|
||||||
self.inventory.add_child(namespace_group, namespace_services_group)
|
|
||||||
|
|
||||||
for service in obj.items:
|
|
||||||
service_name = service.metadata.name
|
|
||||||
service_labels = (
|
|
||||||
{} if not service.metadata.labels else dict(service.metadata.labels)
|
|
||||||
)
|
|
||||||
service_annotations = (
|
|
||||||
{}
|
|
||||||
if not service.metadata.annotations
|
|
||||||
else dict(service.metadata.annotations)
|
|
||||||
)
|
|
||||||
|
|
||||||
self.inventory.add_host(service_name)
|
|
||||||
|
|
||||||
if service.metadata.labels:
|
|
||||||
# create a group for each label_value
|
|
||||||
for key, value in service.metadata.labels:
|
|
||||||
group_name = "label_{0}_{1}".format(key, value)
|
|
||||||
self.inventory.add_group(group_name)
|
|
||||||
self.inventory.add_child(group_name, service_name)
|
|
||||||
|
|
||||||
try:
|
|
||||||
self.inventory.add_child(namespace_services_group, service_name)
|
|
||||||
except AnsibleError:
|
|
||||||
raise
|
|
||||||
|
|
||||||
ports = [
|
|
||||||
{
|
|
||||||
"name": port.name,
|
|
||||||
"port": port.port,
|
|
||||||
"protocol": port.protocol,
|
|
||||||
"targetPort": port.targetPort,
|
|
||||||
"nodePort": port.nodePort,
|
|
||||||
}
|
|
||||||
for port in service.spec.ports or []
|
|
||||||
]
|
|
||||||
|
|
||||||
# add hostvars
|
|
||||||
self.inventory.set_variable(service_name, "object_type", "service")
|
|
||||||
self.inventory.set_variable(service_name, "labels", service_labels)
|
|
||||||
self.inventory.set_variable(
|
|
||||||
service_name, "annotations", service_annotations
|
|
||||||
)
|
|
||||||
self.inventory.set_variable(
|
|
||||||
service_name, "cluster_name", service.metadata.clusterName
|
|
||||||
)
|
|
||||||
self.inventory.set_variable(service_name, "ports", ports)
|
|
||||||
self.inventory.set_variable(service_name, "type", service.spec.type)
|
|
||||||
self.inventory.set_variable(
|
|
||||||
service_name, "self_link", service.metadata.selfLink
|
|
||||||
)
|
|
||||||
self.inventory.set_variable(
|
|
||||||
service_name, "resource_version", service.metadata.resourceVersion
|
|
||||||
)
|
|
||||||
self.inventory.set_variable(service_name, "uid", service.metadata.uid)
|
|
||||||
|
|
||||||
if service.spec.externalTrafficPolicy:
|
|
||||||
self.inventory.set_variable(
|
|
||||||
service_name,
|
|
||||||
"external_traffic_policy",
|
|
||||||
service.spec.externalTrafficPolicy,
|
|
||||||
)
|
|
||||||
if service.spec.externalIPs:
|
|
||||||
self.inventory.set_variable(
|
|
||||||
service_name, "external_ips", service.spec.externalIPs
|
|
||||||
)
|
|
||||||
|
|
||||||
if service.spec.externalName:
|
|
||||||
self.inventory.set_variable(
|
|
||||||
service_name, "external_name", service.spec.externalName
|
|
||||||
)
|
|
||||||
|
|
||||||
if service.spec.healthCheckNodePort:
|
|
||||||
self.inventory.set_variable(
|
|
||||||
service_name,
|
|
||||||
"health_check_node_port",
|
|
||||||
service.spec.healthCheckNodePort,
|
|
||||||
)
|
|
||||||
if service.spec.loadBalancerIP:
|
|
||||||
self.inventory.set_variable(
|
|
||||||
service_name, "load_balancer_ip", service.spec.loadBalancerIP
|
|
||||||
)
|
|
||||||
if service.spec.selector:
|
|
||||||
self.inventory.set_variable(
|
|
||||||
service_name, "selector", dict(service.spec.selector)
|
|
||||||
)
|
|
||||||
|
|
||||||
if (
|
|
||||||
hasattr(service.status.loadBalancer, "ingress")
|
|
||||||
and service.status.loadBalancer.ingress
|
|
||||||
):
|
|
||||||
load_balancer = [
|
|
||||||
{"hostname": ingress.hostname, "ip": ingress.ip}
|
|
||||||
for ingress in service.status.loadBalancer.ingress
|
|
||||||
]
|
|
||||||
self.inventory.set_variable(
|
|
||||||
service_name, "load_balancer", load_balancer
|
|
||||||
)
|
|
||||||
@@ -209,10 +209,10 @@ RETURN = """
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from collections.abc import KeysView
|
||||||
|
|
||||||
from ansible.errors import AnsibleError
|
from ansible.errors import AnsibleError
|
||||||
from ansible.module_utils.ansible_release import __version__ as ansible_version
|
from ansible.module_utils.ansible_release import __version__ as ansible_version
|
||||||
from ansible.module_utils.common._collections_compat import KeysView
|
|
||||||
from ansible.module_utils.common.validation import check_type_bool
|
from ansible.module_utils.common.validation import check_type_bool
|
||||||
from ansible.utils.display import Display
|
from ansible.utils.display import Display
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
|
||||||
|
|||||||
@@ -34,6 +34,13 @@ DOCUMENTATION = """
|
|||||||
description:
|
description:
|
||||||
- Enable the helm chart inflation generator
|
- Enable the helm chart inflation generator
|
||||||
default: "False"
|
default: "False"
|
||||||
|
environment:
|
||||||
|
description:
|
||||||
|
- The environment variables to pass to the kustomize or kubectl command.
|
||||||
|
- This can be a dictionary or a string in the format key=value, multiple pairs separated by space.
|
||||||
|
type: raw
|
||||||
|
default: {}
|
||||||
|
version_added: 6.2.0
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "python >= 3.6"
|
- "python >= 3.6"
|
||||||
@@ -55,6 +62,14 @@ EXAMPLES = """
|
|||||||
- name: Create kubernetes resources for lookup output with `--enable-helm` set
|
- name: Create kubernetes resources for lookup output with `--enable-helm` set
|
||||||
kubernetes.core.k8s:
|
kubernetes.core.k8s:
|
||||||
definition: "{{ lookup('kubernetes.core.kustomize', dir='/path/to/kustomization', enable_helm=True) }}"
|
definition: "{{ lookup('kubernetes.core.kustomize', dir='/path/to/kustomization', enable_helm=True) }}"
|
||||||
|
|
||||||
|
- name: Create kubernetes resources for lookup output with environment variables in string format
|
||||||
|
kubernetes.core.k8s:
|
||||||
|
definition: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kubectl', environment='HTTP_PROXY=http://proxy.example.com:3128') }}"
|
||||||
|
|
||||||
|
- name: Create kubernetes resources for lookup output with environment variables in dict format
|
||||||
|
kubernetes.core.k8s:
|
||||||
|
definition: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kubectl', environment={'HTTP_PROXY': 'http://proxy.example.com:3128'}) }}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
@@ -72,6 +87,7 @@ RETURN = """
|
|||||||
key1: val1
|
key1: val1
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from ansible.errors import AnsibleLookupError
|
from ansible.errors import AnsibleLookupError
|
||||||
@@ -92,8 +108,10 @@ def get_binary_from_path(name, opt_dirs=None):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def run_command(command):
|
def run_command(command, environ=None):
|
||||||
cmd = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
cmd = subprocess.Popen(
|
||||||
|
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=environ
|
||||||
|
)
|
||||||
stdout, stderr = cmd.communicate()
|
stdout, stderr = cmd.communicate()
|
||||||
return cmd.returncode, stdout, stderr
|
return cmd.returncode, stdout, stderr
|
||||||
|
|
||||||
@@ -107,6 +125,7 @@ class LookupModule(LookupBase):
|
|||||||
binary_path=None,
|
binary_path=None,
|
||||||
opt_dirs=None,
|
opt_dirs=None,
|
||||||
enable_helm=False,
|
enable_helm=False,
|
||||||
|
environment=None,
|
||||||
**kwargs
|
**kwargs
|
||||||
):
|
):
|
||||||
executable_path = binary_path
|
executable_path = binary_path
|
||||||
@@ -141,7 +160,21 @@ class LookupModule(LookupBase):
|
|||||||
if enable_helm:
|
if enable_helm:
|
||||||
command += ["--enable-helm"]
|
command += ["--enable-helm"]
|
||||||
|
|
||||||
(ret, out, err) = run_command(command)
|
environ = None
|
||||||
|
if environment:
|
||||||
|
environ = os.environ.copy()
|
||||||
|
if isinstance(environment, str):
|
||||||
|
if not all(env.count("=") == 1 for env in environment.split(" ")):
|
||||||
|
raise AnsibleLookupError(
|
||||||
|
"environment should be dict or string in the format key=value, multiple pairs separated by space"
|
||||||
|
)
|
||||||
|
for env in environment.split(" "):
|
||||||
|
key, value = env.split("=")
|
||||||
|
environ[key] = value
|
||||||
|
if isinstance(environment, dict):
|
||||||
|
environ.update(environment)
|
||||||
|
|
||||||
|
(ret, out, err) = run_command(command, environ=environ)
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
if err:
|
if err:
|
||||||
raise AnsibleLookupError(
|
raise AnsibleLookupError(
|
||||||
|
|||||||
@@ -144,3 +144,18 @@ DELETE_OPTS_ARG_SPEC = {
|
|||||||
"options": {"resourceVersion": {"type": "str"}, "uid": {"type": "str"}},
|
"options": {"resourceVersion": {"type": "str"}, "uid": {"type": "str"}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
METADATA_ONLY_HEADERS_SPEC = {
|
||||||
|
"accept": {"type": "str"},
|
||||||
|
}
|
||||||
|
|
||||||
|
METADATA_ONLY_HEADER_VALUES = {
|
||||||
|
"partial_object": (
|
||||||
|
"application/json;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,"
|
||||||
|
"application/json;q=0.9"
|
||||||
|
),
|
||||||
|
"partial_object_list": (
|
||||||
|
"application/json;as=PartialObjectMetadataList;g=meta.k8s.io;v=v1,"
|
||||||
|
"application/json;q=0.9"
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import base64
|
|||||||
import os
|
import os
|
||||||
from tempfile import NamedTemporaryFile
|
from tempfile import NamedTemporaryFile
|
||||||
|
|
||||||
from ansible.module_utils._text import to_bytes, to_native, to_text
|
from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text
|
||||||
from ansible.module_utils.urls import Request
|
from ansible.module_utils.urls import Request
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
+179
-54
@@ -18,12 +18,14 @@ from __future__ import absolute_import, division, print_function
|
|||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import shlex
|
||||||
import tarfile
|
import tarfile
|
||||||
|
import time
|
||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
from select import select
|
from select import select
|
||||||
from tempfile import NamedTemporaryFile, TemporaryFile
|
from tempfile import NamedTemporaryFile, TemporaryFile
|
||||||
|
|
||||||
from ansible.module_utils._text import to_native
|
from ansible.module_utils.common.text.converters 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 (
|
||||||
@@ -296,14 +298,156 @@ class K8SCopyToPod(K8SCopy):
|
|||||||
Copy files/directory from local filesystem into remote Pod
|
Copy files/directory from local filesystem into remote Pod
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Size of the chunks the tar archive is written to stdin with.
|
||||||
|
CHUNK_SIZE = 1024 * 1024
|
||||||
|
SHELL = "/bin/sh"
|
||||||
|
|
||||||
def __init__(self, module, client):
|
def __init__(self, module, client):
|
||||||
super(K8SCopyToPod, self).__init__(module, client)
|
super(K8SCopyToPod, self).__init__(module, client)
|
||||||
self.files_to_copy = list()
|
self.files_to_copy = list()
|
||||||
|
self.named_temp_file = None
|
||||||
|
self.copy_timeout = module.params.get("copy_timeout")
|
||||||
|
|
||||||
def close_temp_file(self):
|
def close_temp_file(self):
|
||||||
if self.named_temp_file:
|
if self.named_temp_file:
|
||||||
self.named_temp_file.close()
|
self.named_temp_file.close()
|
||||||
|
|
||||||
|
def _fail(self, response, msg, stderr=(), **kwargs):
|
||||||
|
"""Fail, keeping whatever the remote already wrote to stderr.
|
||||||
|
|
||||||
|
An early close or a stall is usually the symptom, not the cause: tar
|
||||||
|
has typically said why on stderr first.
|
||||||
|
"""
|
||||||
|
if stderr:
|
||||||
|
msg = "{0}: {1}".format(msg, "".join(stderr))
|
||||||
|
response.close()
|
||||||
|
self.close_temp_file()
|
||||||
|
self.module.fail_json(
|
||||||
|
msg="Failed to copy local file/directory into Pod: {0}".format(msg),
|
||||||
|
**kwargs,
|
||||||
|
)
|
||||||
|
|
||||||
|
def tar_command(self, dest_file):
|
||||||
|
if self.no_preserve:
|
||||||
|
command = [
|
||||||
|
"tar",
|
||||||
|
"--no-same-permissions",
|
||||||
|
"--no-same-owner",
|
||||||
|
"-xmf",
|
||||||
|
"-",
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
command = ["tar", "-xmf", "-"]
|
||||||
|
|
||||||
|
if dest_file.startswith("/"):
|
||||||
|
command.extend(["-C", "/"])
|
||||||
|
return command
|
||||||
|
|
||||||
|
def can_bound_stream(self):
|
||||||
|
"""Whether the container can run ``sh -c 'head -c ...'``."""
|
||||||
|
error, _out, _err = self._run_from_pod(
|
||||||
|
cmd=[self.SHELL, "-c", "command -v head"]
|
||||||
|
)
|
||||||
|
return (error or {}).get("status") == "Success"
|
||||||
|
|
||||||
|
def remote_command(self, dest_file, archive_size):
|
||||||
|
"""Build the command that extracts the archive inside the container.
|
||||||
|
|
||||||
|
The websocket exec protocol the kubernetes client speaks (v4) cannot
|
||||||
|
half-close stdin, so the only EOF the remote process can get is the
|
||||||
|
connection going away. Relying on that races with tar finishing and
|
||||||
|
truncates the file (issue #776), and tar cannot be relied on to stop at
|
||||||
|
the end-of-archive marker either -- busybox tar blocks for EOF.
|
||||||
|
|
||||||
|
Piping through ``head -c`` bounds the stream at the exact archive size,
|
||||||
|
so tar sees a clean EOF, exits on its own, and the API server reports
|
||||||
|
its exit status on the error channel. Only where the container has no
|
||||||
|
shell do we fall back to feeding tar directly, which cannot confirm
|
||||||
|
that the copy completed.
|
||||||
|
"""
|
||||||
|
command = self.tar_command(dest_file)
|
||||||
|
if not self.can_bound_stream():
|
||||||
|
self.module.warn(
|
||||||
|
"Container has no '{0}' with 'head', falling back to writing the"
|
||||||
|
" archive straight to tar. The module cannot confirm the copy"
|
||||||
|
" completed; verify the file after copying.".format(self.SHELL)
|
||||||
|
)
|
||||||
|
return command, False
|
||||||
|
|
||||||
|
return [
|
||||||
|
self.SHELL,
|
||||||
|
"-c",
|
||||||
|
"head -c {0} | {1}".format(
|
||||||
|
archive_size, " ".join(shlex.quote(arg) for arg in command)
|
||||||
|
),
|
||||||
|
], True
|
||||||
|
|
||||||
|
def _stream_tar_to_pod(self, response, tar_buffer, wait_for_exit):
|
||||||
|
"""Feed the archive to the remote extractor and wait for it to finish.
|
||||||
|
|
||||||
|
Writing the last chunk only hands the bytes to the local socket; they
|
||||||
|
still have to cross the API server and reach the container. Closing the
|
||||||
|
connection at that point kills the extractor mid-write and silently
|
||||||
|
truncates the file, which is what issue #776 reports.
|
||||||
|
"""
|
||||||
|
stdout, stderr = [], []
|
||||||
|
|
||||||
|
def drain(timeout):
|
||||||
|
response.update(timeout=timeout)
|
||||||
|
if response.peek_stdout():
|
||||||
|
stdout.append(response.read_stdout().rstrip("\n"))
|
||||||
|
if response.peek_stderr():
|
||||||
|
stderr.append(response.read_stderr().rstrip("\n"))
|
||||||
|
|
||||||
|
deadline = time.monotonic() + self.copy_timeout
|
||||||
|
|
||||||
|
chunk = tar_buffer.read(self.CHUNK_SIZE)
|
||||||
|
while chunk:
|
||||||
|
if not response.is_open():
|
||||||
|
self._fail(
|
||||||
|
response,
|
||||||
|
"connection to Pod {0}/{1} closed before the whole archive was"
|
||||||
|
" sent, the remote file is incomplete".format(
|
||||||
|
self.namespace, self.name
|
||||||
|
),
|
||||||
|
stderr,
|
||||||
|
)
|
||||||
|
if time.monotonic() > deadline:
|
||||||
|
self._fail(
|
||||||
|
response,
|
||||||
|
"timed out after {0}s sending the archive to Pod {1}/{2}".format(
|
||||||
|
self.copy_timeout, self.namespace, self.name
|
||||||
|
),
|
||||||
|
stderr,
|
||||||
|
)
|
||||||
|
# Non-blocking, keeps the receive buffer clear while we write.
|
||||||
|
drain(0)
|
||||||
|
response.write_stdin(chunk)
|
||||||
|
chunk = tar_buffer.read(self.CHUNK_SIZE)
|
||||||
|
|
||||||
|
if not wait_for_exit:
|
||||||
|
# No way to make the extractor exit, so no status to collect: read
|
||||||
|
# whatever it has already said and close, as the module always did.
|
||||||
|
drain(0)
|
||||||
|
response.close()
|
||||||
|
return None, stdout, stderr
|
||||||
|
|
||||||
|
# The archive is on the wire; wait for the extractor to consume it,
|
||||||
|
# exit, and have its status reported on the error channel.
|
||||||
|
while response.is_open():
|
||||||
|
if time.monotonic() > deadline:
|
||||||
|
self._fail(
|
||||||
|
response,
|
||||||
|
"timed out after {0}s waiting for tar to finish extracting on Pod"
|
||||||
|
" {1}/{2}".format(self.copy_timeout, self.namespace, self.name),
|
||||||
|
stderr,
|
||||||
|
)
|
||||||
|
drain(1)
|
||||||
|
|
||||||
|
error = yaml.safe_load(response.read_channel(ERROR_CHANNEL)) or {}
|
||||||
|
response.close()
|
||||||
|
return error, stdout, stderr
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
# remove trailing slash from destination path
|
# remove trailing slash from destination path
|
||||||
dest_file = self.remote_path.rstrip("/")
|
dest_file = self.remote_path.rstrip("/")
|
||||||
@@ -336,65 +480,46 @@ class K8SCopyToPod(K8SCopy):
|
|||||||
dest_file = os.path.join(dest_file, os.path.basename(src_file))
|
dest_file = os.path.join(dest_file, os.path.basename(src_file))
|
||||||
|
|
||||||
if not self.check_mode:
|
if not self.check_mode:
|
||||||
if self.no_preserve:
|
|
||||||
tar_command = [
|
|
||||||
"tar",
|
|
||||||
"--no-same-permissions",
|
|
||||||
"--no-same-owner",
|
|
||||||
"-xmf",
|
|
||||||
"-",
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
tar_command = ["tar", "-xmf", "-"]
|
|
||||||
|
|
||||||
if dest_file.startswith("/"):
|
|
||||||
tar_command.extend(["-C", "/"])
|
|
||||||
|
|
||||||
response = stream(
|
|
||||||
self.api_instance.connect_get_namespaced_pod_exec,
|
|
||||||
self.name,
|
|
||||||
self.namespace,
|
|
||||||
command=tar_command,
|
|
||||||
stderr=True,
|
|
||||||
stdin=True,
|
|
||||||
stdout=True,
|
|
||||||
tty=False,
|
|
||||||
_preload_content=False,
|
|
||||||
**self.container_arg,
|
|
||||||
)
|
|
||||||
with TemporaryFile() as tar_buffer:
|
with TemporaryFile() as tar_buffer:
|
||||||
|
# Build the archive first: bounding the remote read needs its
|
||||||
|
# exact size.
|
||||||
with tarfile.open(fileobj=tar_buffer, mode="w") as tar:
|
with tarfile.open(fileobj=tar_buffer, mode="w") as tar:
|
||||||
tar.add(src_file, dest_file)
|
tar.add(src_file, dest_file)
|
||||||
|
archive_size = tar_buffer.tell()
|
||||||
tar_buffer.seek(0)
|
tar_buffer.seek(0)
|
||||||
commands = []
|
|
||||||
# push command in chunk mode
|
|
||||||
size = 1024 * 1024
|
|
||||||
while True:
|
|
||||||
data = tar_buffer.read(size)
|
|
||||||
if not data:
|
|
||||||
break
|
|
||||||
commands.append(data)
|
|
||||||
|
|
||||||
stderr, stdout = [], []
|
command, wait_for_exit = self.remote_command(dest_file, archive_size)
|
||||||
while response.is_open():
|
response = stream(
|
||||||
if response.peek_stdout():
|
self.api_instance.connect_get_namespaced_pod_exec,
|
||||||
stdout.append(response.read_stdout().rstrip("\n"))
|
self.name,
|
||||||
if response.peek_stderr():
|
self.namespace,
|
||||||
stderr.append(response.read_stderr().rstrip("\n"))
|
command=command,
|
||||||
if commands:
|
stderr=True,
|
||||||
cmd = commands.pop(0)
|
stdin=True,
|
||||||
response.write_stdin(cmd)
|
stdout=True,
|
||||||
else:
|
tty=False,
|
||||||
break
|
_preload_content=False,
|
||||||
response.close()
|
**self.container_arg,
|
||||||
if stderr:
|
)
|
||||||
self.close_temp_file()
|
error, stdout, stderr = self._stream_tar_to_pod(
|
||||||
self.module.fail_json(
|
response, tar_buffer, wait_for_exit
|
||||||
command=tar_command,
|
)
|
||||||
msg="Failed to copy local file/directory into Pod due to: {0}".format(
|
|
||||||
"".join(stderr)
|
if error is not None and error.get("status") != "Success":
|
||||||
),
|
self._fail(
|
||||||
|
response,
|
||||||
|
"".join(stderr) or error.get("message", "unknown error"),
|
||||||
|
command=command,
|
||||||
|
)
|
||||||
|
if error is None and stderr:
|
||||||
|
# Legacy path: no exit status to go on, so any output is fatal.
|
||||||
|
self._fail(response, "".join(stderr), command=command)
|
||||||
|
if stderr:
|
||||||
|
self.module.warn(
|
||||||
|
"tar wrote to stderr while extracting into Pod {0}/{1}: {2}".format(
|
||||||
|
self.namespace, self.name, "".join(stderr)
|
||||||
)
|
)
|
||||||
|
)
|
||||||
self.close_temp_file()
|
self.close_temp_file()
|
||||||
if self.content:
|
if self.content:
|
||||||
self.module.exit_json(
|
self.module.exit_json(
|
||||||
|
|||||||
@@ -32,6 +32,53 @@ except ImportError:
|
|||||||
HAS_YAML = False
|
HAS_YAML = False
|
||||||
|
|
||||||
|
|
||||||
|
# Helm's registry client writes these progress messages to stdout as of helm 4.2.1
|
||||||
|
# (helm/helm#32056); earlier versions sent them to stderr. Anything that parses the
|
||||||
|
# stdout of a helm command which may pull from an OCI registry has to skip them.
|
||||||
|
# Kept verbatim from helm's pkg/registry/client.go so that a reworded message fails
|
||||||
|
# to match, and therefore fails loudly, rather than silently eating real output.
|
||||||
|
REGISTRY_PROGRESS_RE = re.compile(r"^(?:Pulled|Pushed|Digest): \S")
|
||||||
|
|
||||||
|
REGISTRY_UNDERSCORE_SUFFIX = " contains an underscore.\n"
|
||||||
|
|
||||||
|
REGISTRY_UNDERSCORE_MESSAGE = """
|
||||||
|
OCI artifact references (e.g. tags) do not support the plus sign (+). To support
|
||||||
|
storing semantic versions, Helm adopts the convention of changing plus (+) to
|
||||||
|
an underscore (_) in chart version tags when pushing to a registry and back to
|
||||||
|
a plus (+) when pulling from a registry.
|
||||||
|
"""
|
||||||
|
|
||||||
|
REGISTRY_UNDERSCORE_MESSAGE_LINES = len(REGISTRY_UNDERSCORE_MESSAGE.splitlines())
|
||||||
|
|
||||||
|
|
||||||
|
def strip_registry_progress(out):
|
||||||
|
"""
|
||||||
|
Drop OCI registry progress messages from the front of a helm command's stdout.
|
||||||
|
|
||||||
|
Helm emits 'Pulled:'/'Pushed:' and 'Digest:' lines, followed - when the
|
||||||
|
reference contains an underscore - by a free-text explanation that is not
|
||||||
|
valid YAML. Since helm 4.2.1 these land on stdout ahead of the real output,
|
||||||
|
so 'helm show chart' can no longer be parsed and 'helm template' no longer
|
||||||
|
returns only rendered manifests.
|
||||||
|
"""
|
||||||
|
lines = out.splitlines(keepends=True)
|
||||||
|
index = 0
|
||||||
|
while index < len(lines):
|
||||||
|
if REGISTRY_PROGRESS_RE.match(lines[index]):
|
||||||
|
index += 1
|
||||||
|
elif lines[index].endswith(REGISTRY_UNDERSCORE_SUFFIX):
|
||||||
|
# helm prints its registryUnderscoreMessage right after this line, led
|
||||||
|
# by a blank line. Anything else is not a message we know about.
|
||||||
|
start = index + 1
|
||||||
|
end = start + REGISTRY_UNDERSCORE_MESSAGE_LINES
|
||||||
|
if "".join(lines[start:end]) != REGISTRY_UNDERSCORE_MESSAGE:
|
||||||
|
break
|
||||||
|
index = end
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
return "".join(lines[index:])
|
||||||
|
|
||||||
|
|
||||||
def parse_helm_plugin_list(output=None):
|
def parse_helm_plugin_list(output=None):
|
||||||
"""
|
"""
|
||||||
Parse `helm plugin list`, return list of plugins
|
Parse `helm plugin list`, return list of plugins
|
||||||
@@ -40,16 +87,20 @@ def parse_helm_plugin_list(output=None):
|
|||||||
if not output:
|
if not output:
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
parsing_grammar = None
|
||||||
for line in output:
|
for line in output:
|
||||||
if line.startswith("NAME"):
|
if line.startswith("NAME"):
|
||||||
|
parsing_grammar = [s.strip().lower() for s in line.split("\t")]
|
||||||
continue
|
continue
|
||||||
name, version, description = line.split("\t", 3)
|
if parsing_grammar is None:
|
||||||
name = name.strip()
|
|
||||||
version = version.strip()
|
|
||||||
description = description.strip()
|
|
||||||
if name == "":
|
|
||||||
continue
|
continue
|
||||||
ret.append((name, version, description))
|
plugin = {
|
||||||
|
parsing_grammar[i]: v.strip()
|
||||||
|
for i, v in enumerate(line.split("\t", len(parsing_grammar)))
|
||||||
|
}
|
||||||
|
if plugin["name"] == "":
|
||||||
|
continue
|
||||||
|
ret.append(plugin)
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@@ -202,21 +253,35 @@ class AnsibleHelmModule(object):
|
|||||||
return m.group(1)
|
return m.group(1)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def validate_helm_version(self):
|
def is_helm_v4(self):
|
||||||
|
helm_version = self.get_helm_version()
|
||||||
|
if helm_version is None:
|
||||||
|
return False
|
||||||
|
return LooseVersion(helm_version) >= LooseVersion("4.0.0")
|
||||||
|
|
||||||
|
def is_helm_version_compatible_with_helm_diff(self, helm_diff_version):
|
||||||
"""
|
"""
|
||||||
Validate that Helm version is >=3.0.0 and <4.0.0.
|
Return true if the helm version is compatible with the helm diff version
|
||||||
Helm 4 is not yet supported.
|
Helm v4 requires helm diff v3.14.0
|
||||||
|
"""
|
||||||
|
if not helm_diff_version:
|
||||||
|
return False
|
||||||
|
if self.is_helm_v4():
|
||||||
|
return LooseVersion(helm_diff_version) >= LooseVersion("3.14.0")
|
||||||
|
return True
|
||||||
|
|
||||||
|
def validate_helm_version(self, version="3.0.0"):
|
||||||
|
"""
|
||||||
|
Validate that Helm version is >= version (default version=3.0.0).
|
||||||
"""
|
"""
|
||||||
helm_version = self.get_helm_version()
|
helm_version = self.get_helm_version()
|
||||||
if helm_version is None:
|
if helm_version is None:
|
||||||
self.fail_json(msg="Unable to determine Helm version")
|
self.fail_json(msg="Unable to determine Helm version")
|
||||||
|
|
||||||
if (LooseVersion(helm_version) < LooseVersion("3.0.0")) or (
|
if LooseVersion(helm_version) < LooseVersion(version):
|
||||||
LooseVersion(helm_version) >= LooseVersion("4.0.0")
|
|
||||||
):
|
|
||||||
self.fail_json(
|
self.fail_json(
|
||||||
msg="Helm version must be >=3.0.0,<4.0.0, current version is {0}".format(
|
msg="Helm version must be >= {0}, current version is {1}".format(
|
||||||
helm_version
|
version, helm_version
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -181,6 +181,7 @@ def _create_headers(module=None, **kwargs):
|
|||||||
header_map = {
|
header_map = {
|
||||||
"impersonate_user": "Impersonate-User",
|
"impersonate_user": "Impersonate-User",
|
||||||
"impersonate_groups": "Impersonate-Group",
|
"impersonate_groups": "Impersonate-Group",
|
||||||
|
"accept": "Accept",
|
||||||
}
|
}
|
||||||
|
|
||||||
headers = {}
|
headers = {}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
from ansible.module_utils._text import to_native
|
from ansible.module_utils.common.text.converters 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,
|
||||||
)
|
)
|
||||||
@@ -92,10 +92,10 @@ def run_module(module) -> None:
|
|||||||
|
|
||||||
for definition in definitions:
|
for definition in definitions:
|
||||||
result = {"changed": False, "result": {}}
|
result = {"changed": False, "result": {}}
|
||||||
warnings = []
|
|
||||||
|
|
||||||
if module.params.get("validate") is not None:
|
if module.params.get("validate") is not None:
|
||||||
warnings = validate(client, module, definition)
|
for warning in validate(client, module, definition):
|
||||||
|
module.warn(warning)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = perform_action(svc, definition, module.params)
|
result = perform_action(svc, definition, module.params)
|
||||||
@@ -109,16 +109,12 @@ def run_module(module) -> None:
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
error["msg"] = to_native(e)
|
error["msg"] = to_native(e)
|
||||||
if warnings:
|
|
||||||
error.setdefault("warnings", []).extend(warnings)
|
|
||||||
|
|
||||||
if module.params.get("continue_on_error"):
|
if module.params.get("continue_on_error"):
|
||||||
result["error"] = error
|
result["error"] = error
|
||||||
else:
|
else:
|
||||||
module.fail_json(**error)
|
module.fail_json(**error)
|
||||||
|
|
||||||
if warnings:
|
|
||||||
result.setdefault("warnings", []).extend(warnings)
|
|
||||||
changed |= result["changed"]
|
changed |= result["changed"]
|
||||||
results.append(result)
|
results.append(result)
|
||||||
|
|
||||||
@@ -177,7 +173,7 @@ def perform_action(svc, definition: Dict, params: Dict) -> Dict:
|
|||||||
result["method"] = "apply"
|
result["method"] = "apply"
|
||||||
elif not existing:
|
elif not existing:
|
||||||
if state == "patched":
|
if state == "patched":
|
||||||
result.setdefault("warnings", []).append(
|
svc.module.warn(
|
||||||
"resource 'kind={kind},name={name}' was not found but will not be "
|
"resource 'kind={kind},name={name}' was not found but will not be "
|
||||||
"created as 'state' parameter has been set to '{state}'".format(
|
"created as 'state' parameter has been set to '{state}'".format(
|
||||||
kind=kind, name=definition["metadata"].get("name"), state=state
|
kind=kind, name=definition["metadata"].get("name"), state=state
|
||||||
@@ -194,8 +190,8 @@ def perform_action(svc, definition: Dict, params: Dict) -> Dict:
|
|||||||
instance, warnings = svc.update(resource, definition, existing)
|
instance, warnings = svc.update(resource, definition, existing)
|
||||||
result["method"] = "update"
|
result["method"] = "update"
|
||||||
|
|
||||||
if warnings:
|
for warning in warnings:
|
||||||
result["warnings"] = warnings
|
svc.module.warn(warning)
|
||||||
|
|
||||||
# If needed, wait and/or create diff
|
# If needed, wait and/or create diff
|
||||||
success = True
|
success = True
|
||||||
@@ -217,7 +213,7 @@ def perform_action(svc, definition: Dict, params: Dict) -> Dict:
|
|||||||
existing = {}
|
existing = {}
|
||||||
match, diffs = diff_objects(existing, instance, hidden_fields)
|
match, diffs = diff_objects(existing, instance, hidden_fields)
|
||||||
if match and diffs:
|
if match and diffs:
|
||||||
result.setdefault("warnings", []).append(
|
svc.module.warn(
|
||||||
"No meaningful diff was generated, but the API may not be idempotent "
|
"No meaningful diff was generated, but the API may not be idempotent "
|
||||||
"(only metadata.generation or metadata.resourceVersion were changed)"
|
"(only metadata.generation or metadata.resourceVersion were changed)"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -47,6 +47,18 @@ def pod_ready(pod: ResourceInstance) -> bool:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def job_complete(job: ResourceInstance) -> bool:
|
||||||
|
return bool(
|
||||||
|
job.status
|
||||||
|
and job.status.conditions
|
||||||
|
and any(
|
||||||
|
condition["type"] in ("Complete", "Failed")
|
||||||
|
and boolean(condition["status"], strict=False)
|
||||||
|
for condition in job.status.conditions
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def daemonset_ready(daemonset: ResourceInstance) -> bool:
|
def daemonset_ready(daemonset: ResourceInstance) -> bool:
|
||||||
return bool(
|
return bool(
|
||||||
daemonset.status
|
daemonset.status
|
||||||
@@ -89,18 +101,18 @@ def custom_condition(condition: Dict, resource: ResourceInstance) -> bool:
|
|||||||
if not matches:
|
if not matches:
|
||||||
return False
|
return False
|
||||||
# There should never be more than one condition of a specific type
|
# There should never be more than one condition of a specific type
|
||||||
match: ResourceField = matches[0]
|
match_condition: ResourceField = matches[0]
|
||||||
if match.status == "Unknown":
|
if match_condition.status == "Unknown":
|
||||||
if match.status == condition["status"]:
|
if match_condition.status == condition["status"]:
|
||||||
if "reason" not in condition:
|
if "reason" not in condition:
|
||||||
return True
|
return True
|
||||||
if condition["reason"]:
|
if condition["reason"]:
|
||||||
return match.reason == condition["reason"]
|
return match_condition.reason == condition["reason"]
|
||||||
return False
|
return False
|
||||||
status = True if match.status == "True" else False
|
status = True if match_condition.status == "True" else False
|
||||||
if status == boolean(condition["status"], strict=False):
|
if status == boolean(condition["status"], strict=False):
|
||||||
if condition.get("reason"):
|
if condition.get("reason"):
|
||||||
return match.reason == condition["reason"]
|
return match_condition.reason == condition["reason"]
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -143,6 +155,7 @@ RESOURCE_PREDICATES = {
|
|||||||
"DaemonSet": daemonset_ready,
|
"DaemonSet": daemonset_ready,
|
||||||
"Deployment": deployment_ready,
|
"Deployment": deployment_ready,
|
||||||
"Pod": pod_ready,
|
"Pod": pod_ready,
|
||||||
|
"Job": job_complete,
|
||||||
"StatefulSet": statefulset_ready,
|
"StatefulSet": statefulset_ready,
|
||||||
"ClusterOperator": cluster_operator_ready,
|
"ClusterOperator": cluster_operator_ready,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
# Copyright (c) Ansible Project
|
||||||
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
import hashlib
|
||||||
|
import os
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
try:
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
IMP_YAML = True
|
||||||
|
IMP_YAML_ERR = None
|
||||||
|
except ImportError:
|
||||||
|
IMP_YAML = False
|
||||||
|
IMP_YAML_ERR = traceback.format_exc()
|
||||||
|
|
||||||
|
|
||||||
|
def load_yaml_file(path):
|
||||||
|
if not path or not os.path.exists(path):
|
||||||
|
return {}
|
||||||
|
with open(path, "r") as f:
|
||||||
|
return yaml.safe_load(f) or {}
|
||||||
|
|
||||||
|
|
||||||
|
def deep_merge(base, updates):
|
||||||
|
result = base.copy()
|
||||||
|
for key, value in updates.items():
|
||||||
|
if key in result and isinstance(result[key], dict) and isinstance(value, dict):
|
||||||
|
result[key] = deep_merge(result[key], value)
|
||||||
|
else:
|
||||||
|
result[key] = value
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def merge_by_name(existing, new):
|
||||||
|
merged = {}
|
||||||
|
for item in existing:
|
||||||
|
if isinstance(item, dict) and "name" in item:
|
||||||
|
merged[item["name"]] = item
|
||||||
|
|
||||||
|
for item in new:
|
||||||
|
if not isinstance(item, dict) or "name" not in item:
|
||||||
|
continue
|
||||||
|
|
||||||
|
name = item["name"]
|
||||||
|
behavior = item.get("behavior", "merge")
|
||||||
|
item_copy = {k: v for k, v in item.items() if k != "behavior"}
|
||||||
|
|
||||||
|
if name in merged:
|
||||||
|
if behavior == "keep":
|
||||||
|
continue
|
||||||
|
elif behavior == "remove":
|
||||||
|
del merged[name]
|
||||||
|
elif behavior == "replace":
|
||||||
|
merged[name] = item_copy
|
||||||
|
else:
|
||||||
|
result = {"name": name}
|
||||||
|
for key in ["cluster", "user", "context"]:
|
||||||
|
if key in merged[name] or key in item_copy:
|
||||||
|
existing_config = merged[name].get(key, {})
|
||||||
|
new_config = item_copy.get(key, {})
|
||||||
|
result[key] = deep_merge(existing_config, new_config)
|
||||||
|
for key in merged[name]:
|
||||||
|
if key not in ["name", "cluster", "user", "context"]:
|
||||||
|
result[key] = merged[name][key]
|
||||||
|
for key in item_copy:
|
||||||
|
if (
|
||||||
|
key not in ["name", "cluster", "user", "context"]
|
||||||
|
and key not in result
|
||||||
|
):
|
||||||
|
result[key] = item_copy[key]
|
||||||
|
merged[name] = result
|
||||||
|
else:
|
||||||
|
if behavior == "remove":
|
||||||
|
continue
|
||||||
|
merged[name] = item_copy
|
||||||
|
|
||||||
|
return list(merged.values())
|
||||||
|
|
||||||
|
|
||||||
|
def hash_data(data):
|
||||||
|
"""Generate SHA-256 hash for idempotency checking."""
|
||||||
|
return hashlib.sha256(yaml.safe_dump(data, sort_keys=True).encode()).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def write_file(dest, data):
|
||||||
|
if not dest:
|
||||||
|
return False
|
||||||
|
with open(dest, "w") as f:
|
||||||
|
yaml.safe_dump(data, f, sort_keys=False)
|
||||||
|
return True
|
||||||
@@ -15,4 +15,6 @@ __metaclass__ = type
|
|||||||
#
|
#
|
||||||
# from ansible.module_utils.compat.version import LooseVersion
|
# from ansible.module_utils.compat.version import LooseVersion
|
||||||
|
|
||||||
from ._version import LooseVersion # noqa: F401
|
from ._version import LooseVersion # noqa: F401 # pylint: disable=unused-import
|
||||||
|
|
||||||
|
__all__ = ["LooseVersion"]
|
||||||
|
|||||||
+422
-73
@@ -21,7 +21,7 @@ author:
|
|||||||
- Matthieu Diehr (@d-matt)
|
- Matthieu Diehr (@d-matt)
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "helm (https://github.com/helm/helm/releases)"
|
- "helm >= 3.0.0 (https://github.com/helm/helm/releases)"
|
||||||
- "yaml (https://pypi.org/project/PyYAML/)"
|
- "yaml (https://pypi.org/project/PyYAML/)"
|
||||||
|
|
||||||
description:
|
description:
|
||||||
@@ -132,15 +132,19 @@ options:
|
|||||||
version_added: 2.4.0
|
version_added: 2.4.0
|
||||||
reuse_values:
|
reuse_values:
|
||||||
description:
|
description:
|
||||||
- When upgrading package, specifies wether to reuse the last release's values and merge in any overrides from parameters I(release_values),
|
- When upgrading package, specifies whether to reuse the last release's values and merge in any overrides from parameters O(release_values),
|
||||||
I(values_files) or I(set_values).
|
O(values_files) or O(set_values).
|
||||||
- If I(reset_values) is set to C(True), this is ignored.
|
- Helm ignores this when C(--reset-values) is passed. Since O(reset_values) defaults to V(true), it has to be set to V(false)
|
||||||
|
for this option to take any effect.
|
||||||
|
- C(helm install) does not accept C(--reuse-values), so this option is ignored when O(replace) is set.
|
||||||
|
- The module warns whenever one of those combinations makes this option a no-op.
|
||||||
type: bool
|
type: bool
|
||||||
required: false
|
required: false
|
||||||
version_added: 3.0.0
|
version_added: 3.0.0
|
||||||
reset_values:
|
reset_values:
|
||||||
description:
|
description:
|
||||||
- When upgrading package, reset the values to the ones built into the chart.
|
- When upgrading package, reset the values to the ones built into the chart.
|
||||||
|
- Defaults to V(true), which makes helm ignore O(reuse_values) and O(reset_then_reuse_values). Set it to V(false) to use either of them.
|
||||||
type: bool
|
type: bool
|
||||||
required: false
|
required: false
|
||||||
default: True
|
default: True
|
||||||
@@ -149,7 +153,10 @@ options:
|
|||||||
description:
|
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
|
- 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).
|
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.
|
- Helm ignores this when C(--reset-values) or C(--reuse-values) is passed. Since O(reset_values) defaults to V(true), it has to be
|
||||||
|
set to V(false), and O(reuse_values) left unset or V(false), for this option to take any effect.
|
||||||
|
- C(helm install) does not accept C(--reset-then-reuse-values), so this option is ignored when O(replace) is set.
|
||||||
|
- The module warns whenever one of those combinations makes this option a no-op.
|
||||||
- This feature requires helm diff >= 3.9.12.
|
- This feature requires helm diff >= 3.9.12.
|
||||||
type: bool
|
type: bool
|
||||||
required: false
|
required: false
|
||||||
@@ -165,6 +172,13 @@ options:
|
|||||||
force:
|
force:
|
||||||
description:
|
description:
|
||||||
- Helm option to force reinstall, ignore on new install.
|
- Helm option to force reinstall, ignore on new install.
|
||||||
|
- With Helm v4 this performs a client-side replacement. Helm v4 deprecated
|
||||||
|
C(--force) (split into C(--force-replace) and C(--force-conflicts)) and
|
||||||
|
enables server-side apply by default, so for Helm v4 the module emits
|
||||||
|
C(--server-side=false --force-replace) to preserve the Helm v3 behaviour.
|
||||||
|
With Helm v3 the C(--force) flag is used. The O(force) option works the
|
||||||
|
same way regardless of the installed Helm version.
|
||||||
|
- Mutually exclusive with O(server_side) and O(force_conflicts).
|
||||||
default: False
|
default: False
|
||||||
type: bool
|
type: bool
|
||||||
purge:
|
purge:
|
||||||
@@ -180,6 +194,15 @@ options:
|
|||||||
It will wait for as long as I(wait_timeout). This feature requires helm>=3.7.0. Added in version 2.3.0.
|
It will wait for as long as I(wait_timeout). This feature requires helm>=3.7.0. Added in version 2.3.0.
|
||||||
default: False
|
default: False
|
||||||
type: bool
|
type: bool
|
||||||
|
wait_for_jobs:
|
||||||
|
description:
|
||||||
|
- When I(release_state) is set to C(present), and I(wait) is set to C(True), wait until all jobs are in a
|
||||||
|
completed state before marking the release as successful.
|
||||||
|
- Ignored when used without O(wait).
|
||||||
|
- Requires Helm >= 3.5.0
|
||||||
|
version_added: 6.6.0
|
||||||
|
default: False
|
||||||
|
type: bool
|
||||||
wait_timeout:
|
wait_timeout:
|
||||||
description:
|
description:
|
||||||
- Timeout when wait option is enabled (helm2 is a number of seconds, helm3 is a duration).
|
- Timeout when wait option is enabled (helm2 is a number of seconds, helm3 is a duration).
|
||||||
@@ -195,8 +218,44 @@ options:
|
|||||||
atomic:
|
atomic:
|
||||||
description:
|
description:
|
||||||
- If set, the installation process deletes the installation on failure.
|
- If set, the installation process deletes the installation on failure.
|
||||||
|
- With Helm v4 this is translated to the C(--rollback-on-failure) flag, since
|
||||||
|
C(--atomic) was renamed; with Helm v3 the C(--atomic) flag is used. The
|
||||||
|
O(atomic) option works the same way regardless of the installed Helm version.
|
||||||
type: bool
|
type: bool
|
||||||
default: False
|
default: False
|
||||||
|
cleanup_on_fail:
|
||||||
|
description:
|
||||||
|
- Allow deletion of new resources created during a failed upgrade.
|
||||||
|
- Maps to the C(--cleanup-on-fail) flag, which is available since helm 3.0.0 and
|
||||||
|
was not renamed in Helm v4.
|
||||||
|
- Complements O(atomic) rather than replacing it, and the two can be combined so
|
||||||
|
that a rollback also drops resources orphaned by the failed upgrade.
|
||||||
|
- Helm only accepts this flag on C(helm upgrade), so it cannot be used together
|
||||||
|
with O(replace), which deploys through C(helm install).
|
||||||
|
type: bool
|
||||||
|
default: False
|
||||||
|
version_added: 6.6.0
|
||||||
|
server_side:
|
||||||
|
description:
|
||||||
|
- Control Helm v4 server-side apply when installing or upgrading a release.
|
||||||
|
- Maps to the C(--server-side) flag, which accepts C(true), C(false) or C(auto).
|
||||||
|
- This option requires Helm v4 and is mutually exclusive with O(force).
|
||||||
|
type: str
|
||||||
|
choices:
|
||||||
|
- "auto"
|
||||||
|
- "true"
|
||||||
|
- "false"
|
||||||
|
version_added: 6.5.0
|
||||||
|
force_conflicts:
|
||||||
|
description:
|
||||||
|
- When server-side apply is enabled (the Helm v4 default), force changes
|
||||||
|
against conflicts instead of failing.
|
||||||
|
- Maps to the C(--force-conflicts) flag.
|
||||||
|
- This option requires Helm v4, cannot be combined with O(server_side=false),
|
||||||
|
and is mutually exclusive with O(force).
|
||||||
|
type: bool
|
||||||
|
default: False
|
||||||
|
version_added: 6.5.0
|
||||||
create_namespace:
|
create_namespace:
|
||||||
description:
|
description:
|
||||||
- Create the release namespace if not present.
|
- Create the release namespace if not present.
|
||||||
@@ -237,6 +296,27 @@ options:
|
|||||||
default: False
|
default: False
|
||||||
aliases: [ skip_tls_certs_check ]
|
aliases: [ skip_tls_certs_check ]
|
||||||
version_added: 5.3.0
|
version_added: 5.3.0
|
||||||
|
plain_http:
|
||||||
|
description:
|
||||||
|
- Use HTTP instead of HTTPS when working with OCI registries
|
||||||
|
- Requires Helm >= 3.13.0
|
||||||
|
type: bool
|
||||||
|
default: False
|
||||||
|
version_added: 6.1.0
|
||||||
|
take_ownership:
|
||||||
|
description:
|
||||||
|
- Helm will ignore the check for helm annotations and take ownership of the existing resources
|
||||||
|
- This feature requires helm >= 3.17.0
|
||||||
|
type: bool
|
||||||
|
default: False
|
||||||
|
version_added: 6.1.0
|
||||||
|
skip_schema_validation:
|
||||||
|
description:
|
||||||
|
- Disables JSON schema validation for Chart and values.
|
||||||
|
- This feature requires helm >= 3.16.0
|
||||||
|
type: bool
|
||||||
|
default: False
|
||||||
|
version_added: 6.2.0
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- kubernetes.core.helm_common_options
|
- kubernetes.core.helm_common_options
|
||||||
"""
|
"""
|
||||||
@@ -319,6 +399,12 @@ EXAMPLES = r"""
|
|||||||
chart_ref: "https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz"
|
chart_ref: "https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz"
|
||||||
release_namespace: monitoring
|
release_namespace: monitoring
|
||||||
|
|
||||||
|
- name: Deploy Bitnami's MongoDB latest chart from OCI registry
|
||||||
|
kubernetes.core.helm:
|
||||||
|
name: test
|
||||||
|
chart_ref: "oci://registry-1.docker.io/bitnamicharts/mongodb"
|
||||||
|
release_namespace: database
|
||||||
|
|
||||||
# Using complex Values
|
# Using complex Values
|
||||||
- name: Deploy new-relic client chart
|
- name: Deploy new-relic client chart
|
||||||
kubernetes.core.helm:
|
kubernetes.core.helm:
|
||||||
@@ -327,6 +413,7 @@ EXAMPLES = r"""
|
|||||||
release_namespace: default
|
release_namespace: default
|
||||||
force: True
|
force: True
|
||||||
wait: True
|
wait: True
|
||||||
|
wait_for_jobs: True
|
||||||
replace: True
|
replace: True
|
||||||
update_repo_cache: True
|
update_repo_cache: True
|
||||||
disable_hook: True
|
disable_hook: True
|
||||||
@@ -346,15 +433,30 @@ EXAMPLES = r"""
|
|||||||
enabled: True
|
enabled: True
|
||||||
|
|
||||||
# Deploy latest version
|
# Deploy latest version
|
||||||
|
# 'reset_values' defaults to true and helm ignores '--reuse-values' when it is set,
|
||||||
|
# so it has to be turned off explicitly.
|
||||||
- name: Deploy latest version of Grafana chart using reuse_values
|
- name: Deploy latest version of Grafana chart using reuse_values
|
||||||
kubernetes.core.helm:
|
kubernetes.core.helm:
|
||||||
name: test
|
name: test
|
||||||
chart_ref: stable/grafana
|
chart_ref: stable/grafana
|
||||||
release_namespace: monitoring
|
release_namespace: monitoring
|
||||||
reuse_values: true
|
reuse_values: true
|
||||||
|
reset_values: false
|
||||||
values:
|
values:
|
||||||
replicas: 2
|
replicas: 2
|
||||||
version: 3e8ec0b2dffa40fb97d5342e4af887de95faa8c61a62480dd7f8aa03dffcf533
|
version: 3e8ec0b2dffa40fb97d5342e4af887de95faa8c61a62480dd7f8aa03dffcf533
|
||||||
|
|
||||||
|
# Same for 'reset_then_reuse_values', which helm ignores when either
|
||||||
|
# '--reset-values' or '--reuse-values' is set.
|
||||||
|
- name: Deploy latest version of Grafana chart using reset_then_reuse_values
|
||||||
|
kubernetes.core.helm:
|
||||||
|
name: test
|
||||||
|
chart_ref: stable/grafana
|
||||||
|
release_namespace: monitoring
|
||||||
|
reset_then_reuse_values: true
|
||||||
|
reset_values: false
|
||||||
|
values:
|
||||||
|
replicas: 2
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = r"""
|
RETURN = r"""
|
||||||
@@ -443,6 +545,7 @@ from ansible.module_utils.basic import missing_required_lib
|
|||||||
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,
|
||||||
|
strip_registry_progress,
|
||||||
)
|
)
|
||||||
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,
|
||||||
@@ -473,9 +576,13 @@ def get_release_status(module, release_name, all_status=False):
|
|||||||
"--filter",
|
"--filter",
|
||||||
release_name,
|
release_name,
|
||||||
]
|
]
|
||||||
if all_status:
|
if all_status and not module.is_helm_v4():
|
||||||
|
# --all has been removed from `helm list` command on helm v4
|
||||||
list_command.append("--all")
|
list_command.append("--all")
|
||||||
|
elif not all_status:
|
||||||
|
# The default behavior to display only deployed releases has been removed from
|
||||||
|
# Helm v4
|
||||||
|
list_command.append("--deployed")
|
||||||
rc, out, err = module.run_helm_command(list_command)
|
rc, out, err = module.run_helm_command(list_command)
|
||||||
|
|
||||||
release = get_release(yaml.safe_load(out), release_name)
|
release = get_release(yaml.safe_load(out), release_name)
|
||||||
@@ -512,7 +619,9 @@ def run_dep_update(module, 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, insecure_skip_tls_verify=False, plain_http=False
|
||||||
|
):
|
||||||
"""
|
"""
|
||||||
Get chart info
|
Get chart info
|
||||||
"""
|
"""
|
||||||
@@ -521,9 +630,65 @@ def fetch_chart_info(module, command, chart_ref, insecure_skip_tls_verify=False)
|
|||||||
if insecure_skip_tls_verify:
|
if insecure_skip_tls_verify:
|
||||||
inspect_command += " --insecure-skip-tls-verify"
|
inspect_command += " --insecure-skip-tls-verify"
|
||||||
|
|
||||||
|
if plain_http:
|
||||||
|
helm_version = module.get_helm_version()
|
||||||
|
if LooseVersion(helm_version) < LooseVersion("3.13.0"):
|
||||||
|
module.fail_json(
|
||||||
|
msg="plain_http requires helm >= 3.13.0, current version is {0}".format(
|
||||||
|
helm_version
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
inspect_command += " --plain-http"
|
||||||
|
|
||||||
rc, out, err = module.run_helm_command(inspect_command)
|
rc, out, err = module.run_helm_command(inspect_command)
|
||||||
|
|
||||||
return yaml.safe_load(out)
|
return yaml.safe_load(strip_registry_progress(out))
|
||||||
|
|
||||||
|
|
||||||
|
def validate_value_options(
|
||||||
|
module, replace, reuse_values, reset_values, reset_then_reuse_values
|
||||||
|
):
|
||||||
|
"""
|
||||||
|
Check the value-reuse options against each other and against 'replace'.
|
||||||
|
|
||||||
|
'helm install' accepts none of these flags, so 'replace' drops all three. The rest
|
||||||
|
are precedence rules helm applies silently: '--reset-values' wins over
|
||||||
|
'--reuse-values', and both win over '--reset-then-reuse-values'. Since 'reset_values'
|
||||||
|
defaults to true, requesting either of the other two on its own is a no-op.
|
||||||
|
|
||||||
|
Warn rather than fail throughout. Every one of these combinations is accepted by
|
||||||
|
playbooks today: 'reuse_values' has existed since 3.0.0, and a release that is
|
||||||
|
already converged never reaches deploy(), so the invalid command was never built.
|
||||||
|
Failing here would turn tasks that pass today into tasks that fail.
|
||||||
|
"""
|
||||||
|
if replace:
|
||||||
|
for name, requested in (
|
||||||
|
("reuse_values", reuse_values is not None),
|
||||||
|
("reset_then_reuse_values", reset_then_reuse_values),
|
||||||
|
):
|
||||||
|
if requested:
|
||||||
|
module.warn(
|
||||||
|
"{0} is ignored because replace=true deploys through 'helm install',"
|
||||||
|
" which does not accept the flag.".format(name)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
if reset_values:
|
||||||
|
for name, requested in (
|
||||||
|
("reuse_values", reuse_values),
|
||||||
|
("reset_then_reuse_values", reset_then_reuse_values),
|
||||||
|
):
|
||||||
|
if requested:
|
||||||
|
module.warn(
|
||||||
|
"{0} is ignored because reset_values is true. "
|
||||||
|
"Set reset_values=false to make it take effect.".format(name)
|
||||||
|
)
|
||||||
|
elif reuse_values and reset_then_reuse_values:
|
||||||
|
module.warn(
|
||||||
|
"reset_then_reuse_values is ignored because reuse_values is true. "
|
||||||
|
"Set reuse_values=false to make it take effect."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def deploy(
|
def deploy(
|
||||||
@@ -533,12 +698,14 @@ def deploy(
|
|||||||
release_values,
|
release_values,
|
||||||
chart_name,
|
chart_name,
|
||||||
wait,
|
wait,
|
||||||
|
wait_for_jobs,
|
||||||
wait_timeout,
|
wait_timeout,
|
||||||
disable_hook,
|
disable_hook,
|
||||||
force,
|
force,
|
||||||
values_files,
|
values_files,
|
||||||
history_max,
|
history_max,
|
||||||
atomic=False,
|
atomic=False,
|
||||||
|
cleanup_on_fail=False,
|
||||||
create_namespace=False,
|
create_namespace=False,
|
||||||
replace=False,
|
replace=False,
|
||||||
post_renderer=None,
|
post_renderer=None,
|
||||||
@@ -550,6 +717,11 @@ def deploy(
|
|||||||
reset_values=True,
|
reset_values=True,
|
||||||
reset_then_reuse_values=False,
|
reset_then_reuse_values=False,
|
||||||
insecure_skip_tls_verify=False,
|
insecure_skip_tls_verify=False,
|
||||||
|
plain_http=False,
|
||||||
|
take_ownership=False,
|
||||||
|
skip_schema_validation=False,
|
||||||
|
server_side=None,
|
||||||
|
force_conflicts=False,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Install/upgrade/rollback release chart
|
Install/upgrade/rollback release chart
|
||||||
@@ -561,36 +733,99 @@ 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 take_ownership:
|
||||||
|
deploy_command += " --take-ownership"
|
||||||
|
|
||||||
|
# '--reset-values', '--reuse-values' and '--reset-then-reuse-values' are all
|
||||||
|
# upgrade-only flags, so they must not leak into the 'replace' branch above.
|
||||||
|
# validate_value_options() has already warned about that combination.
|
||||||
if reset_values:
|
if reset_values:
|
||||||
deploy_command += " --reset-values"
|
deploy_command += " --reset-values"
|
||||||
|
|
||||||
if reuse_values is not None:
|
if reuse_values is not None:
|
||||||
deploy_command += " --reuse-values=" + str(reuse_values)
|
deploy_command += " --reuse-values=" + str(reuse_values)
|
||||||
|
|
||||||
if reset_then_reuse_values:
|
if reset_then_reuse_values:
|
||||||
helm_version = module.get_helm_version()
|
helm_version = module.get_helm_version()
|
||||||
if LooseVersion(helm_version) < LooseVersion("3.14.0"):
|
if LooseVersion(helm_version) < LooseVersion("3.14.0"):
|
||||||
module.fail_json(
|
module.fail_json(
|
||||||
msg="reset_then_reuse_values requires helm >= 3.14.0, current version is {0}".format(
|
msg="reset_then_reuse_values requires helm >= 3.14.0, current version is {0}".format(
|
||||||
helm_version
|
helm_version
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
else:
|
||||||
else:
|
deploy_command += " --reset-then-reuse-values"
|
||||||
deploy_command += " --reset-then-reuse-values"
|
|
||||||
|
|
||||||
if wait:
|
if wait:
|
||||||
deploy_command += " --wait"
|
deploy_command += " --wait"
|
||||||
|
if wait_for_jobs:
|
||||||
|
helm_version = module.get_helm_version()
|
||||||
|
if LooseVersion(helm_version) < LooseVersion("3.5.0"):
|
||||||
|
module.fail_json(
|
||||||
|
msg="wait_for_jobs requires helm >= 3.5.0, current version is {0}".format(
|
||||||
|
helm_version
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
deploy_command += " --wait-for-jobs"
|
||||||
if wait_timeout is not None:
|
if wait_timeout is not None:
|
||||||
deploy_command += " --timeout " + wait_timeout
|
deploy_command += " --timeout " + wait_timeout
|
||||||
|
|
||||||
if atomic:
|
if atomic:
|
||||||
deploy_command += " --atomic"
|
# Helm v4 renamed '--atomic' to '--rollback-on-failure'. The old flag is
|
||||||
|
# deprecated on 'helm upgrade' and removed from 'helm install', so always
|
||||||
|
# emit the version-appropriate flag.
|
||||||
|
if module.is_helm_v4():
|
||||||
|
deploy_command += " --rollback-on-failure"
|
||||||
|
else:
|
||||||
|
deploy_command += " --atomic"
|
||||||
|
|
||||||
|
if cleanup_on_fail:
|
||||||
|
# '--cleanup-on-fail' is only accepted by 'helm upgrade', so it cannot be
|
||||||
|
# combined with 'replace', which deploys through 'helm install'. The flag
|
||||||
|
# exists since helm 3.0.0 and kept its name in v4, so no version gate is
|
||||||
|
# needed on top of the module-wide helm >= 3.0.0 requirement.
|
||||||
|
if replace:
|
||||||
|
module.fail_json(
|
||||||
|
msg="cleanup_on_fail is only supported by 'helm upgrade' and cannot be used with replace=true"
|
||||||
|
)
|
||||||
|
deploy_command += " --cleanup-on-fail"
|
||||||
|
|
||||||
if timeout:
|
if timeout:
|
||||||
deploy_command += " --timeout " + timeout
|
deploy_command += " --timeout " + timeout
|
||||||
|
|
||||||
|
if server_side is not None:
|
||||||
|
if not module.is_helm_v4():
|
||||||
|
module.fail_json(
|
||||||
|
msg="server_side requires helm >= 4.0.0, current version is {0}".format(
|
||||||
|
module.get_helm_version()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
deploy_command += " --server-side=" + server_side
|
||||||
|
|
||||||
|
if force_conflicts:
|
||||||
|
if not module.is_helm_v4():
|
||||||
|
module.fail_json(
|
||||||
|
msg="force_conflicts requires helm >= 4.0.0, current version is {0}".format(
|
||||||
|
module.get_helm_version()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if server_side == "false":
|
||||||
|
module.fail_json(
|
||||||
|
msg="force_conflicts requires server-side apply to be enabled and cannot be used with server_side=false"
|
||||||
|
)
|
||||||
|
deploy_command += " --force-conflicts"
|
||||||
|
|
||||||
if force:
|
if force:
|
||||||
deploy_command += " --force"
|
# Helm v4 deprecated '--force' (split into '--force-replace' and
|
||||||
|
# '--force-conflicts') and enables server-side apply by default, which is
|
||||||
|
# incompatible with '--force-replace'. Emit the version-appropriate flags,
|
||||||
|
# disabling server-side apply on v4 to preserve the v3 client-side
|
||||||
|
# replacement behaviour. 'force' is mutually exclusive with 'server_side'.
|
||||||
|
if module.is_helm_v4():
|
||||||
|
deploy_command += " --server-side=false --force-replace"
|
||||||
|
else:
|
||||||
|
deploy_command += " --force"
|
||||||
|
|
||||||
if replace:
|
if replace:
|
||||||
deploy_command += " --replace"
|
deploy_command += " --replace"
|
||||||
@@ -612,6 +847,9 @@ def deploy(
|
|||||||
else:
|
else:
|
||||||
deploy_command += " --insecure-skip-tls-verify"
|
deploy_command += " --insecure-skip-tls-verify"
|
||||||
|
|
||||||
|
if plain_http:
|
||||||
|
deploy_command += " --plain-http"
|
||||||
|
|
||||||
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
|
||||||
@@ -635,6 +873,17 @@ def deploy(
|
|||||||
if set_value_args:
|
if set_value_args:
|
||||||
deploy_command += " " + set_value_args
|
deploy_command += " " + set_value_args
|
||||||
|
|
||||||
|
if skip_schema_validation:
|
||||||
|
helm_version = module.get_helm_version()
|
||||||
|
if LooseVersion(helm_version) < LooseVersion("3.16.0"):
|
||||||
|
module.fail_json(
|
||||||
|
msg="skip_schema_validation requires helm >= 3.16.0, current version is {0}".format(
|
||||||
|
helm_version
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
deploy_command += " --skip-schema-validation"
|
||||||
|
|
||||||
deploy_command += " " + release_name + f" '{chart_name}'"
|
deploy_command += " " + release_name + f" '{chart_name}'"
|
||||||
return deploy_command
|
return deploy_command
|
||||||
|
|
||||||
@@ -687,8 +936,8 @@ def get_plugin_version(plugin):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
for line in out:
|
for line in out:
|
||||||
if line[0] == plugin:
|
if line["name"] == plugin:
|
||||||
return line[1]
|
return line["version"]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@@ -707,6 +956,7 @@ def helmdiff_check(
|
|||||||
reset_values=True,
|
reset_values=True,
|
||||||
reset_then_reuse_values=False,
|
reset_then_reuse_values=False,
|
||||||
insecure_skip_tls_verify=False,
|
insecure_skip_tls_verify=False,
|
||||||
|
skip_schema_validation=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.
|
||||||
@@ -738,10 +988,10 @@ def helmdiff_check(
|
|||||||
if set_value_args:
|
if set_value_args:
|
||||||
cmd += " " + set_value_args
|
cmd += " " + set_value_args
|
||||||
|
|
||||||
if reuse_values:
|
if not replace and reuse_values:
|
||||||
cmd += " --reuse-values"
|
cmd += " --reuse-values"
|
||||||
|
|
||||||
if reset_then_reuse_values:
|
if not replace and reset_then_reuse_values:
|
||||||
helm_diff_version = get_plugin_version("diff")
|
helm_diff_version = get_plugin_version("diff")
|
||||||
helm_version = module.get_helm_version()
|
helm_version = module.get_helm_version()
|
||||||
fail_msg = ""
|
fail_msg = ""
|
||||||
@@ -762,6 +1012,17 @@ def helmdiff_check(
|
|||||||
if insecure_skip_tls_verify:
|
if insecure_skip_tls_verify:
|
||||||
cmd += " --insecure-skip-tls-verify"
|
cmd += " --insecure-skip-tls-verify"
|
||||||
|
|
||||||
|
if skip_schema_validation:
|
||||||
|
helm_version = module.get_helm_version()
|
||||||
|
if LooseVersion(helm_version) < LooseVersion("3.16.0"):
|
||||||
|
module.fail_json(
|
||||||
|
msg="skip_schema_validation requires helm >= 3.16.0, current version is {0}".format(
|
||||||
|
helm_version
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
cmd += " --skip-schema-validation"
|
||||||
|
|
||||||
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())
|
||||||
|
|
||||||
@@ -793,39 +1054,58 @@ def default_check(release_status, chart_info, values=None, values_files=None):
|
|||||||
def argument_spec():
|
def argument_spec():
|
||||||
arg_spec = copy.deepcopy(HELM_AUTH_ARG_SPEC)
|
arg_spec = copy.deepcopy(HELM_AUTH_ARG_SPEC)
|
||||||
arg_spec.update(
|
arg_spec.update(
|
||||||
dict(
|
{
|
||||||
chart_ref=dict(type="path"),
|
"chart_ref": {"type": "path"},
|
||||||
chart_repo_url=dict(type="str"),
|
"chart_repo_url": {"type": "str"},
|
||||||
chart_version=dict(type="str"),
|
"chart_version": {"type": "str"},
|
||||||
dependency_update=dict(type="bool", default=False, aliases=["dep_up"]),
|
"dependency_update": {
|
||||||
release_name=dict(type="str", required=True, aliases=["name"]),
|
"type": "bool",
|
||||||
release_namespace=dict(type="str", required=True, aliases=["namespace"]),
|
"default": False,
|
||||||
release_state=dict(
|
"aliases": ["dep_up"],
|
||||||
default="present", choices=["present", "absent"], aliases=["state"]
|
},
|
||||||
),
|
"release_name": {"type": "str", "required": True, "aliases": ["name"]},
|
||||||
release_values=dict(type="dict", default={}, aliases=["values"]),
|
"release_namespace": {
|
||||||
values_files=dict(type="list", default=[], elements="str"),
|
"type": "str",
|
||||||
update_repo_cache=dict(type="bool", default=False),
|
"required": True,
|
||||||
disable_hook=dict(type="bool", default=False),
|
"aliases": ["namespace"],
|
||||||
force=dict(type="bool", default=False),
|
},
|
||||||
purge=dict(type="bool", default=True),
|
"release_state": {
|
||||||
wait=dict(type="bool", default=False),
|
"default": "present",
|
||||||
wait_timeout=dict(type="str"),
|
"choices": ["present", "absent"],
|
||||||
timeout=dict(type="str"),
|
"aliases": ["state"],
|
||||||
atomic=dict(type="bool", default=False),
|
},
|
||||||
create_namespace=dict(type="bool", default=False),
|
"release_values": {"type": "dict", "default": {}, "aliases": ["values"]},
|
||||||
post_renderer=dict(type="str"),
|
"values_files": {"type": "list", "default": [], "elements": "str"},
|
||||||
replace=dict(type="bool", default=False),
|
"update_repo_cache": {"type": "bool", "default": False},
|
||||||
skip_crds=dict(type="bool", default=False),
|
"disable_hook": {"type": "bool", "default": False},
|
||||||
history_max=dict(type="int"),
|
"force": {"type": "bool", "default": False},
|
||||||
set_values=dict(type="list", elements="dict"),
|
"purge": {"type": "bool", "default": True},
|
||||||
reuse_values=dict(type="bool"),
|
"wait": {"type": "bool", "default": False},
|
||||||
reset_values=dict(type="bool", default=True),
|
"wait_for_jobs": {"type": "bool", "default": False},
|
||||||
reset_then_reuse_values=dict(type="bool", default=False),
|
"wait_timeout": {"type": "str"},
|
||||||
insecure_skip_tls_verify=dict(
|
"timeout": {"type": "str"},
|
||||||
type="bool", default=False, aliases=["skip_tls_certs_check"]
|
"atomic": {"type": "bool", "default": False},
|
||||||
),
|
"server_side": {"type": "str", "choices": ["auto", "true", "false"]},
|
||||||
)
|
"force_conflicts": {"type": "bool", "default": False},
|
||||||
|
"create_namespace": {"type": "bool", "default": False},
|
||||||
|
"post_renderer": {"type": "str"},
|
||||||
|
"replace": {"type": "bool", "default": False},
|
||||||
|
"skip_crds": {"type": "bool", "default": False},
|
||||||
|
"history_max": {"type": "int"},
|
||||||
|
"set_values": {"type": "list", "elements": "dict"},
|
||||||
|
"reuse_values": {"type": "bool"},
|
||||||
|
"reset_values": {"type": "bool", "default": True},
|
||||||
|
"reset_then_reuse_values": {"type": "bool", "default": False},
|
||||||
|
"insecure_skip_tls_verify": {
|
||||||
|
"type": "bool",
|
||||||
|
"default": False,
|
||||||
|
"aliases": ["skip_tls_certs_check"],
|
||||||
|
},
|
||||||
|
"plain_http": {"type": "bool", "default": False},
|
||||||
|
"take_ownership": {"type": "bool", "default": False},
|
||||||
|
"skip_schema_validation": {"type": "bool", "default": False},
|
||||||
|
"cleanup_on_fail": {"type": "bool", "default": False},
|
||||||
|
}
|
||||||
)
|
)
|
||||||
return arg_spec
|
return arg_spec
|
||||||
|
|
||||||
@@ -842,6 +1122,8 @@ def main():
|
|||||||
("context", "ca_cert"),
|
("context", "ca_cert"),
|
||||||
("replace", "history_max"),
|
("replace", "history_max"),
|
||||||
("wait_timeout", "timeout"),
|
("wait_timeout", "timeout"),
|
||||||
|
("force", "server_side"),
|
||||||
|
("force", "force_conflicts"),
|
||||||
],
|
],
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
@@ -857,7 +1139,7 @@ def main():
|
|||||||
if not IMP_YAML:
|
if not IMP_YAML:
|
||||||
module.fail_json(msg=missing_required_lib("yaml"), exception=IMP_YAML_ERR)
|
module.fail_json(msg=missing_required_lib("yaml"), exception=IMP_YAML_ERR)
|
||||||
|
|
||||||
# Validate Helm version >=3.0.0,<4.0.0
|
# Validate Helm version >=3.0.0
|
||||||
module.validate_helm_version()
|
module.validate_helm_version()
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
@@ -877,8 +1159,12 @@ def main():
|
|||||||
force = module.params.get("force")
|
force = module.params.get("force")
|
||||||
purge = module.params.get("purge")
|
purge = module.params.get("purge")
|
||||||
wait = module.params.get("wait")
|
wait = module.params.get("wait")
|
||||||
|
wait_for_jobs = module.params.get("wait_for_jobs")
|
||||||
wait_timeout = module.params.get("wait_timeout")
|
wait_timeout = module.params.get("wait_timeout")
|
||||||
atomic = module.params.get("atomic")
|
atomic = module.params.get("atomic")
|
||||||
|
cleanup_on_fail = module.params.get("cleanup_on_fail")
|
||||||
|
server_side = module.params.get("server_side")
|
||||||
|
force_conflicts = module.params.get("force_conflicts")
|
||||||
create_namespace = module.params.get("create_namespace")
|
create_namespace = module.params.get("create_namespace")
|
||||||
post_renderer = module.params.get("post_renderer")
|
post_renderer = module.params.get("post_renderer")
|
||||||
replace = module.params.get("replace")
|
replace = module.params.get("replace")
|
||||||
@@ -890,6 +1176,9 @@ def main():
|
|||||||
reset_values = module.params.get("reset_values")
|
reset_values = module.params.get("reset_values")
|
||||||
reset_then_reuse_values = module.params.get("reset_then_reuse_values")
|
reset_then_reuse_values = module.params.get("reset_then_reuse_values")
|
||||||
insecure_skip_tls_verify = module.params.get("insecure_skip_tls_verify")
|
insecure_skip_tls_verify = module.params.get("insecure_skip_tls_verify")
|
||||||
|
plain_http = module.params.get("plain_http")
|
||||||
|
take_ownership = module.params.get("take_ownership")
|
||||||
|
skip_schema_validation = module.params.get("skip_schema_validation")
|
||||||
|
|
||||||
if update_repo_cache:
|
if update_repo_cache:
|
||||||
run_repo_update(module)
|
run_repo_update(module)
|
||||||
@@ -899,6 +1188,33 @@ def main():
|
|||||||
release_status = get_release_status(module, release_name, all_status=all_status)
|
release_status = get_release_status(module, release_name, all_status=all_status)
|
||||||
|
|
||||||
helm_cmd = module.get_helm_binary()
|
helm_cmd = module.get_helm_binary()
|
||||||
|
|
||||||
|
if plain_http:
|
||||||
|
helm_version = module.get_helm_version()
|
||||||
|
if LooseVersion(helm_version) < LooseVersion("3.13.0"):
|
||||||
|
module.fail_json(
|
||||||
|
msg="plain_http requires helm >= 3.13.0, current version is {0}".format(
|
||||||
|
helm_version
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if take_ownership:
|
||||||
|
helm_version = module.get_helm_version()
|
||||||
|
if LooseVersion(helm_version) < LooseVersion("3.17.0"):
|
||||||
|
module.fail_json(
|
||||||
|
msg="take_ownership requires helm >= 3.17.0, current version is {0}".format(
|
||||||
|
helm_version
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if skip_schema_validation:
|
||||||
|
helm_version = module.get_helm_version()
|
||||||
|
if LooseVersion(helm_version) < LooseVersion("3.16.0"):
|
||||||
|
module.fail_json(
|
||||||
|
msg="skip_schema_validation requires helm >= 3.16.0, current version is {0}".format(
|
||||||
|
helm_version
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
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'
|
# skip release statuses 'uninstalled' and 'uninstalling'
|
||||||
@@ -909,8 +1225,7 @@ def main():
|
|||||||
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"] = []
|
module.warn(
|
||||||
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
|
||||||
@@ -920,6 +1235,10 @@ def main():
|
|||||||
)
|
)
|
||||||
changed = True
|
changed = True
|
||||||
elif release_state == "present":
|
elif release_state == "present":
|
||||||
|
validate_value_options(
|
||||||
|
module, replace, reuse_values, reset_values, reset_then_reuse_values
|
||||||
|
)
|
||||||
|
|
||||||
if chart_version is not None:
|
if chart_version is not None:
|
||||||
helm_cmd += " --version=" + chart_version
|
helm_cmd += " --version=" + chart_version
|
||||||
|
|
||||||
@@ -928,7 +1247,7 @@ def main():
|
|||||||
|
|
||||||
# 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, insecure_skip_tls_verify
|
module, helm_cmd, chart_ref, insecure_skip_tls_verify, plain_http
|
||||||
)
|
)
|
||||||
|
|
||||||
if dependency_update:
|
if dependency_update:
|
||||||
@@ -973,11 +1292,15 @@ def main():
|
|||||||
release_values,
|
release_values,
|
||||||
chart_ref,
|
chart_ref,
|
||||||
wait,
|
wait,
|
||||||
|
wait_for_jobs,
|
||||||
wait_timeout,
|
wait_timeout,
|
||||||
disable_hook,
|
disable_hook,
|
||||||
False,
|
False,
|
||||||
values_files=values_files,
|
values_files=values_files,
|
||||||
atomic=atomic,
|
atomic=atomic,
|
||||||
|
cleanup_on_fail=cleanup_on_fail,
|
||||||
|
server_side=server_side,
|
||||||
|
force_conflicts=force_conflicts,
|
||||||
create_namespace=create_namespace,
|
create_namespace=create_namespace,
|
||||||
post_renderer=post_renderer,
|
post_renderer=post_renderer,
|
||||||
replace=replace,
|
replace=replace,
|
||||||
@@ -990,19 +1313,29 @@ def main():
|
|||||||
reset_values=reset_values,
|
reset_values=reset_values,
|
||||||
reset_then_reuse_values=reset_then_reuse_values,
|
reset_then_reuse_values=reset_then_reuse_values,
|
||||||
insecure_skip_tls_verify=insecure_skip_tls_verify,
|
insecure_skip_tls_verify=insecure_skip_tls_verify,
|
||||||
|
plain_http=plain_http,
|
||||||
|
take_ownership=take_ownership,
|
||||||
|
skip_schema_validation=skip_schema_validation,
|
||||||
)
|
)
|
||||||
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 (
|
helm_version_compatible = module.is_helm_version_compatible_with_helm_diff(
|
||||||
not chart_repo_url
|
helm_diff_version
|
||||||
or (
|
)
|
||||||
chart_repo_url
|
if (
|
||||||
and LooseVersion(helm_diff_version) >= LooseVersion("3.4.1")
|
helm_diff_version
|
||||||
|
and helm_version_compatible
|
||||||
|
and (
|
||||||
|
not chart_repo_url
|
||||||
|
or (
|
||||||
|
chart_repo_url
|
||||||
|
and LooseVersion(helm_diff_version) >= LooseVersion("3.4.1")
|
||||||
|
)
|
||||||
)
|
)
|
||||||
):
|
):
|
||||||
(would_change, prepared) = helmdiff_check(
|
would_change, prepared = helmdiff_check(
|
||||||
module,
|
module,
|
||||||
release_name,
|
release_name,
|
||||||
chart_ref,
|
chart_ref,
|
||||||
@@ -1017,14 +1350,23 @@ def main():
|
|||||||
reset_values=reset_values,
|
reset_values=reset_values,
|
||||||
reset_then_reuse_values=reset_then_reuse_values,
|
reset_then_reuse_values=reset_then_reuse_values,
|
||||||
insecure_skip_tls_verify=insecure_skip_tls_verify,
|
insecure_skip_tls_verify=insecure_skip_tls_verify,
|
||||||
|
skip_schema_validation=skip_schema_validation,
|
||||||
)
|
)
|
||||||
if would_change and module._diff:
|
if would_change and module._diff:
|
||||||
opt_result["diff"] = {"prepared": prepared}
|
opt_result["diff"] = {"prepared": prepared}
|
||||||
else:
|
else:
|
||||||
module.warn(
|
if helm_diff_version and not helm_version_compatible:
|
||||||
"The default idempotency check can fail to report changes in certain cases. "
|
module.warn(
|
||||||
"Install helm diff >= 3.4.1 for better results."
|
"Idempotency checks are currently disabled due to a version mismatch."
|
||||||
)
|
f" Helm version {module.get_helm_version()} requires helm-diff >= 3.14.0,"
|
||||||
|
f" but the environment is currently running {helm_diff_version}."
|
||||||
|
" Please align the plugin versions to restore standard behavior."
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
module.warn(
|
||||||
|
"The default idempotency check can fail to report changes in certain cases. "
|
||||||
|
"Install helm diff >= 3.4.1 for better results."
|
||||||
|
)
|
||||||
would_change = default_check(
|
would_change = default_check(
|
||||||
release_status, chart_info, release_values, values_files
|
release_status, chart_info, release_values, values_files
|
||||||
)
|
)
|
||||||
@@ -1037,11 +1379,15 @@ def main():
|
|||||||
release_values,
|
release_values,
|
||||||
chart_ref,
|
chart_ref,
|
||||||
wait,
|
wait,
|
||||||
|
wait_for_jobs,
|
||||||
wait_timeout,
|
wait_timeout,
|
||||||
disable_hook,
|
disable_hook,
|
||||||
force,
|
force,
|
||||||
values_files=values_files,
|
values_files=values_files,
|
||||||
atomic=atomic,
|
atomic=atomic,
|
||||||
|
cleanup_on_fail=cleanup_on_fail,
|
||||||
|
server_side=server_side,
|
||||||
|
force_conflicts=force_conflicts,
|
||||||
create_namespace=create_namespace,
|
create_namespace=create_namespace,
|
||||||
post_renderer=post_renderer,
|
post_renderer=post_renderer,
|
||||||
replace=replace,
|
replace=replace,
|
||||||
@@ -1054,6 +1400,9 @@ def main():
|
|||||||
reset_values=reset_values,
|
reset_values=reset_values,
|
||||||
reset_then_reuse_values=reset_then_reuse_values,
|
reset_then_reuse_values=reset_then_reuse_values,
|
||||||
insecure_skip_tls_verify=insecure_skip_tls_verify,
|
insecure_skip_tls_verify=insecure_skip_tls_verify,
|
||||||
|
plain_http=plain_http,
|
||||||
|
take_ownership=take_ownership,
|
||||||
|
skip_schema_validation=skip_schema_validation,
|
||||||
)
|
)
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ author:
|
|||||||
- Lucas Boisserie (@LucasBoisserie)
|
- Lucas Boisserie (@LucasBoisserie)
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "helm (https://github.com/helm/helm/releases)"
|
- "helm >= 3.0.0 (https://github.com/helm/helm/releases)"
|
||||||
- "yaml (https://pypi.org/project/PyYAML/)"
|
- "yaml (https://pypi.org/project/PyYAML/)"
|
||||||
|
|
||||||
description:
|
description:
|
||||||
@@ -253,7 +253,7 @@ def main():
|
|||||||
if not IMP_YAML:
|
if not IMP_YAML:
|
||||||
module.fail_json(msg=missing_required_lib("yaml"), exception=IMP_YAML_ERR)
|
module.fail_json(msg=missing_required_lib("yaml"), exception=IMP_YAML_ERR)
|
||||||
|
|
||||||
# Validate Helm version >=3.0.0,<4.0.0
|
# Validate Helm version >=3.0.0
|
||||||
module.validate_helm_version()
|
module.validate_helm_version()
|
||||||
|
|
||||||
release_name = module.params.get("release_name")
|
release_name = module.params.get("release_name")
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ version_added: 1.0.0
|
|||||||
author:
|
author:
|
||||||
- Abhijeet Kasurde (@Akasurde)
|
- Abhijeet Kasurde (@Akasurde)
|
||||||
requirements:
|
requirements:
|
||||||
- "helm (https://github.com/helm/helm/releases)"
|
- "helm >= 3.0.0 (https://github.com/helm/helm/releases)"
|
||||||
description:
|
description:
|
||||||
- Manages Helm plugins.
|
- Manages Helm plugins.
|
||||||
options:
|
options:
|
||||||
@@ -48,6 +48,22 @@ options:
|
|||||||
required: false
|
required: false
|
||||||
type: str
|
type: str
|
||||||
version_added: 2.3.0
|
version_added: 2.3.0
|
||||||
|
verify:
|
||||||
|
description:
|
||||||
|
- Verify the plugin signature before installing.
|
||||||
|
- This option requires helm version >= 4.0.0
|
||||||
|
- Used with I(state=present).
|
||||||
|
type: bool
|
||||||
|
default: true
|
||||||
|
version_added: 6.4.0
|
||||||
|
keyring:
|
||||||
|
description:
|
||||||
|
- Location of public keys used for verification.
|
||||||
|
- Only valid with C(state=present), which maps to the C(helm plugin install) subcommand.
|
||||||
|
- This option requires helm version >= 4.0.0.
|
||||||
|
type: path
|
||||||
|
required: false
|
||||||
|
version_added: 6.5.0
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- kubernetes.core.helm_common_options
|
- kubernetes.core.helm_common_options
|
||||||
"""
|
"""
|
||||||
@@ -118,6 +134,9 @@ from ansible_collections.kubernetes.core.plugins.module_utils.helm_args_common i
|
|||||||
HELM_AUTH_ARG_SPEC,
|
HELM_AUTH_ARG_SPEC,
|
||||||
HELM_AUTH_MUTUALLY_EXCLUSIVE,
|
HELM_AUTH_MUTUALLY_EXCLUSIVE,
|
||||||
)
|
)
|
||||||
|
from ansible_collections.kubernetes.core.plugins.module_utils.version import (
|
||||||
|
LooseVersion,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def argument_spec():
|
def argument_spec():
|
||||||
@@ -138,6 +157,14 @@ def argument_spec():
|
|||||||
default="present",
|
default="present",
|
||||||
choices=["present", "absent", "latest"],
|
choices=["present", "absent", "latest"],
|
||||||
),
|
),
|
||||||
|
verify=dict(
|
||||||
|
type="bool",
|
||||||
|
default=True,
|
||||||
|
),
|
||||||
|
keyring=dict(
|
||||||
|
type="path",
|
||||||
|
required=False,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return arg_spec
|
return arg_spec
|
||||||
@@ -161,18 +188,50 @@ def main():
|
|||||||
mutually_exclusive=mutually_exclusive(),
|
mutually_exclusive=mutually_exclusive(),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Validate Helm version >=3.0.0,<4.0.0
|
# Validate helm version >= 3.0.0
|
||||||
module.validate_helm_version()
|
module.validate_helm_version()
|
||||||
|
|
||||||
state = module.params.get("state")
|
state = module.params.get("state")
|
||||||
|
|
||||||
|
# The ``--keyring`` flag is only supported by the ``install``, ``verify`` and
|
||||||
|
# ``package`` plugin subcommands. Of those, this module only implements
|
||||||
|
# ``install`` (state=present); using ``keyring`` with other states emits a
|
||||||
|
# warning and the option is not passed to Helm.
|
||||||
|
if module.params.get("keyring") is not None and state != "present":
|
||||||
|
module.warn(
|
||||||
|
"The 'keyring' option is only supported with state=present "
|
||||||
|
"(the 'helm plugin install' subcommand)."
|
||||||
|
)
|
||||||
|
|
||||||
helm_cmd_common = module.get_helm_binary() + " plugin"
|
helm_cmd_common = module.get_helm_binary() + " plugin"
|
||||||
|
|
||||||
if state == "present":
|
if state == "present":
|
||||||
helm_cmd_common += " install %s" % module.params.get("plugin_path")
|
helm_cmd_common += " install %s" % module.params.get("plugin_path")
|
||||||
plugin_version = module.params.get("plugin_version")
|
plugin_version = module.params.get("plugin_version")
|
||||||
|
verify = module.params.get("verify")
|
||||||
|
keyring = module.params.get("keyring")
|
||||||
if plugin_version is not None:
|
if plugin_version is not None:
|
||||||
helm_cmd_common += " --version=%s" % plugin_version
|
helm_cmd_common += " --version=%s" % plugin_version
|
||||||
|
if not verify or keyring is not None:
|
||||||
|
helm_version = module.get_helm_version()
|
||||||
|
if not verify:
|
||||||
|
if LooseVersion(helm_version) < LooseVersion("4.0.0"):
|
||||||
|
module.warn(
|
||||||
|
"verify parameter requires helm >= 4.0.0, current version is {0}".format(
|
||||||
|
helm_version
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
helm_cmd_common += " --verify=false"
|
||||||
|
if keyring is not None:
|
||||||
|
if LooseVersion(helm_version) < LooseVersion("4.0.0"):
|
||||||
|
module.warn(
|
||||||
|
"keyring parameter requires helm >= 4.0.0, current version is {0}".format(
|
||||||
|
helm_version
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
helm_cmd_common += " --keyring=" + keyring
|
||||||
if not module.check_mode:
|
if not module.check_mode:
|
||||||
rc, out, err = module.run_helm_command(
|
rc, out, err = module.run_helm_command(
|
||||||
helm_cmd_common, fails_on_error=False
|
helm_cmd_common, fails_on_error=False
|
||||||
@@ -211,9 +270,9 @@ def main():
|
|||||||
elif state == "absent":
|
elif state == "absent":
|
||||||
plugin_name = module.params.get("plugin_name")
|
plugin_name = module.params.get("plugin_name")
|
||||||
rc, output, err, command = module.get_helm_plugin_list()
|
rc, output, err, command = module.get_helm_plugin_list()
|
||||||
out = parse_helm_plugin_list(output=output.splitlines())
|
plugins = parse_helm_plugin_list(output=output.splitlines())
|
||||||
|
|
||||||
if not out:
|
if not plugins:
|
||||||
module.exit_json(
|
module.exit_json(
|
||||||
failed=False,
|
failed=False,
|
||||||
changed=False,
|
changed=False,
|
||||||
@@ -224,12 +283,7 @@ def main():
|
|||||||
rc=rc,
|
rc=rc,
|
||||||
)
|
)
|
||||||
|
|
||||||
found = False
|
if all(plugin["name"] != plugin_name for plugin in plugins):
|
||||||
for line in out:
|
|
||||||
if line[0] == plugin_name:
|
|
||||||
found = True
|
|
||||||
break
|
|
||||||
if not found:
|
|
||||||
module.exit_json(
|
module.exit_json(
|
||||||
failed=False,
|
failed=False,
|
||||||
changed=False,
|
changed=False,
|
||||||
@@ -267,9 +321,9 @@ def main():
|
|||||||
elif state == "latest":
|
elif state == "latest":
|
||||||
plugin_name = module.params.get("plugin_name")
|
plugin_name = module.params.get("plugin_name")
|
||||||
rc, output, err, command = module.get_helm_plugin_list()
|
rc, output, err, command = module.get_helm_plugin_list()
|
||||||
out = parse_helm_plugin_list(output=output.splitlines())
|
plugins = parse_helm_plugin_list(output=output.splitlines())
|
||||||
|
|
||||||
if not out:
|
if not plugins:
|
||||||
module.exit_json(
|
module.exit_json(
|
||||||
failed=False,
|
failed=False,
|
||||||
changed=False,
|
changed=False,
|
||||||
@@ -280,12 +334,7 @@ def main():
|
|||||||
rc=rc,
|
rc=rc,
|
||||||
)
|
)
|
||||||
|
|
||||||
found = False
|
if all(plugin["name"] != plugin_name for plugin in plugins):
|
||||||
for line in out:
|
|
||||||
if line[0] == plugin_name:
|
|
||||||
found = True
|
|
||||||
break
|
|
||||||
if not found:
|
|
||||||
module.exit_json(
|
module.exit_json(
|
||||||
failed=False,
|
failed=False,
|
||||||
changed=False,
|
changed=False,
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ version_added: 1.0.0
|
|||||||
author:
|
author:
|
||||||
- Abhijeet Kasurde (@Akasurde)
|
- Abhijeet Kasurde (@Akasurde)
|
||||||
requirements:
|
requirements:
|
||||||
- "helm (https://github.com/helm/helm/releases)"
|
- "helm >= 3.0.0 (https://github.com/helm/helm/releases)"
|
||||||
description:
|
description:
|
||||||
- Gather information about Helm plugins installed in namespace.
|
- Gather information about Helm plugins installed in namespace.
|
||||||
options:
|
options:
|
||||||
@@ -98,29 +98,16 @@ def main():
|
|||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Validate Helm version >=3.0.0,<4.0.0
|
# Validate helm version >= 3.0.0
|
||||||
module.validate_helm_version()
|
module.validate_helm_version()
|
||||||
|
|
||||||
plugin_name = module.params.get("plugin_name")
|
plugin_name = module.params.get("plugin_name")
|
||||||
|
|
||||||
plugin_list = []
|
|
||||||
|
|
||||||
rc, output, err, command = module.get_helm_plugin_list()
|
rc, output, err, command = module.get_helm_plugin_list()
|
||||||
|
|
||||||
out = parse_helm_plugin_list(output=output.splitlines())
|
plugins = parse_helm_plugin_list(output=output.splitlines())
|
||||||
|
if plugin_name is not None:
|
||||||
for line in out:
|
plugins = [plugin for plugin in plugins if plugin.get("name") == plugin_name]
|
||||||
if plugin_name is None:
|
|
||||||
plugin_list.append(
|
|
||||||
{"name": line[0], "version": line[1], "description": line[2]}
|
|
||||||
)
|
|
||||||
continue
|
|
||||||
|
|
||||||
if plugin_name == line[0]:
|
|
||||||
plugin_list.append(
|
|
||||||
{"name": line[0], "version": line[1], "description": line[2]}
|
|
||||||
)
|
|
||||||
break
|
|
||||||
|
|
||||||
module.exit_json(
|
module.exit_json(
|
||||||
changed=True,
|
changed=True,
|
||||||
@@ -128,7 +115,7 @@ def main():
|
|||||||
stdout=output,
|
stdout=output,
|
||||||
stderr=err,
|
stderr=err,
|
||||||
rc=rc,
|
rc=rc,
|
||||||
plugin_list=plugin_list,
|
plugin_list=plugins,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ description:
|
|||||||
- There are options for unpacking the chart after download.
|
- There are options for unpacking the chart after download.
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "helm >= 3.0, <4.0.0 (https://github.com/helm/helm/releases)"
|
- "helm >= 3.0.0 (https://github.com/helm/helm/releases)"
|
||||||
|
|
||||||
options:
|
options:
|
||||||
chart_ref:
|
chart_ref:
|
||||||
@@ -122,6 +122,13 @@ options:
|
|||||||
- The path of a helm binary to use.
|
- The path of a helm binary to use.
|
||||||
required: false
|
required: false
|
||||||
type: path
|
type: path
|
||||||
|
plain_http:
|
||||||
|
description:
|
||||||
|
- Use HTTP instead of HTTPS when working with OCI registries
|
||||||
|
- Requires Helm >= 3.13.0
|
||||||
|
type: bool
|
||||||
|
default: False
|
||||||
|
version_added: 6.1.0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = r"""
|
EXAMPLES = r"""
|
||||||
@@ -353,6 +360,7 @@ def main():
|
|||||||
chart_ssl_cert_file=dict(type="path"),
|
chart_ssl_cert_file=dict(type="path"),
|
||||||
chart_ssl_key_file=dict(type="path"),
|
chart_ssl_key_file=dict(type="path"),
|
||||||
binary_path=dict(type="path"),
|
binary_path=dict(type="path"),
|
||||||
|
plain_http=dict(type="bool", default=False),
|
||||||
)
|
)
|
||||||
module = AnsibleHelmModule(
|
module = AnsibleHelmModule(
|
||||||
argument_spec=argspec,
|
argument_spec=argspec,
|
||||||
@@ -364,7 +372,7 @@ def main():
|
|||||||
mutually_exclusive=[("chart_version", "chart_devel")],
|
mutually_exclusive=[("chart_version", "chart_devel")],
|
||||||
)
|
)
|
||||||
|
|
||||||
# Validate Helm version >=3.0.0,<4.0.0
|
# Validate Helm version >=3.0.0
|
||||||
module.validate_helm_version()
|
module.validate_helm_version()
|
||||||
|
|
||||||
helm_version = module.get_helm_version()
|
helm_version = module.get_helm_version()
|
||||||
@@ -374,6 +382,7 @@ def main():
|
|||||||
chart_ca_cert="3.1.0",
|
chart_ca_cert="3.1.0",
|
||||||
chart_ssl_cert_file="3.1.0",
|
chart_ssl_cert_file="3.1.0",
|
||||||
chart_ssl_key_file="3.1.0",
|
chart_ssl_key_file="3.1.0",
|
||||||
|
plain_http="3.13.0",
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_version_requirement(opt):
|
def test_version_requirement(opt):
|
||||||
@@ -413,6 +422,7 @@ def main():
|
|||||||
skip_tls_certs_check=dict(key="insecure-skip-tls-verify"),
|
skip_tls_certs_check=dict(key="insecure-skip-tls-verify"),
|
||||||
chart_devel=dict(key="devel"),
|
chart_devel=dict(key="devel"),
|
||||||
untar_chart=dict(key="untar"),
|
untar_chart=dict(key="untar"),
|
||||||
|
plain_http=dict(key="plain-http"),
|
||||||
)
|
)
|
||||||
|
|
||||||
for k, v in helm_flag_args.items():
|
for k, v in helm_flag_args.items():
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ author:
|
|||||||
- Yuriy Novostavskiy (@yurnov)
|
- Yuriy Novostavskiy (@yurnov)
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "helm (https://github.com/helm/helm/releases) >= 3.8.0, <4.0.0"
|
- "helm (https://github.com/helm/helm/releases) >= 3.8.0"
|
||||||
|
|
||||||
description:
|
description:
|
||||||
- Helm registry authentication module allows you to login C(helm registry login) and logout C(helm registry logout) from a Helm registry.
|
- Helm registry authentication module allows you to login C(helm registry login) and logout C(helm registry logout) from a Helm registry.
|
||||||
@@ -75,6 +75,14 @@ options:
|
|||||||
- Path to the CA certificate SSL file for verify registry server certificate.
|
- Path to the CA certificate SSL file for verify registry server certificate.
|
||||||
required: false
|
required: false
|
||||||
type: path
|
type: path
|
||||||
|
plain_http:
|
||||||
|
description:
|
||||||
|
- Use insecure HTTP connections for C(helm registry login).
|
||||||
|
- Requires Helm >= 3.18.0
|
||||||
|
required: false
|
||||||
|
type: bool
|
||||||
|
default: False
|
||||||
|
version_added: 6.4.0
|
||||||
binary_path:
|
binary_path:
|
||||||
description:
|
description:
|
||||||
- The path of a helm binary to use.
|
- The path of a helm binary to use.
|
||||||
@@ -98,17 +106,23 @@ EXAMPLES = r"""
|
|||||||
RETURN = r"""
|
RETURN = r"""
|
||||||
stdout:
|
stdout:
|
||||||
type: str
|
type: str
|
||||||
description: Full C(helm) command stdout, in case you want to display it or examine the event log
|
description:
|
||||||
|
- Full C(helm) command stdout, in case you want to display it or examine the event log.
|
||||||
|
- As of Helm 4.2.1 success messages such as C(Login Succeeded) are printed to stdout
|
||||||
|
(see U(https://github.com/helm/helm/pull/32056)). On earlier versions they are printed to stderr.
|
||||||
returned: always
|
returned: always
|
||||||
stout_lines:
|
sample: 'Login Succeeded\n'
|
||||||
|
stdout_lines:
|
||||||
type: list
|
type: list
|
||||||
description: Full C(helm) command stdout, in case you want to display it or examine the event log
|
description: Full C(helm) command stdout, in case you want to display it or examine the event log
|
||||||
returned: always
|
returned: always
|
||||||
stderr:
|
stderr:
|
||||||
type: str
|
type: str
|
||||||
description: >-
|
description:
|
||||||
Full C(helm) command stderr, in case you want to display it or examine the event log.
|
- 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.
|
- Please note that the helm binary may print messages to stderr even if the command is successful.
|
||||||
|
- On Helm versions earlier than 4.2.1, success messages such as C(Login Succeeded) are printed
|
||||||
|
here; as of Helm 4.2.1 they are printed to stdout (see U(https://github.com/helm/helm/pull/32056)).
|
||||||
returned: always
|
returned: always
|
||||||
sample: 'Login Succeeded\n'
|
sample: 'Login Succeeded\n'
|
||||||
stderr_lines:
|
stderr_lines:
|
||||||
@@ -148,6 +162,7 @@ def arg_spec():
|
|||||||
key_file=dict(type="path", required=False),
|
key_file=dict(type="path", required=False),
|
||||||
cert_file=dict(type="path", required=False),
|
cert_file=dict(type="path", required=False),
|
||||||
ca_file=dict(type="path", required=False),
|
ca_file=dict(type="path", required=False),
|
||||||
|
plain_http=dict(type="bool", default=False),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -160,6 +175,7 @@ def login(
|
|||||||
key_file,
|
key_file,
|
||||||
cert_file,
|
cert_file,
|
||||||
ca_file,
|
ca_file,
|
||||||
|
plain_http,
|
||||||
):
|
):
|
||||||
login_command = command + " registry login " + host
|
login_command = command + " registry login " + host
|
||||||
|
|
||||||
@@ -177,6 +193,8 @@ def login(
|
|||||||
|
|
||||||
if ca_file is not None:
|
if ca_file is not None:
|
||||||
login_command += " --ca-file=" + ca_file
|
login_command += " --ca-file=" + ca_file
|
||||||
|
if plain_http:
|
||||||
|
login_command += " --plain-http"
|
||||||
|
|
||||||
return login_command
|
return login_command
|
||||||
|
|
||||||
@@ -194,8 +212,8 @@ def main():
|
|||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Validate Helm version >=3.0.0,<4.0.0
|
# Validate Helm version >=3.8.0
|
||||||
module.validate_helm_version()
|
module.validate_helm_version(version="3.8.0")
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
|
|
||||||
@@ -207,6 +225,19 @@ def main():
|
|||||||
key_file = module.params.get("key_file")
|
key_file = module.params.get("key_file")
|
||||||
cert_file = module.params.get("cert_file")
|
cert_file = module.params.get("cert_file")
|
||||||
ca_file = module.params.get("ca_file")
|
ca_file = module.params.get("ca_file")
|
||||||
|
plain_http = module.params.get("plain_http")
|
||||||
|
|
||||||
|
helm_version = module.get_helm_version()
|
||||||
|
|
||||||
|
if plain_http:
|
||||||
|
if LooseVersion(helm_version) < LooseVersion("3.18.0"):
|
||||||
|
module.warn(
|
||||||
|
"plain_http option requires helm >= 3.18.0, current version is {0}".format(
|
||||||
|
helm_version
|
||||||
|
)
|
||||||
|
)
|
||||||
|
# reset option
|
||||||
|
plain_http = False
|
||||||
|
|
||||||
helm_cmd = module.get_helm_binary()
|
helm_cmd = module.get_helm_binary()
|
||||||
|
|
||||||
@@ -215,7 +246,15 @@ def main():
|
|||||||
changed = True
|
changed = True
|
||||||
elif state == "present":
|
elif state == "present":
|
||||||
helm_cmd = login(
|
helm_cmd = login(
|
||||||
helm_cmd, host, insecure, username, password, key_file, cert_file, ca_file
|
helm_cmd,
|
||||||
|
host,
|
||||||
|
insecure,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
key_file,
|
||||||
|
cert_file,
|
||||||
|
ca_file,
|
||||||
|
plain_http,
|
||||||
)
|
)
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
@@ -238,7 +277,6 @@ def main():
|
|||||||
command=helm_cmd,
|
command=helm_cmd,
|
||||||
)
|
)
|
||||||
|
|
||||||
helm_version = module.get_helm_version()
|
|
||||||
if LooseVersion(helm_version) >= LooseVersion("3.18.0") and state == "absent":
|
if LooseVersion(helm_version) >= LooseVersion("3.18.0") and state == "absent":
|
||||||
# https://github.com/ansible-collections/kubernetes.core/issues/944
|
# https://github.com/ansible-collections/kubernetes.core/issues/944
|
||||||
module.warn(
|
module.warn(
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ author:
|
|||||||
- Lucas Boisserie (@LucasBoisserie)
|
- Lucas Boisserie (@LucasBoisserie)
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "helm (https://github.com/helm/helm/releases)"
|
- "helm >= 3.0.0 (https://github.com/helm/helm/releases)"
|
||||||
- "yaml (https://pypi.org/project/PyYAML/)"
|
- "yaml (https://pypi.org/project/PyYAML/)"
|
||||||
|
|
||||||
description:
|
description:
|
||||||
@@ -295,7 +295,7 @@ def main():
|
|||||||
if not IMP_YAML:
|
if not IMP_YAML:
|
||||||
module.fail_json(msg=missing_required_lib("yaml"), exception=IMP_YAML_ERR)
|
module.fail_json(msg=missing_required_lib("yaml"), exception=IMP_YAML_ERR)
|
||||||
|
|
||||||
# Validate Helm version >=3.0.0,<4.0.0
|
# Validate Helm version >= 3.0.0
|
||||||
module.validate_helm_version()
|
module.validate_helm_version()
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ author:
|
|||||||
description:
|
description:
|
||||||
- Render chart templates to an output directory or as text of concatenated yaml documents.
|
- Render chart templates to an output directory or as text of concatenated yaml documents.
|
||||||
|
|
||||||
|
requirements:
|
||||||
|
- "helm >= 3.0.0 (https://github.com/helm/helm/releases)"
|
||||||
|
- "yaml (https://pypi.org/project/PyYAML/)"
|
||||||
|
|
||||||
options:
|
options:
|
||||||
binary_path:
|
binary_path:
|
||||||
description:
|
description:
|
||||||
@@ -147,6 +151,13 @@ options:
|
|||||||
- json
|
- json
|
||||||
- file
|
- file
|
||||||
version_added: 2.4.0
|
version_added: 2.4.0
|
||||||
|
plain_http:
|
||||||
|
description:
|
||||||
|
- Use HTTP instead of HTTPS when working with OCI registries
|
||||||
|
- Requires Helm >= 3.13.0
|
||||||
|
type: bool
|
||||||
|
default: False
|
||||||
|
version_added: 6.1.0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = r"""
|
EXAMPLES = r"""
|
||||||
@@ -217,6 +228,10 @@ except ImportError:
|
|||||||
from ansible.module_utils.basic import missing_required_lib
|
from ansible.module_utils.basic import missing_required_lib
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.helm import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.helm import (
|
||||||
AnsibleHelmModule,
|
AnsibleHelmModule,
|
||||||
|
strip_registry_progress,
|
||||||
|
)
|
||||||
|
from ansible_collections.kubernetes.core.plugins.module_utils.version import (
|
||||||
|
LooseVersion,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -236,6 +251,7 @@ def template(
|
|||||||
values_files=None,
|
values_files=None,
|
||||||
include_crds=False,
|
include_crds=False,
|
||||||
set_values=None,
|
set_values=None,
|
||||||
|
plain_http=False,
|
||||||
):
|
):
|
||||||
cmd += " template "
|
cmd += " template "
|
||||||
|
|
||||||
@@ -262,6 +278,9 @@ def template(
|
|||||||
if insecure_registry:
|
if insecure_registry:
|
||||||
cmd += " --insecure-skip-tls-verify"
|
cmd += " --insecure-skip-tls-verify"
|
||||||
|
|
||||||
|
if plain_http:
|
||||||
|
cmd += " --plain-http"
|
||||||
|
|
||||||
if show_only:
|
if show_only:
|
||||||
for template in show_only:
|
for template in show_only:
|
||||||
cmd += " -s " + template
|
cmd += " -s " + template
|
||||||
@@ -307,6 +326,7 @@ def main():
|
|||||||
values_files=dict(type="list", default=[], elements="str"),
|
values_files=dict(type="list", default=[], elements="str"),
|
||||||
update_repo_cache=dict(type="bool", default=False),
|
update_repo_cache=dict(type="bool", default=False),
|
||||||
set_values=dict(type="list", elements="dict"),
|
set_values=dict(type="list", elements="dict"),
|
||||||
|
plain_http=dict(type="bool", default=False),
|
||||||
),
|
),
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
@@ -327,15 +347,25 @@ def main():
|
|||||||
values_files = module.params.get("values_files")
|
values_files = module.params.get("values_files")
|
||||||
update_repo_cache = module.params.get("update_repo_cache")
|
update_repo_cache = module.params.get("update_repo_cache")
|
||||||
set_values = module.params.get("set_values")
|
set_values = module.params.get("set_values")
|
||||||
|
plain_http = module.params.get("plain_http")
|
||||||
|
|
||||||
if not IMP_YAML:
|
if not IMP_YAML:
|
||||||
module.fail_json(msg=missing_required_lib("yaml"), exception=IMP_YAML_ERR)
|
module.fail_json(msg=missing_required_lib("yaml"), exception=IMP_YAML_ERR)
|
||||||
|
|
||||||
# Validate Helm version >=3.0.0,<4.0.0
|
# Validate Helm version >=3.0.0
|
||||||
module.validate_helm_version()
|
module.validate_helm_version()
|
||||||
|
|
||||||
helm_cmd = module.get_helm_binary()
|
helm_cmd = module.get_helm_binary()
|
||||||
|
|
||||||
|
if plain_http:
|
||||||
|
helm_version = module.get_helm_version()
|
||||||
|
if LooseVersion(helm_version) < LooseVersion("3.13.0"):
|
||||||
|
module.fail_json(
|
||||||
|
msg="plain_http requires helm >= 3.13.0, current version is {0}".format(
|
||||||
|
helm_version
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
if update_repo_cache:
|
if update_repo_cache:
|
||||||
update_cmd = helm_cmd + " repo update"
|
update_cmd = helm_cmd + " repo update"
|
||||||
module.run_helm_command(update_cmd)
|
module.run_helm_command(update_cmd)
|
||||||
@@ -360,10 +390,14 @@ def main():
|
|||||||
values_files=values_files,
|
values_files=values_files,
|
||||||
include_crds=include_crds,
|
include_crds=include_crds,
|
||||||
set_values=set_values_args,
|
set_values=set_values_args,
|
||||||
|
plain_http=plain_http,
|
||||||
)
|
)
|
||||||
|
|
||||||
if not check_mode:
|
if not check_mode:
|
||||||
rc, out, err = module.run_helm_command(tmpl_cmd)
|
rc, out, err = module.run_helm_command(tmpl_cmd)
|
||||||
|
# 'stdout' is documented to hold the rendered templates, so keep helm's
|
||||||
|
# OCI registry progress messages out of it.
|
||||||
|
out = strip_registry_progress(out)
|
||||||
else:
|
else:
|
||||||
out = err = ""
|
out = err = ""
|
||||||
rc = 0
|
rc = 0
|
||||||
|
|||||||
@@ -40,9 +40,8 @@ options:
|
|||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- Determines if an object should be created, patched, or deleted. When set to C(present), an object will be
|
- Determines if an object should be created, patched, or deleted. When set to C(present), an object will be
|
||||||
created, if it does not already exist. If set to C(absent), an existing object will be deleted. If set to
|
created if it does not already exist, and an existing object will be patched if its attributes differ from
|
||||||
C(present), an existing object will be patched, if its attributes differ from those specified using
|
those specified using I(resource_definition) or I(src). If set to C(absent), an existing object will be deleted.
|
||||||
I(resource_definition) or I(src).
|
|
||||||
- C(patched) state is an existing resource that has a given patch applied. If the resource doesn't exist, silently skip it (do not raise an error).
|
- C(patched) state is an existing resource that has a given patch applied. If the resource doesn't exist, silently skip it (do not raise an error).
|
||||||
type: str
|
type: str
|
||||||
default: present
|
default: present
|
||||||
|
|||||||
@@ -76,9 +76,21 @@ options:
|
|||||||
- This option is ignored when I(content) is set or when I(state) is set to C(from_pod).
|
- This option is ignored when I(content) is set or when I(state) is set to C(from_pod).
|
||||||
type: bool
|
type: bool
|
||||||
default: False
|
default: False
|
||||||
|
copy_timeout:
|
||||||
|
description:
|
||||||
|
- Maximum time in seconds to spend streaming the archive to the pod and waiting for the remote
|
||||||
|
C(tar) process to finish extracting it.
|
||||||
|
- Raise this when copying large files over a slow connection.
|
||||||
|
- This option is ignored when I(state) is set to C(from_pod).
|
||||||
|
type: int
|
||||||
|
default: 300
|
||||||
|
version_added: 6.6.0
|
||||||
|
|
||||||
notes:
|
notes:
|
||||||
- the tar binary is required on the container when copying from local filesystem to pod.
|
- the tar binary is required on the container when copying from local filesystem to pod.
|
||||||
|
- a POSIX shell at C(/bin/sh) and C(head) are also used, when present, to bound the archive
|
||||||
|
sent to the container so that the module can confirm the copy finished. Without them the
|
||||||
|
copy still runs but completion cannot be verified, and a warning is emitted.
|
||||||
- the (init) container has to be started before you copy files or directories to it.
|
- the (init) container has to be started before you copy files or directories to it.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -140,7 +152,7 @@ result:
|
|||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
from ansible.module_utils._text import to_native
|
from ansible.module_utils.common.text.converters 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,
|
||||||
)
|
)
|
||||||
@@ -180,6 +192,7 @@ def argspec():
|
|||||||
"choices": ["to_pod", "from_pod"],
|
"choices": ["to_pod", "from_pod"],
|
||||||
}
|
}
|
||||||
argument_spec["no_preserve"] = {"type": "bool", "default": False}
|
argument_spec["no_preserve"] = {"type": "bool", "default": False}
|
||||||
|
argument_spec["copy_timeout"] = {"type": "int", "default": 300}
|
||||||
return argument_spec
|
return argument_spec
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ import time
|
|||||||
import traceback
|
import traceback
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from ansible.module_utils._text import to_native
|
from ansible.module_utils.common.text.converters 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,
|
||||||
)
|
)
|
||||||
@@ -230,7 +230,7 @@ def filter_pods(pods, force, ignore_daemonset, delete_emptydir_data):
|
|||||||
else:
|
else:
|
||||||
to_delete.append((pod.metadata.namespace, pod.metadata.name))
|
to_delete.append((pod.metadata.namespace, pod.metadata.name))
|
||||||
|
|
||||||
warnings, errors = [], []
|
warnings, errors, info = [], [], []
|
||||||
if unmanaged:
|
if unmanaged:
|
||||||
pod_names = ",".join([pod[0] + "/" + pod[1] for pod in unmanaged])
|
pod_names = ",".join([pod[0] + "/" + pod[1] for pod in unmanaged])
|
||||||
if not force:
|
if not force:
|
||||||
@@ -242,7 +242,7 @@ def filter_pods(pods, force, ignore_daemonset, delete_emptydir_data):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# Pod not managed will be deleted as 'force' is true
|
# Pod not managed will be deleted as 'force' is true
|
||||||
warnings.append(
|
info.append(
|
||||||
"Deleting Pods not managed by ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet: {0}.".format(
|
"Deleting Pods not managed by ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet: {0}.".format(
|
||||||
pod_names
|
pod_names
|
||||||
)
|
)
|
||||||
@@ -264,7 +264,7 @@ def filter_pods(pods, force, ignore_daemonset, delete_emptydir_data):
|
|||||||
"cannot delete Pods with local storage: {0}.".format(pod_names)
|
"cannot delete Pods with local storage: {0}.".format(pod_names)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
warnings.append("Deleting Pods with local storage: {0}.".format(pod_names))
|
info.append("Deleting Pods with local storage: {0}.".format(pod_names))
|
||||||
for pod in localStorage:
|
for pod in localStorage:
|
||||||
to_delete.append((pod[0], pod[1]))
|
to_delete.append((pod[0], pod[1]))
|
||||||
|
|
||||||
@@ -278,8 +278,8 @@ def filter_pods(pods, force, ignore_daemonset, delete_emptydir_data):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
warnings.append("Ignoring DaemonSet-managed Pods: {0}.".format(pod_names))
|
info.append("Ignoring DaemonSet-managed Pods: {0}.".format(pod_names))
|
||||||
return to_delete, warnings, errors
|
return to_delete, warnings, errors, info
|
||||||
|
|
||||||
|
|
||||||
class K8sDrainAnsible(object):
|
class K8sDrainAnsible(object):
|
||||||
@@ -334,18 +334,19 @@ class K8sDrainAnsible(object):
|
|||||||
def evict_pods(self, pods):
|
def evict_pods(self, pods):
|
||||||
for namespace, name in pods:
|
for namespace, name in pods:
|
||||||
try:
|
try:
|
||||||
if self._drain_options.get("disable_eviction"):
|
if not self._module.check_mode:
|
||||||
self._api_instance.delete_namespaced_pod(
|
if self._drain_options.get("disable_eviction"):
|
||||||
name=name, namespace=namespace, body=self._delete_options
|
self._api_instance.delete_namespaced_pod(
|
||||||
)
|
name=name, namespace=namespace, body=self._delete_options
|
||||||
else:
|
)
|
||||||
body = v1_eviction(
|
else:
|
||||||
delete_options=self._delete_options,
|
body = v1_eviction(
|
||||||
metadata=V1ObjectMeta(name=name, namespace=namespace),
|
delete_options=self._delete_options,
|
||||||
)
|
metadata=V1ObjectMeta(name=name, namespace=namespace),
|
||||||
self._api_instance.create_namespaced_pod_eviction(
|
)
|
||||||
name=name, namespace=namespace, body=body
|
self._api_instance.create_namespaced_pod_eviction(
|
||||||
)
|
name=name, namespace=namespace, body=body
|
||||||
|
)
|
||||||
self._changed = True
|
self._changed = True
|
||||||
except ApiException as exc:
|
except ApiException as exc:
|
||||||
if exc.reason != "Not Found":
|
if exc.reason != "Not Found":
|
||||||
@@ -362,11 +363,7 @@ class K8sDrainAnsible(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def list_pods(self):
|
def list_pods(self):
|
||||||
params = {
|
params = {"field_selector": "spec.nodeName=" + self._module.params.get("name")}
|
||||||
"field_selector": "spec.nodeName={name}".format(
|
|
||||||
name=self._module.params.get("name")
|
|
||||||
)
|
|
||||||
}
|
|
||||||
pod_selectors = self._module.params.get("pod_selectors")
|
pod_selectors = self._module.params.get("pod_selectors")
|
||||||
if pod_selectors:
|
if pod_selectors:
|
||||||
params["label_selector"] = ",".join(pod_selectors)
|
params["label_selector"] = ",".join(pod_selectors)
|
||||||
@@ -376,7 +373,8 @@ class K8sDrainAnsible(object):
|
|||||||
# Mark node as unschedulable
|
# Mark node as unschedulable
|
||||||
result = []
|
result = []
|
||||||
if not node_unschedulable:
|
if not node_unschedulable:
|
||||||
self.patch_node(unschedulable=True)
|
if not self._module.check_mode:
|
||||||
|
self.patch_node(unschedulable=True)
|
||||||
result.append(
|
result.append(
|
||||||
"node {0} marked unschedulable.".format(self._module.params.get("name"))
|
"node {0} marked unschedulable.".format(self._module.params.get("name"))
|
||||||
)
|
)
|
||||||
@@ -391,7 +389,8 @@ class K8sDrainAnsible(object):
|
|||||||
def _revert_node_patch():
|
def _revert_node_patch():
|
||||||
if self._changed:
|
if self._changed:
|
||||||
self._changed = False
|
self._changed = False
|
||||||
self.patch_node(unschedulable=False)
|
if not self._module.check_mode:
|
||||||
|
self.patch_node(unschedulable=False)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pod_list = self.list_pods()
|
pod_list = self.list_pods()
|
||||||
@@ -401,7 +400,7 @@ class K8sDrainAnsible(object):
|
|||||||
delete_emptydir_data = self._drain_options.get(
|
delete_emptydir_data = self._drain_options.get(
|
||||||
"delete_emptydir_data", False
|
"delete_emptydir_data", False
|
||||||
)
|
)
|
||||||
pods, warnings, errors = filter_pods(
|
pods, warnings, errors, info = filter_pods(
|
||||||
pod_list.items, force, ignore_daemonset, delete_emptydir_data
|
pod_list.items, force, ignore_daemonset, delete_emptydir_data
|
||||||
)
|
)
|
||||||
if errors:
|
if errors:
|
||||||
@@ -431,18 +430,25 @@ class K8sDrainAnsible(object):
|
|||||||
if pods:
|
if pods:
|
||||||
self.evict_pods(pods)
|
self.evict_pods(pods)
|
||||||
number_pod = len(pods)
|
number_pod = len(pods)
|
||||||
if self._drain_options.get("wait_timeout") is not None:
|
if self._module.check_mode:
|
||||||
warn = self.wait_for_pod_deletion(
|
result.append(
|
||||||
pods,
|
"Would have deleted {0} Pod(s) from node if not in check mode.".format(
|
||||||
self._drain_options.get("wait_timeout"),
|
number_pod
|
||||||
self._drain_options.get("wait_sleep"),
|
)
|
||||||
)
|
)
|
||||||
if warn:
|
else:
|
||||||
warnings.append(warn)
|
wait_timeout = self._drain_options.get("wait_timeout")
|
||||||
result.append("{0} Pod(s) deleted from node.".format(number_pod))
|
wait_sleep = self._drain_options.get("wait_sleep")
|
||||||
|
if wait_timeout is not None:
|
||||||
|
warn = self.wait_for_pod_deletion(pods, wait_timeout, wait_sleep)
|
||||||
|
if warn:
|
||||||
|
warnings.append(warn)
|
||||||
|
result.append("{0} Pod(s) deleted from node.".format(number_pod))
|
||||||
if warnings:
|
if warnings:
|
||||||
for warning in warnings:
|
for warning in warnings:
|
||||||
self._module.warn(warning)
|
self._module.warn(warning)
|
||||||
|
for line in info:
|
||||||
|
self._module.debug(line)
|
||||||
return dict(result=" ".join(result))
|
return dict(result=" ".join(result))
|
||||||
|
|
||||||
def patch_node(self, unschedulable):
|
def patch_node(self, unschedulable):
|
||||||
@@ -483,7 +489,8 @@ class K8sDrainAnsible(object):
|
|||||||
self._module.exit_json(
|
self._module.exit_json(
|
||||||
result="node {0} already marked unschedulable.".format(name)
|
result="node {0} already marked unschedulable.".format(name)
|
||||||
)
|
)
|
||||||
self.patch_node(unschedulable=True)
|
if not self._module.check_mode:
|
||||||
|
self.patch_node(unschedulable=True)
|
||||||
result["result"] = "node {0} marked unschedulable.".format(name)
|
result["result"] = "node {0} marked unschedulable.".format(name)
|
||||||
self._changed = True
|
self._changed = True
|
||||||
|
|
||||||
@@ -492,7 +499,8 @@ class K8sDrainAnsible(object):
|
|||||||
self._module.exit_json(
|
self._module.exit_json(
|
||||||
result="node {0} already marked schedulable.".format(name)
|
result="node {0} already marked schedulable.".format(name)
|
||||||
)
|
)
|
||||||
self.patch_node(unschedulable=False)
|
if not self._module.check_mode:
|
||||||
|
self.patch_node(unschedulable=False)
|
||||||
result["result"] = "node {0} marked schedulable.".format(name)
|
result["result"] = "node {0} marked schedulable.".format(name)
|
||||||
self._changed = True
|
self._changed = True
|
||||||
|
|
||||||
@@ -535,7 +543,9 @@ def argspec():
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleK8SModule(module_class=AnsibleModule, argument_spec=argspec())
|
module = AnsibleK8SModule(
|
||||||
|
module_class=AnsibleModule, argument_spec=argspec(), supports_check_mode=True
|
||||||
|
)
|
||||||
|
|
||||||
if not HAS_EVICTION_API:
|
if not HAS_EVICTION_API:
|
||||||
module.fail_json(
|
module.fail_json(
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ 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.module_utils.common.text.converters 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,
|
||||||
)
|
)
|
||||||
|
|||||||
+40
-10
@@ -53,6 +53,15 @@ options:
|
|||||||
type: list
|
type: list
|
||||||
elements: str
|
elements: str
|
||||||
version_added: 3.0.0
|
version_added: 3.0.0
|
||||||
|
metadata_only:
|
||||||
|
description:
|
||||||
|
- Request metadata only response from the Kubernetes API server.
|
||||||
|
- This feature is useful for clients that only need to check for the existence of an object,
|
||||||
|
- or that only need to read its metadata.
|
||||||
|
- It can significantly reduce the size of the response from the API server.
|
||||||
|
type: bool
|
||||||
|
default: false
|
||||||
|
version_added: 6.6.0
|
||||||
|
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- kubernetes.core.k8s_auth_options
|
- kubernetes.core.k8s_auth_options
|
||||||
@@ -135,6 +144,12 @@ EXAMPLES = r"""
|
|||||||
(ocp_bootstrap_status.resources[0].data.status == 'complete')
|
(ocp_bootstrap_status.resources[0].data.status == 'complete')
|
||||||
retries: 60
|
retries: 60
|
||||||
delay: 15
|
delay: 15
|
||||||
|
|
||||||
|
- name: Get a list of all pods metadata only
|
||||||
|
kubernetes.core.k8s_info:
|
||||||
|
kind: Pod
|
||||||
|
metadata_only: true
|
||||||
|
register: pod_metadata_list
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = r"""
|
RETURN = r"""
|
||||||
@@ -179,6 +194,8 @@ 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,
|
||||||
|
METADATA_ONLY_HEADER_VALUES,
|
||||||
|
METADATA_ONLY_HEADERS_SPEC,
|
||||||
WAIT_ARG_SPEC,
|
WAIT_ARG_SPEC,
|
||||||
)
|
)
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
|
from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import (
|
||||||
@@ -216,15 +233,16 @@ def argspec():
|
|||||||
args = copy.deepcopy(AUTH_ARG_SPEC)
|
args = copy.deepcopy(AUTH_ARG_SPEC)
|
||||||
args.update(WAIT_ARG_SPEC)
|
args.update(WAIT_ARG_SPEC)
|
||||||
args.update(
|
args.update(
|
||||||
dict(
|
{
|
||||||
kind=dict(required=True),
|
"kind": {"required": True},
|
||||||
api_version=dict(default="v1", aliases=["api", "version"]),
|
"api_version": {"default": "v1", "aliases": ["api", "version"]},
|
||||||
name=dict(),
|
"name": {},
|
||||||
namespace=dict(),
|
"namespace": {},
|
||||||
label_selectors=dict(type="list", elements="str", default=[]),
|
"label_selectors": {"type": "list", "elements": "str", "default": []},
|
||||||
field_selectors=dict(type="list", elements="str", default=[]),
|
"field_selectors": {"type": "list", "elements": "str", "default": []},
|
||||||
hidden_fields=dict(type="list", elements="str"),
|
"hidden_fields": {"type": "list", "elements": "str"},
|
||||||
)
|
"metadata_only": {"type": "bool", "default": False},
|
||||||
|
}
|
||||||
)
|
)
|
||||||
return args
|
return args
|
||||||
|
|
||||||
@@ -233,8 +251,20 @@ def main():
|
|||||||
module = AnsibleK8SModule(
|
module = AnsibleK8SModule(
|
||||||
module_class=AnsibleModule, argument_spec=argspec(), supports_check_mode=True
|
module_class=AnsibleModule, argument_spec=argspec(), supports_check_mode=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
metadata_only_headers = {}
|
||||||
|
if module.params["metadata_only"]:
|
||||||
|
metadata_only_headers = copy.deepcopy(METADATA_ONLY_HEADERS_SPEC)
|
||||||
|
metadata_only_headers.update(
|
||||||
|
{"accept": METADATA_ONLY_HEADER_VALUES["partial_object_list"]}
|
||||||
|
)
|
||||||
|
if module.params["name"]:
|
||||||
|
metadata_only_headers.update(
|
||||||
|
{"accept": METADATA_ONLY_HEADER_VALUES["partial_object"]}
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
client = get_api_client(module)
|
client = get_api_client(module, **metadata_only_headers)
|
||||||
svc = K8sService(client, module)
|
svc = K8sService(client, module)
|
||||||
execute_module(module, svc)
|
execute_module(module, svc)
|
||||||
except CoreException as e:
|
except CoreException as e:
|
||||||
|
|||||||
@@ -33,6 +33,14 @@ options:
|
|||||||
aliases:
|
aliases:
|
||||||
- api
|
- api
|
||||||
- version
|
- version
|
||||||
|
hidden_fields:
|
||||||
|
description:
|
||||||
|
- List of fields to hide from the diff output.
|
||||||
|
- This is useful for fields that are not relevant to the patch operation, such as `metadata.managedFields`.
|
||||||
|
type: list
|
||||||
|
elements: str
|
||||||
|
default: []
|
||||||
|
version_added: 6.1.0
|
||||||
kind:
|
kind:
|
||||||
description:
|
description:
|
||||||
- Use to specify an object model.
|
- Use to specify an object model.
|
||||||
@@ -127,8 +135,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.common.text.converters 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,
|
||||||
)
|
)
|
||||||
@@ -147,6 +155,7 @@ from ansible_collections.kubernetes.core.plugins.module_utils.k8s.exceptions imp
|
|||||||
)
|
)
|
||||||
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,
|
||||||
|
hide_fields,
|
||||||
)
|
)
|
||||||
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,
|
||||||
@@ -174,6 +183,7 @@ JSON_PATCH_ARGS = {
|
|||||||
"namespace": {"type": "str"},
|
"namespace": {"type": "str"},
|
||||||
"name": {"type": "str", "required": True},
|
"name": {"type": "str", "required": True},
|
||||||
"patch": {"type": "list", "required": True, "elements": "dict"},
|
"patch": {"type": "list", "required": True, "elements": "dict"},
|
||||||
|
"hidden_fields": {"type": "list", "elements": "str", "default": []},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -203,6 +213,7 @@ def execute_module(module, client):
|
|||||||
namespace = module.params.get("namespace")
|
namespace = module.params.get("namespace")
|
||||||
patch = module.params.get("patch")
|
patch = module.params.get("patch")
|
||||||
|
|
||||||
|
hidden_fields = module.params.get("hidden_fields")
|
||||||
wait = module.params.get("wait")
|
wait = module.params.get("wait")
|
||||||
wait_sleep = module.params.get("wait_sleep")
|
wait_sleep = module.params.get("wait_sleep")
|
||||||
wait_timeout = module.params.get("wait_timeout")
|
wait_timeout = module.params.get("wait_timeout")
|
||||||
@@ -260,13 +271,13 @@ def execute_module(module, client):
|
|||||||
module.fail_json(msg=msg, error=to_native(exc), status="", reason="")
|
module.fail_json(msg=msg, error=to_native(exc), status="", reason="")
|
||||||
|
|
||||||
success = True
|
success = True
|
||||||
result = {"result": obj}
|
result = {"result": hide_fields(obj, hidden_fields)}
|
||||||
if wait and not module.check_mode:
|
if wait and not module.check_mode:
|
||||||
waiter = get_waiter(client, resource, condition=wait_condition)
|
waiter = get_waiter(client, resource, condition=wait_condition)
|
||||||
success, result["result"], result["duration"] = waiter.wait(
|
success, result["result"], result["duration"] = waiter.wait(
|
||||||
wait_timeout, wait_sleep, name, namespace
|
wait_timeout, wait_sleep, name, namespace
|
||||||
)
|
)
|
||||||
match, diffs = diff_objects(existing.to_dict(), obj)
|
match, diffs = diff_objects(existing.to_dict(), obj, hidden_fields)
|
||||||
result["changed"] = not match
|
result["changed"] = not match
|
||||||
if module._diff:
|
if module._diff:
|
||||||
result["diff"] = diffs
|
result["diff"] = diffs
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ except ImportError:
|
|||||||
# Handled in module setup
|
# Handled in module setup
|
||||||
pass
|
pass
|
||||||
|
|
||||||
from ansible.module_utils._text import to_native
|
from ansible.module_utils.common.text.converters 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,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ result:
|
|||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
from ansible.module_utils._text import to_native
|
from ansible.module_utils.common.text.converters 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,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,490 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
#
|
||||||
|
# Copyright (c) Ansible Project
|
||||||
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
DOCUMENTATION = r"""
|
||||||
|
---
|
||||||
|
module: kubeconfig
|
||||||
|
|
||||||
|
short_description: Generate, update, and optionally write Kubernetes kubeconfig files
|
||||||
|
|
||||||
|
version_added: "6.5.0"
|
||||||
|
|
||||||
|
author: "Youssef Khalid Ali (@YoussefKhalidAli)"
|
||||||
|
|
||||||
|
description:
|
||||||
|
- Build, update, and manage Kubernetes kubeconfig files using structured input.
|
||||||
|
- Supports loading an existing kubeconfig file and merging clusters, users, and contexts.
|
||||||
|
- Can optionally write the resulting kubeconfig to a destination path.
|
||||||
|
- Ensures idempotent behavior by only updating files when changes occur.
|
||||||
|
|
||||||
|
requirements:
|
||||||
|
- "PyYAML >= 5.1"
|
||||||
|
|
||||||
|
notes:
|
||||||
|
- Input data is merged by resource name (cluster, user, context).
|
||||||
|
- Updates under O(clusters), O(users), and O(contexts) are matched by C(name) against the kubeconfig loaded from O(path).
|
||||||
|
- For an existing C(name), each entry's C(behavior) suboption controls the update.
|
||||||
|
- The default is V(merge), which merges nested C(cluster), C(user), and C(context) data so unspecified keys are preserved.
|
||||||
|
- With V(replace), the previous entry for that name is dropped and only the new definition is used.
|
||||||
|
- With V(keep), the existing entry is left unchanged.
|
||||||
|
- With V(remove), the existing entry is deleted from the kubeconfig entirely. If no entry with that name exists, the operation is silently skipped.
|
||||||
|
- This can be used to move kubeconfig files to a different location with different content.
|
||||||
|
- This module does not validate cluster connectivity or authentication.
|
||||||
|
- The module supports C(check_mode) and will not write files when enabled.
|
||||||
|
- The structure follows standard Kubernetes kubeconfig format as defined in the Kubernetes documentation.
|
||||||
|
- Tokens and sensitive data should be protected using ansible-vault or environment variables.
|
||||||
|
|
||||||
|
options:
|
||||||
|
path:
|
||||||
|
description:
|
||||||
|
- Path to an existing kubeconfig file to load and merge from.
|
||||||
|
- If the file does not exist, a new kubeconfig will be created.
|
||||||
|
- This becomes the default destination if O(dest) is not specified.
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
|
||||||
|
dest:
|
||||||
|
description:
|
||||||
|
- Destination path where the final kubeconfig should be written.
|
||||||
|
- If not specified, the kubeconfig will be saved to O(path).
|
||||||
|
- Allows copying and modifying a kubeconfig to a new location.
|
||||||
|
type: str
|
||||||
|
required: false
|
||||||
|
|
||||||
|
clusters:
|
||||||
|
description:
|
||||||
|
- List of cluster definitions to merge into the kubeconfig.
|
||||||
|
- Each cluster is identified by its C(name).
|
||||||
|
- When C(name) matches an existing cluster, the default C(behavior) is V(merge).
|
||||||
|
- See the C(behavior) suboption for V(replace), V(keep), and V(remove).
|
||||||
|
type: list
|
||||||
|
elements: dict
|
||||||
|
required: false
|
||||||
|
default: []
|
||||||
|
suboptions:
|
||||||
|
name:
|
||||||
|
description:
|
||||||
|
- Unique name identifier for the cluster.
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
behavior:
|
||||||
|
description:
|
||||||
|
- How to handle merging if a cluster with this name already exists.
|
||||||
|
- C(merge) - Update only the specified fields, preserve others (default).
|
||||||
|
- C(replace) - Replace the entire cluster definition.
|
||||||
|
- C(keep) - Keep existing cluster, skip this entry.
|
||||||
|
- C(remove) - Remove the cluster entry entirely. Silently skipped if the entry does not exist.
|
||||||
|
type: str
|
||||||
|
choices: ['merge', 'replace', 'keep', 'remove']
|
||||||
|
default: merge
|
||||||
|
cluster:
|
||||||
|
description:
|
||||||
|
- Cluster configuration details.
|
||||||
|
- Not required when C(behavior) is V(remove).
|
||||||
|
type: dict
|
||||||
|
suboptions:
|
||||||
|
server:
|
||||||
|
description:
|
||||||
|
- Kubernetes API server URL (e.g., C(https://k8s.example.com:6443)).
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
certificate-authority:
|
||||||
|
description:
|
||||||
|
- Path to a CA certificate file for validating the API server certificate.
|
||||||
|
type: str
|
||||||
|
certificate-authority-data:
|
||||||
|
description:
|
||||||
|
- Base64 encoded CA certificate data.
|
||||||
|
- Use this instead of C(certificate-authority) for embedded certificates.
|
||||||
|
type: str
|
||||||
|
insecure-skip-tls-verify:
|
||||||
|
description:
|
||||||
|
- If true, the server's certificate will not be validated.
|
||||||
|
type: bool
|
||||||
|
proxy-url:
|
||||||
|
description:
|
||||||
|
- Optional proxy URL for cluster connections.
|
||||||
|
type: str
|
||||||
|
tls-server-name:
|
||||||
|
description:
|
||||||
|
- Server name to use for server certificate validation.
|
||||||
|
type: str
|
||||||
|
|
||||||
|
users:
|
||||||
|
description:
|
||||||
|
- List of user authentication configurations.
|
||||||
|
- Each user is identified by its C(name).
|
||||||
|
- When C(name) matches an existing user, the default C(behavior) is V(merge).
|
||||||
|
- See the C(behavior) suboption for V(replace), V(keep), and V(remove).
|
||||||
|
type: list
|
||||||
|
elements: dict
|
||||||
|
required: false
|
||||||
|
default: []
|
||||||
|
suboptions:
|
||||||
|
name:
|
||||||
|
description:
|
||||||
|
- Unique name identifier for the user.
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
behavior:
|
||||||
|
description:
|
||||||
|
- How to handle merging if a user with this name already exists.
|
||||||
|
- C(merge) - Update only the specified fields, preserve others (default).
|
||||||
|
- C(replace) - Replace the entire user definition.
|
||||||
|
- C(keep) - Keep existing user, skip this entry.
|
||||||
|
- C(remove) - Remove the user entry entirely. Silently skipped if the entry does not exist.
|
||||||
|
type: str
|
||||||
|
choices: ['merge', 'replace', 'keep', 'remove']
|
||||||
|
default: merge
|
||||||
|
user:
|
||||||
|
description:
|
||||||
|
- User authentication configuration.
|
||||||
|
- Not required when C(behavior) is V(remove).
|
||||||
|
type: dict
|
||||||
|
suboptions:
|
||||||
|
token:
|
||||||
|
description:
|
||||||
|
- Bearer token for authentication.
|
||||||
|
type: str
|
||||||
|
username:
|
||||||
|
description:
|
||||||
|
- Username for basic authentication.
|
||||||
|
type: str
|
||||||
|
password:
|
||||||
|
description:
|
||||||
|
- Password for basic authentication.
|
||||||
|
type: str
|
||||||
|
client-certificate:
|
||||||
|
description:
|
||||||
|
- Path to client certificate file.
|
||||||
|
- Used for certificate-based authentication.
|
||||||
|
type: str
|
||||||
|
client-key:
|
||||||
|
description:
|
||||||
|
- Path to client private key file.
|
||||||
|
- Must be provided with C(client-certificate).
|
||||||
|
type: str
|
||||||
|
client-certificate-data:
|
||||||
|
description:
|
||||||
|
- Base64 encoded client certificate.
|
||||||
|
- Use instead of C(client-certificate) for embedded certificates.
|
||||||
|
type: str
|
||||||
|
client-key-data:
|
||||||
|
description:
|
||||||
|
- Base64 encoded client private key.
|
||||||
|
- Use instead of C(client-key) for embedded keys.
|
||||||
|
type: str
|
||||||
|
auth-provider:
|
||||||
|
description:
|
||||||
|
- Authentication provider configuration (e.g., for GCP, Azure).
|
||||||
|
type: dict
|
||||||
|
exec:
|
||||||
|
description:
|
||||||
|
- Exec-based credential plugin configuration.
|
||||||
|
- Used for external authentication providers.
|
||||||
|
type: dict
|
||||||
|
|
||||||
|
contexts:
|
||||||
|
description:
|
||||||
|
- List of context definitions linking users and clusters.
|
||||||
|
- Each context is identified by its C(name).
|
||||||
|
- When C(name) matches an existing context, the default C(behavior) is V(merge).
|
||||||
|
- See the C(behavior) suboption for V(replace), V(keep), and V(remove).
|
||||||
|
type: list
|
||||||
|
elements: dict
|
||||||
|
required: false
|
||||||
|
default: []
|
||||||
|
suboptions:
|
||||||
|
name:
|
||||||
|
description:
|
||||||
|
- Unique name identifier for the context.
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
behavior:
|
||||||
|
description:
|
||||||
|
- How to handle merging if a context with this name already exists.
|
||||||
|
- C(merge) - Update only the specified fields, preserve others (default).
|
||||||
|
- C(replace) - Replace the entire context definition.
|
||||||
|
- C(keep) - Keep existing context, skip this entry.
|
||||||
|
- C(remove) - Remove the context entry entirely. Silently skipped if the entry does not exist.
|
||||||
|
type: str
|
||||||
|
choices: ['merge', 'replace', 'keep', 'remove']
|
||||||
|
default: merge
|
||||||
|
context:
|
||||||
|
description:
|
||||||
|
- Context configuration linking cluster and user.
|
||||||
|
- Not required when C(behavior) is V(remove).
|
||||||
|
type: dict
|
||||||
|
suboptions:
|
||||||
|
cluster:
|
||||||
|
description:
|
||||||
|
- Name of the cluster to use (must match a cluster name in O(clusters)).
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
user:
|
||||||
|
description:
|
||||||
|
- Name of the user to authenticate as (must match a user name in O(users)).
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
namespace:
|
||||||
|
description:
|
||||||
|
- Default namespace to use for this context.
|
||||||
|
- If not specified, defaults to C(default).
|
||||||
|
type: str
|
||||||
|
|
||||||
|
preferences:
|
||||||
|
description:
|
||||||
|
- Kubeconfig preferences.
|
||||||
|
- Used for client-side settings like color output, default editor, etc.
|
||||||
|
type: dict
|
||||||
|
required: false
|
||||||
|
default: {}
|
||||||
|
|
||||||
|
current_context:
|
||||||
|
description:
|
||||||
|
- Name of the context to set as current/active.
|
||||||
|
- This context will be used by default when using kubectl.
|
||||||
|
- Must match one of the context names defined in O(contexts).
|
||||||
|
type: str
|
||||||
|
required: false
|
||||||
|
|
||||||
|
seealso:
|
||||||
|
- name: Kubernetes kubeconfig documentation
|
||||||
|
description: Official Kubernetes documentation for kubeconfig files
|
||||||
|
link: https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/
|
||||||
|
- name: kubectl config documentation
|
||||||
|
description: kubectl commands for working with kubeconfig files
|
||||||
|
link: https://kubernetes.io/docs/reference/kubectl/generated/kubectl_config/
|
||||||
|
"""
|
||||||
|
|
||||||
|
EXAMPLES = r"""
|
||||||
|
# Create a new kubeconfig file with a single cluster
|
||||||
|
- name: Create basic kubeconfig
|
||||||
|
kubernetes.core.kubeconfig:
|
||||||
|
path: /home/user/.kube/config
|
||||||
|
clusters:
|
||||||
|
- name: production-cluster
|
||||||
|
cluster:
|
||||||
|
server: https://prod.k8s.example.com:6443
|
||||||
|
certificate-authority-data: LS0tLS1CRUdJTi...
|
||||||
|
users:
|
||||||
|
- name: admin-user
|
||||||
|
user:
|
||||||
|
token: eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9...
|
||||||
|
contexts:
|
||||||
|
- name: prod-admin
|
||||||
|
context:
|
||||||
|
cluster: production-cluster
|
||||||
|
user: admin-user
|
||||||
|
namespace: production
|
||||||
|
current_context: prod-admin
|
||||||
|
|
||||||
|
- name: Add a second cluster to an existing kubeconfig without touching other entries
|
||||||
|
kubernetes.core.kubeconfig:
|
||||||
|
path: /home/user/.kube/config
|
||||||
|
clusters:
|
||||||
|
- name: staging-cluster
|
||||||
|
cluster:
|
||||||
|
server: https://staging.k8s.example.com:6443
|
||||||
|
insecure-skip-tls-verify: true
|
||||||
|
users:
|
||||||
|
- name: staging-user
|
||||||
|
user:
|
||||||
|
client-certificate: /path/to/staging.crt
|
||||||
|
client-key: /path/to/staging.key
|
||||||
|
contexts:
|
||||||
|
- name: staging-admin
|
||||||
|
context:
|
||||||
|
cluster: staging-cluster
|
||||||
|
user: staging-user
|
||||||
|
namespace: staging
|
||||||
|
|
||||||
|
- name: Update only the token for an existing user, preserving all other user fields
|
||||||
|
kubernetes.core.kubeconfig:
|
||||||
|
path: /home/user/.kube/config
|
||||||
|
users:
|
||||||
|
- name: admin-user
|
||||||
|
behavior: merge
|
||||||
|
user:
|
||||||
|
token: "{{ new_admin_token }}"
|
||||||
|
|
||||||
|
- name: Replace a cluster definition entirely.
|
||||||
|
kubernetes.core.kubeconfig:
|
||||||
|
path: /home/user/.kube/config
|
||||||
|
clusters:
|
||||||
|
- name: production-cluster
|
||||||
|
behavior: replace
|
||||||
|
cluster:
|
||||||
|
server: https://new-prod.k8s.example.com:6443
|
||||||
|
certificate-authority-data: LS0tLS1CRUdJTi...
|
||||||
|
|
||||||
|
- name: Remove a decommissioned cluster, user, and context
|
||||||
|
kubernetes.core.kubeconfig:
|
||||||
|
path: /home/user/.kube/config
|
||||||
|
clusters:
|
||||||
|
- name: old-cluster
|
||||||
|
behavior: remove
|
||||||
|
users:
|
||||||
|
- name: old-user
|
||||||
|
behavior: remove
|
||||||
|
contexts:
|
||||||
|
- name: old-context
|
||||||
|
behavior: remove
|
||||||
|
|
||||||
|
- name: Switch the active context
|
||||||
|
kubernetes.core.kubeconfig:
|
||||||
|
path: /home/user/.kube/config
|
||||||
|
current_context: staging-admin
|
||||||
|
|
||||||
|
- name: Copy a kubeconfig to a new location with an additional cluster merged in
|
||||||
|
kubernetes.core.kubeconfig:
|
||||||
|
path: /home/user/.kube/config
|
||||||
|
dest: /home/user/.kube/config-ci
|
||||||
|
clusters:
|
||||||
|
- name: ci-cluster
|
||||||
|
cluster:
|
||||||
|
server: https://ci.k8s.example.com:6443
|
||||||
|
insecure-skip-tls-verify: true
|
||||||
|
"""
|
||||||
|
|
||||||
|
RETURN = r"""
|
||||||
|
kubeconfig:
|
||||||
|
description: The complete kubeconfig data structure.
|
||||||
|
type: dict
|
||||||
|
returned: always
|
||||||
|
|
||||||
|
dest:
|
||||||
|
description: The path where the kubeconfig was written.
|
||||||
|
type: str
|
||||||
|
returned: always
|
||||||
|
sample: /home/user/.kube/config
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||||
|
from ansible.module_utils.common.text.converters import to_native
|
||||||
|
from ansible_collections.kubernetes.core.plugins.module_utils.args_common import (
|
||||||
|
extract_sensitive_values_from_kubeconfig,
|
||||||
|
)
|
||||||
|
from ansible_collections.kubernetes.core.plugins.module_utils.kubeconfig import (
|
||||||
|
hash_data,
|
||||||
|
load_yaml_file,
|
||||||
|
merge_by_name,
|
||||||
|
write_file,
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
IMP_YAML = True
|
||||||
|
IMP_YAML_ERR = None
|
||||||
|
except ImportError:
|
||||||
|
IMP_YAML = False
|
||||||
|
IMP_YAML_ERR = traceback.format_exc()
|
||||||
|
|
||||||
|
|
||||||
|
def run_module():
|
||||||
|
module_args = dict(
|
||||||
|
path=dict(type="str", required=True),
|
||||||
|
dest=dict(type="str", required=False),
|
||||||
|
clusters=dict(type="list", elements="dict", required=False, default=[]),
|
||||||
|
users=dict(type="list", elements="dict", required=False, default=[]),
|
||||||
|
contexts=dict(type="list", elements="dict", required=False, default=[]),
|
||||||
|
preferences=dict(type="dict", required=False, default={}),
|
||||||
|
current_context=dict(type="str", required=False),
|
||||||
|
)
|
||||||
|
|
||||||
|
module = AnsibleModule(argument_spec=module_args, supports_check_mode=True)
|
||||||
|
|
||||||
|
path = module.params["path"]
|
||||||
|
dest = module.params["dest"] or path
|
||||||
|
|
||||||
|
clusters_input = module.params["clusters"]
|
||||||
|
users_input = module.params["users"]
|
||||||
|
contexts_input = module.params["contexts"]
|
||||||
|
|
||||||
|
preferences = module.params["preferences"]
|
||||||
|
current_context = module.params["current_context"]
|
||||||
|
|
||||||
|
# Load existing kubeconfig
|
||||||
|
try:
|
||||||
|
if not IMP_YAML:
|
||||||
|
module.fail_json(
|
||||||
|
msg=missing_required_lib("pyyaml"),
|
||||||
|
exception=IMP_YAML_ERR,
|
||||||
|
)
|
||||||
|
existing = load_yaml_file(path) if path else {}
|
||||||
|
except Exception as e:
|
||||||
|
module.fail_json(
|
||||||
|
msg="Failed to load existing kubeconfig: %s" % to_native(e),
|
||||||
|
exception=traceback.format_exc(),
|
||||||
|
)
|
||||||
|
|
||||||
|
clusters = merge_by_name(existing.get("clusters", []), clusters_input)
|
||||||
|
users = merge_by_name(existing.get("users", []), users_input)
|
||||||
|
contexts = merge_by_name(existing.get("contexts", []), contexts_input)
|
||||||
|
|
||||||
|
# Build final kubeconfig
|
||||||
|
kubeconfig = {
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"kind": "Config",
|
||||||
|
"preferences": preferences or existing.get("preferences", {}),
|
||||||
|
"clusters": clusters,
|
||||||
|
"users": users,
|
||||||
|
"contexts": contexts,
|
||||||
|
"current-context": current_context or existing.get("current-context") or "",
|
||||||
|
}
|
||||||
|
|
||||||
|
changed = False
|
||||||
|
old_data = {}
|
||||||
|
|
||||||
|
if os.path.exists(dest):
|
||||||
|
try:
|
||||||
|
with open(dest, "r") as f:
|
||||||
|
old_data = yaml.safe_load(f) or {}
|
||||||
|
except Exception as e:
|
||||||
|
module.fail_json(
|
||||||
|
msg="Failed to read destination file: %s" % to_native(e),
|
||||||
|
exception=traceback.format_exc(),
|
||||||
|
)
|
||||||
|
|
||||||
|
old_hash = hash_data(old_data)
|
||||||
|
new_hash = hash_data(kubeconfig)
|
||||||
|
|
||||||
|
if old_hash != new_hash:
|
||||||
|
if not module.check_mode:
|
||||||
|
try:
|
||||||
|
write_file(dest, kubeconfig)
|
||||||
|
except Exception as e:
|
||||||
|
module.fail_json(
|
||||||
|
msg="Failed to write kubeconfig: %s" % to_native(e),
|
||||||
|
exception=traceback.format_exc(),
|
||||||
|
)
|
||||||
|
changed = True
|
||||||
|
|
||||||
|
if isinstance(kubeconfig, dict):
|
||||||
|
module.no_log_values.update(
|
||||||
|
extract_sensitive_values_from_kubeconfig(kubeconfig)
|
||||||
|
)
|
||||||
|
|
||||||
|
module.exit_json(
|
||||||
|
changed=changed,
|
||||||
|
kubeconfig=kubeconfig,
|
||||||
|
dest=dest,
|
||||||
|
msg=(
|
||||||
|
"Kubeconfig file has been updated."
|
||||||
|
if changed
|
||||||
|
else "Kubeconfig file is already up to date."
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
run_module()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -9,7 +9,7 @@ sonar.python.coverage.reportPaths=coverage.xml
|
|||||||
|
|
||||||
sonar.tests=tests/unit,tests/integration
|
sonar.tests=tests/unit,tests/integration
|
||||||
sonar.python.version=3.12
|
sonar.python.version=3.12
|
||||||
sonar.newCode.referenceBranch=stable-5
|
sonar.newCode.referenceBranch=main
|
||||||
|
|
||||||
sonar.exclusions=tests/**,.tox/**
|
sonar.exclusions=tests/**,.tox/**
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ sonar.cpd.exclusions=tests/**
|
|||||||
# constructor (not {...} literals) for readability and consistency across the
|
# constructor (not {...} literals) for readability and consistency across the
|
||||||
# collection. Suppress python:S7498 ("prefer literal syntax"), which conflicts
|
# collection. Suppress python:S7498 ("prefer literal syntax"), which conflicts
|
||||||
# with that convention and otherwise re-fires on every new module argument.
|
# with that convention and otherwise re-fires on every new module argument.
|
||||||
sonar.issue.ignore.multicriteria=e1,e2,e3
|
sonar.issue.ignore.multicriteria=e1,e2,e3,e4,e5
|
||||||
sonar.issue.ignore.multicriteria.e1.ruleKey=python:S7498
|
sonar.issue.ignore.multicriteria.e1.ruleKey=python:S7498
|
||||||
sonar.issue.ignore.multicriteria.e1.resourceKey=**/*.py
|
sonar.issue.ignore.multicriteria.e1.resourceKey=**/*.py
|
||||||
|
|
||||||
@@ -45,3 +45,24 @@ sonar.issue.ignore.multicriteria.e2.resourceKey=tests/**/*.py
|
|||||||
# to simplify maintenance. Suppress githubactions:S7637 ("use full commit SHA").
|
# to simplify maintenance. Suppress githubactions:S7637 ("use full commit SHA").
|
||||||
sonar.issue.ignore.multicriteria.e3.ruleKey=githubactions:S7637
|
sonar.issue.ignore.multicriteria.e3.ruleKey=githubactions:S7637
|
||||||
sonar.issue.ignore.multicriteria.e3.resourceKey=.github/workflows/**/*.yaml
|
sonar.issue.ignore.multicriteria.e3.resourceKey=.github/workflows/**/*.yaml
|
||||||
|
|
||||||
|
# Workflows across this repo install ansible-core from a GitHub source
|
||||||
|
# archive (required for devel/milestone builds, which have no published
|
||||||
|
# wheel) and install this collection's shared test-requirements.txt /
|
||||||
|
# requirements.txt. Suppress githubactions:S8541 ("omitting --only-binary
|
||||||
|
# :all:") repo-wide for workflow files: forcing wheel-only installs would
|
||||||
|
# break the ansible-core source install and fails outright on the
|
||||||
|
# test-requirements.txt pin coverage==4.5.4, which has no Python 3.13 wheel.
|
||||||
|
# Scoped the same way as e3 above, since a filename-only resourceKey (as
|
||||||
|
# originally used here) does not reliably suppress issues already raised
|
||||||
|
# against this project.
|
||||||
|
sonar.issue.ignore.multicriteria.e4.ruleKey=githubactions:S8541
|
||||||
|
sonar.issue.ignore.multicriteria.e4.resourceKey=.github/workflows/**/*.yaml
|
||||||
|
|
||||||
|
# Same shared test-requirements.txt / requirements.txt as above are not
|
||||||
|
# hash-locked; that is a repo-wide dependency-management concern affecting
|
||||||
|
# every existing workflow. Suppress githubactions:S8544 ("dependencies
|
||||||
|
# without locking resolved versions") repo-wide for workflow files rather
|
||||||
|
# than diverging from established practice.
|
||||||
|
sonar.issue.ignore.multicriteria.e5.ruleKey=githubactions:S8544
|
||||||
|
sonar.issue.ignore.multicriteria.e5.resourceKey=.github/workflows/**/*.yaml
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
# Running Helm Integration Tests Locally
|
||||||
|
|
||||||
|
This guide explains how to run the `helm*` integration test targets locally using `ansible-test`.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- `ansible-test` available in your environment (installed with `ansible-core`)
|
||||||
|
- A Kubernetes cluster accessible via `kubectl` (for targets that interact with a cluster)
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
Create an `integration_config.yml` file under `tests/integration/` with the following variables:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
setup_helm_version: vx.x.x # e.g v4.2.1
|
||||||
|
helm_install_path: /path/to/helm/directory
|
||||||
|
```
|
||||||
|
|
||||||
|
### Variables
|
||||||
|
|
||||||
|
| Variable | Description |
|
||||||
|
|---|---|
|
||||||
|
| `setup_helm_version` | The Helm version to install (e.g. `v4.2.1`). The `v` prefix is optional and will be added automatically if omitted. |
|
||||||
|
| `helm_install_path` | Path to a directory that either already contains a `helm` executable matching the version set in `setup_helm_version`, or an empty/non-existent directory where Helm will be downloaded and installed. |
|
||||||
|
|
||||||
|
If a `helm` binary already exists at `<helm_install_path>/helm`, the setup will skip the download and use the existing binary directly.
|
||||||
|
|
||||||
|
## Running Tests
|
||||||
|
|
||||||
|
Run a specific Helm test target with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ansible-test integration --python <version> -v --no-temp-workdir <target>
|
||||||
|
```
|
||||||
|
|
||||||
|
For example, to run the `helm` target with Python 3.12:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ansible-test integration --python 3.12 -v --no-temp-workdir helm
|
||||||
|
```
|
||||||
|
|
||||||
|
You can run multiple targets in a single command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ansible-test integration --python 3.12 -v --no-temp-workdir helm helm_diff helm_plugin
|
||||||
|
```
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
time=100
|
helm
|
||||||
helm_info
|
helm_info
|
||||||
helm_repository
|
helm_plugin
|
||||||
helm_template
|
helm_template
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
helm_default_archive_name: "helm-{{ helm_version }}-{{ ansible_system | lower }}-amd64.tar.gz"
|
helm_binary: "helm"
|
||||||
helm_binary: "/tmp/helm/{{ ansible_system | lower }}-amd64/helm"
|
setup_helm_version_binary_path: "{{ helm_binary }}"
|
||||||
|
|
||||||
chart_test: "ingress-nginx"
|
chart_test: "ingress-nginx"
|
||||||
chart_test_oci: "oci://registry-1.docker.io/bitnamicharts/redis"
|
chart_test_oci: "oci://registry-1.docker.io/bitnamicharts/redis"
|
||||||
@@ -9,23 +9,26 @@ chart_test_version: 4.2.4
|
|||||||
chart_test_version_local_path: 1.32.0
|
chart_test_version_local_path: 1.32.0
|
||||||
chart_test_version_upgrade: 4.2.5
|
chart_test_version_upgrade: 4.2.5
|
||||||
chart_test_version_upgrade_local_path: 1.33.0
|
chart_test_version_upgrade_local_path: 1.33.0
|
||||||
chart_test_repo: "https://kubernetes.github.io/ingress-nginx"
|
chart_test_repo: "https://stenic.github.io/k8status/"
|
||||||
chart_test_git_repo: "http://github.com/helm/charts.git"
|
chart_test_git_repo: "http://github.com/helm/charts.git"
|
||||||
chart_test_values:
|
chart_test_values:
|
||||||
revisionHistoryLimit: 0
|
revisionHistoryLimit: 0
|
||||||
myValue: "changed"
|
myValue: "changed"
|
||||||
|
|
||||||
test_namespace:
|
test_namespace:
|
||||||
- "helm-test-crds"
|
- "helm-test-crds-{{ helm_version | replace('.', '-') }}"
|
||||||
- "helm-uninstall"
|
- "helm-uninstall-{{ helm_version | replace('.', '-') }}"
|
||||||
- "helm-read-envvars"
|
- "helm-read-envvars-{{ helm_version | replace('.', '-') }}"
|
||||||
- "helm-dep-update"
|
- "helm-dep-update-{{ helm_version | replace('.', '-') }}"
|
||||||
- "helm-local-path-001"
|
- "helm-local-path-001-{{ helm_version | replace('.', '-') }}"
|
||||||
- "helm-local-path-002"
|
- "helm-local-path-002-{{ helm_version | replace('.', '-') }}"
|
||||||
- "helm-local-path-003"
|
- "helm-local-path-003-{{ helm_version | replace('.', '-') }}"
|
||||||
- "helm-from-repository"
|
- "helm-from-repository-{{ helm_version | replace('.', '-') }}"
|
||||||
- "helm-from-url"
|
- "helm-from-url-{{ helm_version | replace('.', '-') }}"
|
||||||
- "helm-reuse-values"
|
- "helm-reuse-values-{{ helm_version | replace('.', '-') }}"
|
||||||
- "helm-chart-with-space-into-name"
|
- "helm-chart-with-space-into-name-{{ helm_version | replace('.', '-') }}"
|
||||||
- "helm-reset-then-reuse-values"
|
- "helm-reset-then-reuse-values-{{ helm_version | replace('.', '-') }}"
|
||||||
- "helm-insecure"
|
- "helm-insecure-{{ helm_version | replace('.', '-') }}"
|
||||||
|
- "helm-test-take-ownership-{{ helm_version | replace('.', '-') }}"
|
||||||
|
- "helm-skip-schema-validation-{{ helm_version | replace('.', '-') }}"
|
||||||
|
- "helm-wait-for-jobs-{{ helm_version | replace('.', '-') }}"
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
apiVersion: v2
|
||||||
|
name: test-chart-job
|
||||||
|
description: A chart with a Job for testing wait_for_jobs
|
||||||
|
type: application
|
||||||
|
version: 0.1.0
|
||||||
|
appVersion: "default"
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: "{{ .Release.Name }}-job"
|
||||||
|
spec:
|
||||||
|
backoffLimit: 0
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
automountServiceAccountToken: false
|
||||||
|
restartPolicy: Never
|
||||||
|
containers:
|
||||||
|
- name: test
|
||||||
|
image: "busybox:1.37"
|
||||||
|
command: ["sh", "-c", "echo done"]
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: "50m"
|
||||||
|
memory: "32Mi"
|
||||||
|
ephemeral-storage: "16Mi"
|
||||||
|
limits:
|
||||||
|
memory: "64Mi"
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Copyright: (c) 2021, Ansible Project
|
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
||||||
from __future__ import absolute_import, division, print_function
|
|
||||||
|
|
||||||
__metaclass__ = type
|
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = r"""
|
|
||||||
---
|
|
||||||
module: helm_test_version
|
|
||||||
short_description: check helm executable version
|
|
||||||
author:
|
|
||||||
- Aubin Bikouo (@abikouo)
|
|
||||||
requirements:
|
|
||||||
- "helm (https://github.com/helm/helm/releases)"
|
|
||||||
description:
|
|
||||||
- validate version of helm binary is lower than the specified version.
|
|
||||||
options:
|
|
||||||
binary_path:
|
|
||||||
description:
|
|
||||||
- The path of a helm binary to use.
|
|
||||||
required: false
|
|
||||||
type: path
|
|
||||||
version:
|
|
||||||
description:
|
|
||||||
- version to test against helm binary.
|
|
||||||
type: str
|
|
||||||
default: 3.7.0
|
|
||||||
"""
|
|
||||||
|
|
||||||
EXAMPLES = r"""
|
|
||||||
- name: validate helm binary version is lower than 3.5.0
|
|
||||||
helm_test_version:
|
|
||||||
binary_path: path/to/helm
|
|
||||||
version: "3.5.0"
|
|
||||||
"""
|
|
||||||
|
|
||||||
RETURN = r"""
|
|
||||||
message:
|
|
||||||
type: str
|
|
||||||
description: Text message describing the test result.
|
|
||||||
returned: always
|
|
||||||
sample: 'version installed: 3.4.5 is lower than version 3.5.0'
|
|
||||||
result:
|
|
||||||
type: bool
|
|
||||||
description: Test result.
|
|
||||||
returned: always
|
|
||||||
sample: 1
|
|
||||||
"""
|
|
||||||
|
|
||||||
import re
|
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
|
||||||
from ansible_collections.kubernetes.core.plugins.module_utils.version import (
|
|
||||||
LooseVersion,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
module = AnsibleModule(
|
|
||||||
argument_spec=dict(
|
|
||||||
binary_path=dict(type="path"),
|
|
||||||
version=dict(type="str", default="3.7.0"),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
bin_path = module.params.get("binary_path")
|
|
||||||
version = module.params.get("version")
|
|
||||||
|
|
||||||
if bin_path is not None:
|
|
||||||
helm_cmd_common = bin_path
|
|
||||||
else:
|
|
||||||
helm_cmd_common = "helm"
|
|
||||||
|
|
||||||
helm_cmd_common = module.get_bin_path(helm_cmd_common, required=True)
|
|
||||||
rc, out, err = module.run_command([helm_cmd_common, "version"])
|
|
||||||
if rc != 0:
|
|
||||||
module.fail_json(msg="helm version failed.", err=err, out=out, rc=rc)
|
|
||||||
|
|
||||||
m = re.match(r'version.BuildInfo{Version:"v([0-9\.]*)",', out)
|
|
||||||
installed_version = m.group(1)
|
|
||||||
|
|
||||||
message = "version installed: %s" % installed_version
|
|
||||||
if LooseVersion(installed_version) < LooseVersion(version):
|
|
||||||
message += " is lower than version %s" % version
|
|
||||||
module.exit_json(changed=False, result=True, message=message)
|
|
||||||
else:
|
|
||||||
message += " is greater than version %s" % version
|
|
||||||
module.exit_json(changed=False, result=False, message=message)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
|
dependencies:
|
||||||
|
- setup_helm_version
|
||||||
collections:
|
collections:
|
||||||
- kubernetes.core
|
- kubernetes.core
|
||||||
dependencies:
|
|
||||||
- remove_namespace
|
|
||||||
|
|||||||
@@ -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 "$@"
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Init Helm folders
|
|
||||||
file:
|
|
||||||
path: /tmp/helm/
|
|
||||||
state: directory
|
|
||||||
|
|
||||||
- name: Unarchive Helm binary
|
|
||||||
unarchive:
|
|
||||||
src: 'https://get.helm.sh/{{ helm_archive_name | default(helm_default_archive_name) }}'
|
|
||||||
dest: /tmp/helm/
|
|
||||||
remote_src: yes
|
|
||||||
retries: 10
|
|
||||||
delay: 5
|
|
||||||
register: result
|
|
||||||
until: result is not failed
|
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
---
|
---
|
||||||
|
- name: Ensure helm is not installed
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "/tmp/helm"
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Check failed if helm is not installed
|
||||||
|
ansible.builtin.include_tasks: test_helm_not_installed.yml
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
include_tasks: run_test.yml
|
ansible.builtin.include_tasks: run_test.yml
|
||||||
loop_control:
|
|
||||||
loop_var: helm_version
|
|
||||||
with_items:
|
|
||||||
- "v3.15.4"
|
|
||||||
- "v3.16.0"
|
|
||||||
- "v3.17.0"
|
|
||||||
- "v4.0.0"
|
|
||||||
|
|||||||
@@ -1,28 +1,18 @@
|
|||||||
---
|
---
|
||||||
- name: Ensure helm is not installed
|
- name: Main helm tests
|
||||||
file:
|
|
||||||
path: "{{ item }}"
|
|
||||||
state: absent
|
|
||||||
with_items:
|
|
||||||
- "/tmp/helm"
|
|
||||||
|
|
||||||
- name: Check failed if helm is not installed
|
|
||||||
include_tasks: test_helm_not_installed.yml
|
|
||||||
|
|
||||||
- name: "Install {{ helm_version }}"
|
|
||||||
include_role:
|
|
||||||
name: install_helm
|
|
||||||
|
|
||||||
- name: Main helm tests with Helm v3
|
|
||||||
when: helm_version != "v4.0.0"
|
|
||||||
block:
|
block:
|
||||||
|
- name: Install helm-diff plugin
|
||||||
|
helm_plugin:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
|
plugin_path: https://github.com/databus23/helm-diff
|
||||||
|
plugin_version: "{{ helm_version | string is ansible.builtin.version('4.0.0', '>=') | ternary('v3.14.0', 'v3.10.0') }}"
|
||||||
|
verify: false
|
||||||
|
|
||||||
- name: "Ensure we honor the environment variables"
|
- name: "Ensure we honor the environment variables"
|
||||||
include_tasks: test_read_envvars.yml
|
ansible.builtin.include_tasks: test_read_envvars.yml
|
||||||
when: helm_version != "v4.0.0"
|
|
||||||
|
|
||||||
- name: Deploy charts
|
- name: Deploy charts
|
||||||
include_tasks: "tests_chart/{{ test_chart_type }}.yml"
|
ansible.builtin.include_tasks: "tests_chart/{{ test_chart_type }}.yml"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: test_chart_type
|
loop_var: test_chart_type
|
||||||
with_items:
|
with_items:
|
||||||
@@ -30,34 +20,44 @@
|
|||||||
- from_repository
|
- from_repository
|
||||||
- from_url
|
- from_url
|
||||||
|
|
||||||
- name: test helm upgrade with reuse_values
|
- name: Test helm upgrade with reuse_values
|
||||||
include_tasks: test_helm_reuse_values.yml
|
ansible.builtin.include_tasks: test_helm_reuse_values.yml
|
||||||
|
|
||||||
- name: test helm upgrade with reset_then_reuse_values
|
- name: Test helm upgrade with reset_then_reuse_values
|
||||||
include_tasks: test_helm_reset_then_reuse_values.yml
|
ansible.builtin.include_tasks: test_helm_reset_then_reuse_values.yml
|
||||||
|
when: helm_version | string is ansible.builtin.version('3.14.0', '>=')
|
||||||
|
|
||||||
- name: test helm dependency update
|
- name: Test helm dependency update
|
||||||
include_tasks: test_up_dep.yml
|
ansible.builtin.include_tasks: test_up_dep.yml
|
||||||
|
|
||||||
- name: Test helm uninstall
|
|
||||||
include_tasks: test_helm_uninstall.yml
|
|
||||||
|
|
||||||
- name: Test helm install with chart name containing space
|
- name: Test helm install with chart name containing space
|
||||||
include_tasks: test_helm_with_space_into_chart_name.yml
|
ansible.builtin.include_tasks: test_helm_with_space_into_chart_name.yml
|
||||||
|
|
||||||
# https://github.com/ansible-collections/community.kubernetes/issues/296
|
# https://github.com/ansible-collections/community.kubernetes/issues/296
|
||||||
- name: Test Skip CRDS feature in helm chart install
|
- name: Test Skip CRDS feature in helm chart install
|
||||||
include_tasks: test_crds.yml
|
ansible.builtin.include_tasks: test_crds.yml
|
||||||
|
|
||||||
- name: Test insecure registry flag feature
|
- name: Test insecure registry flag feature
|
||||||
include_tasks: test_helm_insecure.yml
|
ansible.builtin.include_tasks: test_helm_insecure.yml
|
||||||
|
|
||||||
- name: Test helm version
|
- name: Test take ownership flag feature
|
||||||
include_tasks: test_helm_version.yml
|
ansible.builtin.include_tasks: test_helm_take_ownership.yml
|
||||||
|
|
||||||
- name: Clean helm install
|
- name: Test helm skip_schema_validation
|
||||||
file:
|
ansible.builtin.include_tasks: test_skip_schema_validation.yml
|
||||||
path: "{{ item }}"
|
|
||||||
state: absent
|
- name: Test helm wait_for_jobs
|
||||||
with_items:
|
ansible.builtin.include_tasks: test_helm_wait_for_jobs.yml
|
||||||
- "/tmp/helm/"
|
|
||||||
|
always:
|
||||||
|
- name: Remove helm-diff plugin
|
||||||
|
helm_plugin:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
|
plugin_name: diff
|
||||||
|
state: absent
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Clean helm install
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "/tmp/helm/"
|
||||||
|
state: absent
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
register: install
|
register: install
|
||||||
|
|
||||||
- name: Validate that insecure flag is not set
|
- name: Validate that insecure flag is not set
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is changed
|
- install is changed
|
||||||
- '"--insecure-skip-tls-verify" not in install.command'
|
- '"--insecure-skip-tls-verify" not in install.command'
|
||||||
@@ -30,18 +30,18 @@
|
|||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- name: Validate that insecure flag IS set if helm version is >= 3.16.0
|
- name: Validate that insecure flag IS set if helm version is >= 3.16.0
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is changed
|
- install is changed
|
||||||
- '"--insecure-skip-tls-verify" in install.command'
|
- '"--insecure-skip-tls-verify" in install.command'
|
||||||
when: '"v3.16.0" <= helm_version'
|
when: helm_version | string is ansible.builtin.version("3.16.0", ">=")
|
||||||
|
|
||||||
- name: Validate that feature fails for helm < 3.16.0
|
- name: Validate that feature fails for helm < 3.16.0
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is failed
|
- install is failed
|
||||||
- '"insecure_skip_tls_verify requires helm >= 3.16.0" in install.msg'
|
- '"insecure_skip_tls_verify requires helm >= 3.16.0" in install.msg'
|
||||||
when: 'helm_version < "v3.16.0"'
|
when: helm_version | string is ansible.builtin.version("3.16.0", "<")
|
||||||
|
|
||||||
always:
|
always:
|
||||||
- name: Remove helm namespace
|
- name: Remove helm namespace
|
||||||
|
|||||||
@@ -1,23 +1,15 @@
|
|||||||
---
|
---
|
||||||
- name: Failed test when helm is not installed
|
- name: Failed test when helm is not installed
|
||||||
helm:
|
helm:
|
||||||
binary_path: "{{ helm_binary}}_fake"
|
binary_path: "{{ helm_binary }}_fake"
|
||||||
name: test
|
name: test
|
||||||
chart_ref: "{{ chart_test }}"
|
chart_ref: "{{ chart_test }}"
|
||||||
namespace: "helm-test"
|
namespace: "helm-test"
|
||||||
ignore_errors: yes
|
ignore_errors: true
|
||||||
register: helm_missing_binary
|
register: helm_missing_binary
|
||||||
|
|
||||||
- name: Assert that helm is not installed
|
- name: Assert that helm is not installed
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
|
||||||
- helm_missing_binary is failed
|
|
||||||
- "'No such file or directory' in helm_missing_binary.msg"
|
|
||||||
when: ansible_version.full is version('2.20', '<')
|
|
||||||
|
|
||||||
- name: Assert that helm is not installed (ansible 2.20+)
|
|
||||||
assert:
|
|
||||||
that:
|
that:
|
||||||
- helm_missing_binary is failed
|
- helm_missing_binary is failed
|
||||||
- "'Error executing command' in helm_missing_binary.msg"
|
- "'Error executing command' in helm_missing_binary.msg"
|
||||||
when: ansible_version.full is version('2.20', '>=')
|
|
||||||
|
|||||||
@@ -32,12 +32,34 @@
|
|||||||
register: release_value
|
register: release_value
|
||||||
|
|
||||||
- name: Validate that chart values are as expected
|
- name: Validate that chart values are as expected
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is changed
|
- install is changed
|
||||||
- '"--reset-then-reuse-values" not in install.command'
|
- '"--reset-then-reuse-values" not in install.command'
|
||||||
- release_value["status"]["release_values"] == chart_release_values
|
- release_value["status"]["release_values"] == chart_release_values
|
||||||
|
|
||||||
|
# We need to provide the actual redis password otherwise the update command
|
||||||
|
# will fail with the following:
|
||||||
|
# Error: execution error at (redis/templates/replicas/application.yaml:55:35):
|
||||||
|
# PASSWORDS ERROR: You must provide your current passwords when upgrading the release.
|
||||||
|
# Note that even after reinstallation, old credentials may be needed as they may be kept in persistent volume claims.
|
||||||
|
# Further information can be obtained at https://docs.bitnami.com/general/how-to/troubleshoot-helm-chart-issues/#credential-errors-while-upgrading-chart-releases
|
||||||
|
# 'global.redis.password' must not be empty, please add '--set global.redis.password=$REDIS_PASSWORD' to the command. To get the current value:
|
||||||
|
- name: Retrieve release password
|
||||||
|
kubernetes.core.k8s_info:
|
||||||
|
namespace: "{{ helm_namespace }}"
|
||||||
|
kind: Secret
|
||||||
|
name: test-redis
|
||||||
|
register: redis_secret
|
||||||
|
|
||||||
|
- ansible.builtin.set_fact:
|
||||||
|
chart_reset_then_reuse_values: "{{ chart_reset_then_reuse_values | combine(redis_global_password) }}"
|
||||||
|
vars:
|
||||||
|
redis_global_password:
|
||||||
|
global:
|
||||||
|
redis:
|
||||||
|
password: "{{ redis_secret.resources.0.data['redis-password'] | b64decode }}"
|
||||||
|
|
||||||
- name: Upgrade chart using reset_then_reuse_values=true
|
- name: Upgrade chart using reset_then_reuse_values=true
|
||||||
helm:
|
helm:
|
||||||
binary_path: "{{ helm_binary }}"
|
binary_path: "{{ helm_binary }}"
|
||||||
@@ -58,7 +80,7 @@
|
|||||||
register: release_value
|
register: release_value
|
||||||
|
|
||||||
- name: Validate that chart values are as expected
|
- name: Validate that chart values are as expected
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- upgrade is changed
|
- upgrade is changed
|
||||||
- '"--reset-then-reuse-values" in upgrade.command'
|
- '"--reset-then-reuse-values" in upgrade.command'
|
||||||
@@ -73,3 +95,4 @@
|
|||||||
kind: Namespace
|
kind: Namespace
|
||||||
name: "{{ helm_namespace }}"
|
name: "{{ helm_namespace }}"
|
||||||
state: absent
|
state: absent
|
||||||
|
wait: false
|
||||||
|
|||||||
@@ -32,12 +32,27 @@
|
|||||||
register: release_value
|
register: release_value
|
||||||
|
|
||||||
- name: Validate that chart values are as expected
|
- name: Validate that chart values are as expected
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is changed
|
- install is changed
|
||||||
- '"--reuse-values=True" not in install.command'
|
- '"--reuse-values=True" not in install.command'
|
||||||
- release_value["status"]["release_values"] == chart_release_values
|
- release_value["status"]["release_values"] == chart_release_values
|
||||||
|
|
||||||
|
- name: Retrieve release password
|
||||||
|
kubernetes.core.k8s_info:
|
||||||
|
namespace: "{{ helm_namespace }}"
|
||||||
|
kind: Secret
|
||||||
|
name: test-redis
|
||||||
|
register: redis_secret
|
||||||
|
|
||||||
|
- ansible.builtin.set_fact:
|
||||||
|
chart_reuse_values: "{{ chart_reuse_values | combine(redis_global_password) }}"
|
||||||
|
vars:
|
||||||
|
redis_global_password:
|
||||||
|
global:
|
||||||
|
redis:
|
||||||
|
password: "{{ redis_secret.resources.0.data['redis-password'] | b64decode }}"
|
||||||
|
|
||||||
- name: Upgrade chart using reuse_values=true
|
- name: Upgrade chart using reuse_values=true
|
||||||
helm:
|
helm:
|
||||||
binary_path: "{{ helm_binary }}"
|
binary_path: "{{ helm_binary }}"
|
||||||
@@ -57,7 +72,7 @@
|
|||||||
register: release_value
|
register: release_value
|
||||||
|
|
||||||
- name: Validate that chart values are as expected
|
- name: Validate that chart values are as expected
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- upgrade is changed
|
- upgrade is changed
|
||||||
- '"--reuse-values=True" in upgrade.command'
|
- '"--reuse-values=True" in upgrade.command'
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
---
|
||||||
|
- name: Test helm take ownership
|
||||||
|
vars:
|
||||||
|
helm_namespace: "{{ test_namespace[13] }}"
|
||||||
|
block:
|
||||||
|
|
||||||
|
- name: Initial chart installation (no flag set)
|
||||||
|
helm:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
|
chart_ref: "{{ chart_test_oci }}"
|
||||||
|
release_name: test-take-ownership
|
||||||
|
release_namespace: "{{ helm_namespace }}"
|
||||||
|
create_namespace: true
|
||||||
|
register: install
|
||||||
|
|
||||||
|
- name: Validate that take-ownership flag is not set
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- install is changed
|
||||||
|
- '"--take-ownership" not in install.command'
|
||||||
|
|
||||||
|
# We need to provide the actual redis password otherwise the update command
|
||||||
|
# will fail with the following:
|
||||||
|
# Error: execution error at (redis/templates/replicas/application.yaml:55:35):
|
||||||
|
# PASSWORDS ERROR: You must provide your current passwords when upgrading the release.
|
||||||
|
# Note that even after reinstallation, old credentials may be needed as they may be kept in persistent volume claims.
|
||||||
|
# Further information can be obtained at https://docs.bitnami.com/general/how-to/troubleshoot-helm-chart-issues/#credential-errors-while-upgrading-chart-releases
|
||||||
|
# 'global.redis.password' must not be empty, please add '--set global.redis.password=$REDIS_PASSWORD' to the command. To get the current value:
|
||||||
|
- name: Retrieve release password
|
||||||
|
kubernetes.core.k8s_info:
|
||||||
|
namespace: "{{ helm_namespace }}"
|
||||||
|
kind: Secret
|
||||||
|
name: test-take-ownership-redis
|
||||||
|
register: redis_secret
|
||||||
|
|
||||||
|
- name: Upgrade chart (take-onwership flag set)
|
||||||
|
helm:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
|
chart_ref: "{{ chart_test_oci }}"
|
||||||
|
release_name: test-take-ownership
|
||||||
|
release_namespace: "{{ helm_namespace }}"
|
||||||
|
take_ownership: true
|
||||||
|
values:
|
||||||
|
commonLabels:
|
||||||
|
take-onwership: "set"
|
||||||
|
global:
|
||||||
|
redis:
|
||||||
|
password: "{{ redis_secret.resources.0.data['redis-password'] | b64decode }}"
|
||||||
|
register: upgrade
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Validate that take-ownership flag IS set if helm version is >= 3.17.0
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- upgrade is changed
|
||||||
|
- '"--take-ownership" in upgrade.command'
|
||||||
|
when: helm_version | string is ansible.builtin.version("3.17.0", ">=")
|
||||||
|
|
||||||
|
- name: Validate that feature fails for helm < 3.17.0
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- upgrade is failed
|
||||||
|
- '"take_ownership requires helm >= 3.17.0" in upgrade.msg'
|
||||||
|
when: helm_version | string is ansible.builtin.version("3.17.0", "<")
|
||||||
|
|
||||||
|
- name: Upgrade chart (take-onwership flag not set)
|
||||||
|
helm:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
|
chart_ref: "{{ chart_test_oci }}"
|
||||||
|
release_name: test-take-ownership
|
||||||
|
release_namespace: "{{ helm_namespace }}"
|
||||||
|
values:
|
||||||
|
commonLabels:
|
||||||
|
take-onwership: "not-set"
|
||||||
|
global:
|
||||||
|
redis:
|
||||||
|
password: "{{ redis_secret.resources.0.data['redis-password'] | b64decode }}"
|
||||||
|
register: upgrade
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Validate that take-ownership flag IS set if helm version is >= 3.17.0
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- upgrade is changed
|
||||||
|
- '"--take-ownership" not in upgrade.command'
|
||||||
|
when: helm_version | string is ansible.builtin.version("3.17.0", ">=")
|
||||||
|
|
||||||
|
- name: Validate that feature fails for helm < 3.17.0
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- upgrade is changed
|
||||||
|
- upgrade.msg is not defined
|
||||||
|
when: helm_version | string is ansible.builtin.version("3.17.0", "<")
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: Remove helm namespace
|
||||||
|
k8s:
|
||||||
|
api_version: v1
|
||||||
|
kind: Namespace
|
||||||
|
name: "{{ helm_namespace }}"
|
||||||
|
state: absent
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
- name: validate helm version lower than 3.7.0
|
|
||||||
helm_test_version:
|
|
||||||
binary_path: "{{ helm_binary }}"
|
|
||||||
version: "3.7.0"
|
|
||||||
register: test_version
|
|
||||||
|
|
||||||
- vars:
|
|
||||||
chart_source: "https://github.com/kubernetes/kube-state-metrics/releases/download/kube-state-metrics-helm-chart-2.13.3/kube-state-metrics-2.13.3.tgz"
|
|
||||||
chart_name: "test-wait-uninstall"
|
|
||||||
chart_name_pending: "test-uninstall-pending-release"
|
|
||||||
helm_namespace: "{{ test_namespace[1] }}"
|
|
||||||
block:
|
|
||||||
|
|
||||||
- name: Install chart
|
|
||||||
helm:
|
|
||||||
binary_path: "{{ helm_binary }}"
|
|
||||||
name: "{{ chart_name }}"
|
|
||||||
chart_ref: "{{ chart_source }}"
|
|
||||||
namespace: "{{ helm_namespace }}"
|
|
||||||
create_namespace: true
|
|
||||||
|
|
||||||
- name: Delete chart with wait
|
|
||||||
helm:
|
|
||||||
state: absent
|
|
||||||
binary_path: "{{ helm_binary }}"
|
|
||||||
name: "{{ chart_name }}"
|
|
||||||
namespace: "{{ helm_namespace }}"
|
|
||||||
wait: yes
|
|
||||||
register: uninstall
|
|
||||||
|
|
||||||
- name: assert warning has been raised
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- uninstall.warnings
|
|
||||||
|
|
||||||
- name: Create temp directory
|
|
||||||
tempfile:
|
|
||||||
state: directory
|
|
||||||
suffix: .test
|
|
||||||
register: _result
|
|
||||||
|
|
||||||
- set_fact:
|
|
||||||
helm_tmp_dir: "{{ _result.path }}"
|
|
||||||
|
|
||||||
- name: Unarchive Helm binary
|
|
||||||
unarchive:
|
|
||||||
src: 'https://get.helm.sh/helm-v3.7.0-linux-amd64.tar.gz'
|
|
||||||
dest: "{{ helm_tmp_dir }}"
|
|
||||||
remote_src: yes
|
|
||||||
|
|
||||||
- name: Install chart
|
|
||||||
helm:
|
|
||||||
binary_path: "{{ helm_tmp_dir }}/linux-amd64/helm"
|
|
||||||
name: "{{ chart_name }}"
|
|
||||||
chart_ref: "{{ chart_source }}"
|
|
||||||
namespace: "{{ helm_namespace }}"
|
|
||||||
create_namespace: true
|
|
||||||
|
|
||||||
- name: uninstall chart again using recent version
|
|
||||||
helm:
|
|
||||||
state: absent
|
|
||||||
binary_path: "{{ helm_tmp_dir }}/linux-amd64/helm"
|
|
||||||
name: "{{ chart_name }}"
|
|
||||||
namespace: "{{ helm_namespace }}"
|
|
||||||
wait: yes
|
|
||||||
register: uninstall
|
|
||||||
|
|
||||||
# Test uninstall chart release with 'pending-install' status
|
|
||||||
- name: Create chart release with 'pending-install' status
|
|
||||||
helm_test_pending:
|
|
||||||
binary_path: "{{ helm_binary }}"
|
|
||||||
chart_ref: "{{ chart_source }}"
|
|
||||||
chart_release: "{{ chart_name_pending }}"
|
|
||||||
chart_release_namespace: "{{ helm_namespace }}"
|
|
||||||
|
|
||||||
- name: Uninstall chart release with 'pending-install' status
|
|
||||||
helm:
|
|
||||||
binary_path: "{{ helm_binary }}"
|
|
||||||
release_name: "{{ chart_name_pending }}"
|
|
||||||
namespace: "{{ helm_namespace }}"
|
|
||||||
release_state: absent
|
|
||||||
register: _uninstall
|
|
||||||
|
|
||||||
- name: Get Helm release details
|
|
||||||
helm_info:
|
|
||||||
binary_path: "{{ helm_binary }}"
|
|
||||||
release_namespace: "{{ helm_namespace }}"
|
|
||||||
release_state: pending
|
|
||||||
release_name: "{{ chart_name_pending }}"
|
|
||||||
register: _info
|
|
||||||
|
|
||||||
- name: assert release does not exist anymore
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- _uninstall is changed
|
|
||||||
- _info.status is undefined
|
|
||||||
|
|
||||||
always:
|
|
||||||
- name: Delete temp directory
|
|
||||||
file:
|
|
||||||
path: "{{ helm_tmp_dir }}"
|
|
||||||
state: absent
|
|
||||||
ignore_errors: true
|
|
||||||
|
|
||||||
- name: Remove namespace
|
|
||||||
k8s:
|
|
||||||
kind: Namespace
|
|
||||||
name: "{{ helm_namespace }}"
|
|
||||||
state: absent
|
|
||||||
ignore_errors: true
|
|
||||||
when: test_version.result
|
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
---
|
||||||
|
- name: Test helm wait_for_jobs
|
||||||
|
vars:
|
||||||
|
helm_namespace: "{{ test_namespace[15] }}"
|
||||||
|
chart_local: "{{ role_path }}/files/test-chart-job"
|
||||||
|
block:
|
||||||
|
|
||||||
|
- name: Install chart with wait and wait_for_jobs
|
||||||
|
helm:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
|
chart_ref: "{{ chart_local }}"
|
||||||
|
release_name: test-wait-for-jobs
|
||||||
|
release_namespace: "{{ helm_namespace }}"
|
||||||
|
create_namespace: true
|
||||||
|
wait: true
|
||||||
|
wait_for_jobs: true
|
||||||
|
wait_timeout: "120s"
|
||||||
|
register: install
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Validate wait_for_jobs with helm >= 3.5.0 works
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- install is changed
|
||||||
|
- "'--wait' in install.command"
|
||||||
|
- "'--wait-for-jobs' in install.command"
|
||||||
|
when: "helm_version | string is ansible.builtin.version('3.5.0', '>=')"
|
||||||
|
|
||||||
|
- name: Validate wait_for_jobs with helm < 3.5.0 fails
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- install is failed
|
||||||
|
- "'wait_for_jobs requires helm >= 3.5.0' in install.msg"
|
||||||
|
when: "helm_version | string is ansible.builtin.version('3.5.0', '<')"
|
||||||
|
|
||||||
|
- name: Install chart with wait_for_jobs but without wait
|
||||||
|
helm:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
|
chart_ref: "{{ chart_local }}"
|
||||||
|
release_name: test-wait-for-jobs-no-wait
|
||||||
|
release_namespace: "{{ helm_namespace }}"
|
||||||
|
create_namespace: true
|
||||||
|
wait_for_jobs: true
|
||||||
|
register: install_no_wait
|
||||||
|
|
||||||
|
- name: Validate wait_for_jobs is ignored without wait
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- install_no_wait is changed
|
||||||
|
- "'--wait-for-jobs' not in install_no_wait.command"
|
||||||
|
- "'--wait' not in install_no_wait.command"
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: Remove helm namespace
|
||||||
|
k8s:
|
||||||
|
api_version: v1
|
||||||
|
kind: Namespace
|
||||||
|
name: "{{ helm_namespace }}"
|
||||||
|
state: absent
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
register: install_chart
|
register: install_chart
|
||||||
|
|
||||||
- name: Assert that chart is installed
|
- name: Assert that chart is installed
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install_chart is changed
|
- install_chart is changed
|
||||||
- install_chart.status.status | lower == 'deployed'
|
- install_chart.status.status | lower == 'deployed'
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
register: chart_info
|
register: chart_info
|
||||||
|
|
||||||
- name: Assert that Chart is installed (using helm_info)
|
- name: Assert that Chart is installed (using helm_info)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- chart_info.status.status | lower == 'deployed'
|
- chart_info.status.status | lower == 'deployed'
|
||||||
|
|
||||||
|
|||||||
+16
-15
@@ -1,20 +1,15 @@
|
|||||||
---
|
---
|
||||||
- name: Test helm reuse_values
|
- name: Test helm skip_schema_validation
|
||||||
vars:
|
vars:
|
||||||
helm_namespace: "{{ test_namespace[12] }}"
|
helm_namespace: "{{ test_namespace[14] }}"
|
||||||
chart_release_values:
|
chart_release_values:
|
||||||
replica:
|
replica:
|
||||||
replicaCount: 3
|
replicaCount: 3
|
||||||
master:
|
master:
|
||||||
count: 1
|
count: 1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
chart_reuse_values:
|
|
||||||
replica:
|
|
||||||
replicaCount: 1
|
|
||||||
master:
|
|
||||||
count: 3
|
|
||||||
block:
|
block:
|
||||||
- name: Initial chart installation
|
- name: Chart installation
|
||||||
helm:
|
helm:
|
||||||
binary_path: "{{ helm_binary }}"
|
binary_path: "{{ helm_binary }}"
|
||||||
chart_ref: oci://registry-1.docker.io/bitnamicharts/redis
|
chart_ref: oci://registry-1.docker.io/bitnamicharts/redis
|
||||||
@@ -22,21 +17,27 @@
|
|||||||
release_namespace: "{{ helm_namespace }}"
|
release_namespace: "{{ helm_namespace }}"
|
||||||
create_namespace: true
|
create_namespace: true
|
||||||
release_values: "{{ chart_release_values }}"
|
release_values: "{{ chart_release_values }}"
|
||||||
|
skip_schema_validation: true
|
||||||
register: install
|
register: install
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
when: helm_version == "v4.0.0"
|
|
||||||
|
|
||||||
- name: Debug install result
|
- name: Debug install result
|
||||||
debug:
|
ansible.builtin.debug:
|
||||||
var: install
|
var: install
|
||||||
when: helm_version == "v4.0.0"
|
|
||||||
|
|
||||||
- name: Ensure helm installation was failed for v4.0.0
|
- name: Validate skip_schema_validation with helm >= 3.16.0 works
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- install is changed
|
||||||
|
- "'--skip-schema-validation' in install.command"
|
||||||
|
when: "helm_version | string is ansible.builtin.version('3.16.0', '>=')"
|
||||||
|
|
||||||
|
- name: Validate skip_schema_validation with helm < 3.16.0 fails
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is failed
|
- install is failed
|
||||||
- "'Helm version must be >=3.0.0,<4.0.0' in install.msg"
|
- "'skip_schema_validation requires helm >= 3.16.0' in install.msg"
|
||||||
when: helm_version == "v4.0.0"
|
when: "helm_version | string is ansible.builtin.version('3.16.0', '<')"
|
||||||
|
|
||||||
always:
|
always:
|
||||||
- name: Remove helm namespace
|
- name: Remove helm namespace
|
||||||
@@ -3,8 +3,8 @@
|
|||||||
vars:
|
vars:
|
||||||
helm_namespace: "{{ test_namespace[3] }}"
|
helm_namespace: "{{ test_namespace[3] }}"
|
||||||
block:
|
block:
|
||||||
- name: copy chart
|
- name: Copy chart
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
src: "{{ item }}"
|
src: "{{ item }}"
|
||||||
dest: /tmp
|
dest: /tmp
|
||||||
loop:
|
loop:
|
||||||
@@ -19,16 +19,16 @@
|
|||||||
chart_version: "{{ chart_source_version | default(omit) }}"
|
chart_version: "{{ chart_source_version | default(omit) }}"
|
||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
dependency_update: false
|
dependency_update: false
|
||||||
create_namespace: yes
|
create_namespace: true
|
||||||
register: release
|
register: release
|
||||||
|
|
||||||
- name: "Get stats of the subchart"
|
- name: "Get stats of the subchart"
|
||||||
stat:
|
ansible.builtin.stat:
|
||||||
path: "/tmp/test-chart/Chart.lock"
|
path: "/tmp/test-chart/Chart.lock"
|
||||||
register: stat_result
|
register: stat_result
|
||||||
|
|
||||||
- name: "Check if the subchart not exist in chart"
|
- name: "Check if the subchart not exist in chart"
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- not stat_result.stat.exists
|
- not stat_result.stat.exists
|
||||||
success_msg: "subchart not exist in the chart directory"
|
success_msg: "subchart not exist in the chart directory"
|
||||||
@@ -41,12 +41,12 @@
|
|||||||
chart_ref: "/tmp/test-chart"
|
chart_ref: "/tmp/test-chart"
|
||||||
chart_version: "{{ chart_source_version | default(omit) }}"
|
chart_version: "{{ chart_source_version | default(omit) }}"
|
||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
create_namespace: yes
|
create_namespace: true
|
||||||
dependency_update: true
|
dependency_update: true
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: release
|
register: release
|
||||||
|
|
||||||
- assert:
|
- ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- release.warnings[0] == "There is no dependencies block defined in Chart.yaml. Dependency update will not be performed. Please consider add dependencies block or disable dependency_update to remove this warning."
|
- release.warnings[0] == "There is no dependencies block defined in Chart.yaml. Dependency update will not be performed. Please consider add dependencies block or disable dependency_update to remove this warning."
|
||||||
success_msg: "warning when there is no dependencies block with dependency_update enabled"
|
success_msg: "warning when there is no dependencies block with dependency_update enabled"
|
||||||
@@ -59,16 +59,16 @@
|
|||||||
chart_version: "{{ chart_source_version | default(omit) }}"
|
chart_version: "{{ chart_source_version | default(omit) }}"
|
||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
dependency_update: true
|
dependency_update: true
|
||||||
create_namespace: yes
|
create_namespace: true
|
||||||
register: release
|
register: release
|
||||||
|
|
||||||
- name: "Get stats of the subchart"
|
- name: "Get stats of the subchart"
|
||||||
stat:
|
ansible.builtin.stat:
|
||||||
path: "/tmp/dep-up/Chart.lock"
|
path: "/tmp/dep-up/Chart.lock"
|
||||||
register: stat_result
|
register: stat_result
|
||||||
|
|
||||||
- name: "Check if the subchart exists in chart"
|
- name: "Check if the subchart exists in chart"
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- stat_result.stat.exists
|
- stat_result.stat.exists
|
||||||
success_msg: "subchart exist in the chart directory"
|
success_msg: "subchart exist in the chart directory"
|
||||||
@@ -82,7 +82,7 @@
|
|||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: "Remove charts"
|
- name: "Remove charts"
|
||||||
file:
|
ansible.builtin.file:
|
||||||
state: absent
|
state: absent
|
||||||
path: "/tmp/{{ item }}"
|
path: "/tmp/{{ item }}"
|
||||||
loop:
|
loop:
|
||||||
@@ -92,8 +92,8 @@
|
|||||||
# Helm_template module
|
# Helm_template module
|
||||||
- name: "Test dependency update for helm_template module"
|
- name: "Test dependency update for helm_template module"
|
||||||
block:
|
block:
|
||||||
- name: copy chart
|
- name: Copy chart
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
src: "{{ item }}"
|
src: "{{ item }}"
|
||||||
dest: /tmp
|
dest: /tmp
|
||||||
loop:
|
loop:
|
||||||
@@ -110,7 +110,7 @@
|
|||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: "Get stats of the subchart"
|
- name: "Get stats of the subchart"
|
||||||
stat:
|
ansible.builtin.stat:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
register: stat_result
|
register: stat_result
|
||||||
loop:
|
loop:
|
||||||
@@ -118,7 +118,7 @@
|
|||||||
- /tmp/dep_up/charts/test-chart/templates/configmap.yaml
|
- /tmp/dep_up/charts/test-chart/templates/configmap.yaml
|
||||||
|
|
||||||
- name: "Check if the subchart exist in chart"
|
- name: "Check if the subchart exist in chart"
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- stat_result.results[0].stat.exists
|
- stat_result.results[0].stat.exists
|
||||||
- stat_result.results[1].stat.exists
|
- stat_result.results[1].stat.exists
|
||||||
@@ -135,7 +135,7 @@
|
|||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: "Get stats of the subchart"
|
- name: "Get stats of the subchart"
|
||||||
stat:
|
ansible.builtin.stat:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
register: stat_result
|
register: stat_result
|
||||||
loop:
|
loop:
|
||||||
@@ -143,7 +143,7 @@
|
|||||||
- /tmp/test-chart/templates/configmap.yaml
|
- /tmp/test-chart/templates/configmap.yaml
|
||||||
|
|
||||||
- name: "Check if the subchart not exist in chart"
|
- name: "Check if the subchart not exist in chart"
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- not stat_result.results[0].stat.exists
|
- not stat_result.results[0].stat.exists
|
||||||
- stat_result.results[1].stat.exists
|
- stat_result.results[1].stat.exists
|
||||||
@@ -152,7 +152,7 @@
|
|||||||
always:
|
always:
|
||||||
|
|
||||||
- name: "Remove charts"
|
- name: "Remove charts"
|
||||||
file:
|
ansible.builtin.file:
|
||||||
state: absent
|
state: absent
|
||||||
path: "/tmp/{{ item }}"
|
path: "/tmp/{{ item }}"
|
||||||
loop:
|
loop:
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
chart_release_replaced_name: "test-{{ chart_name | default(source) }}-001"
|
chart_release_replaced_name: "test-{{ chart_name | default(source) }}-001"
|
||||||
block:
|
block:
|
||||||
- name: Create temp directory
|
- name: Create temp directory
|
||||||
tempfile:
|
ansible.builtin.tempfile:
|
||||||
state: directory
|
state: directory
|
||||||
register: tmpdir
|
register: tmpdir
|
||||||
|
|
||||||
- name: Set temp directory fact
|
- name: Set temp directory fact
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
temp_dir: "{{ tmpdir.path }}"
|
temp_dir: "{{ tmpdir.path }}"
|
||||||
|
|
||||||
- name: Check helm_info empty
|
- name: Check helm_info empty
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
register: empty_info
|
register: empty_info
|
||||||
|
|
||||||
- name: "Assert that no charts are installed with helm_info"
|
- name: "Assert that no charts are installed with helm_info"
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- empty_info.status is undefined
|
- empty_info.status is undefined
|
||||||
|
|
||||||
@@ -30,13 +30,13 @@
|
|||||||
binary_path: "{{ helm_binary }}"
|
binary_path: "{{ helm_binary }}"
|
||||||
name: "{{ chart_release_name }}"
|
name: "{{ chart_release_name }}"
|
||||||
chart_ref: "{{ chart_source }}"
|
chart_ref: "{{ chart_source }}"
|
||||||
chart_version: "{{ chart_source_version | default(omit) }}"
|
chart_version: "{{ chart_test_version }}"
|
||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
ignore_errors: yes
|
ignore_errors: true
|
||||||
register: install_fail
|
register: install_fail
|
||||||
|
|
||||||
- name: "Assert that Install fail {{ chart_test }} from {{ source }}"
|
- name: "Assert that Install fail {{ chart_test }} from {{ source }}"
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install_fail is failed
|
- install_fail is failed
|
||||||
- "'Error: create: failed to create: namespaces \"' + helm_namespace + '\" not found' in install_fail.stderr"
|
- "'Error: create: failed to create: namespaces \"' + helm_namespace + '\" not found' in install_fail.stderr"
|
||||||
@@ -46,14 +46,14 @@
|
|||||||
binary_path: "{{ helm_binary }}"
|
binary_path: "{{ helm_binary }}"
|
||||||
name: "{{ chart_release_name }}"
|
name: "{{ chart_release_name }}"
|
||||||
chart_ref: "{{ chart_source }}"
|
chart_ref: "{{ chart_source }}"
|
||||||
chart_version: "{{ chart_source_version | default(omit) }}"
|
chart_version: "{{ chart_test_version }}"
|
||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
create_namespace: true
|
create_namespace: true
|
||||||
register: install_check_mode
|
register: install_check_mode
|
||||||
check_mode: true
|
check_mode: true
|
||||||
|
|
||||||
- name: "Assert that {{ chart_test }} chart is installed from {{ source }} in check mode"
|
- name: "Assert that {{ chart_test }} chart is installed from {{ source }} in check mode"
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install_check_mode is changed
|
- install_check_mode is changed
|
||||||
- install_check_mode.status is defined
|
- install_check_mode.status is defined
|
||||||
@@ -64,17 +64,18 @@
|
|||||||
binary_path: "{{ helm_binary }}"
|
binary_path: "{{ helm_binary }}"
|
||||||
name: "{{ chart_release_name }}"
|
name: "{{ chart_release_name }}"
|
||||||
chart_ref: "{{ chart_source }}"
|
chart_ref: "{{ chart_source }}"
|
||||||
chart_version: "{{ chart_source_version | default(omit) }}"
|
chart_version: "{{ chart_test_version }}"
|
||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
create_namespace: true
|
create_namespace: true
|
||||||
register: install
|
register: install
|
||||||
|
|
||||||
- name: "Assert that {{ chart_test }} chart is installed from {{ source }}"
|
- name: "Assert that {{ chart_test }} chart version {{ chart_test_version }} is installed from {{ source }}"
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is changed
|
- install is changed
|
||||||
- install.status.chart == chart_test+"-"+chart_test_version
|
- install.status.chart == chart_test+"-"+chart_test_version
|
||||||
- install.status.status | lower == 'deployed'
|
- install.status.status | lower == 'deployed'
|
||||||
|
- install.status.release_values == {}
|
||||||
|
|
||||||
- name: Check helm_info content
|
- name: Check helm_info content
|
||||||
helm_info:
|
helm_info:
|
||||||
@@ -92,8 +93,8 @@
|
|||||||
- deployed
|
- deployed
|
||||||
register: release_state_content_info
|
register: release_state_content_info
|
||||||
|
|
||||||
- name: "Assert that {{ chart_test }} is installed from {{ source }} with helm_info"
|
- name: "Assert that {{ chart_test }} chart version {{ chart_test_version }} is installed from {{ source }} with helm_info"
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- content_info.status.chart == chart_test+"-"+chart_test_version
|
- content_info.status.chart == chart_test+"-"+chart_test_version
|
||||||
- content_info.status.status | lower == 'deployed'
|
- content_info.status.status | lower == 'deployed'
|
||||||
@@ -104,12 +105,13 @@
|
|||||||
binary_path: "{{ helm_binary }}"
|
binary_path: "{{ helm_binary }}"
|
||||||
name: "{{ chart_release_name }}"
|
name: "{{ chart_release_name }}"
|
||||||
chart_ref: "{{ chart_source }}"
|
chart_ref: "{{ chart_source }}"
|
||||||
chart_version: "{{ chart_source_version | default(omit) }}"
|
chart_version: "{{ chart_test_version }}"
|
||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
register: install
|
register: install
|
||||||
|
diff: true
|
||||||
|
|
||||||
- name: Assert idempotency
|
- name: Assert idempotency
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is not changed
|
- install is not changed
|
||||||
- install.status.chart == chart_test+"-"+chart_test_version
|
- install.status.chart == chart_test+"-"+chart_test_version
|
||||||
@@ -120,48 +122,49 @@
|
|||||||
binary_path: "{{ helm_binary }}"
|
binary_path: "{{ helm_binary }}"
|
||||||
name: "{{ chart_release_name }}"
|
name: "{{ chart_release_name }}"
|
||||||
chart_ref: "{{ chart_source }}"
|
chart_ref: "{{ chart_source }}"
|
||||||
chart_version: "{{ chart_source_version | default(omit) }}"
|
chart_version: "{{ chart_test_version }}"
|
||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
values: "{{ chart_test_values }}"
|
values: "{{ chart_test_values }}"
|
||||||
register: install
|
register: install
|
||||||
|
|
||||||
- name: "Assert that {{ chart_test }} chart is upgraded with new var from {{ source }}"
|
- name: "Assert that {{ chart_test }} chart is upgraded with new var from {{ source }}"
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is changed
|
- install is changed
|
||||||
- install.status.status | lower == 'deployed'
|
- install.status.status | lower == 'deployed'
|
||||||
- install.status.chart == chart_test+"-"+chart_test_version
|
- install.status.chart == chart_test+"-"+chart_test_version
|
||||||
- "install.status['release_values'].revisionHistoryLimit == 0"
|
- install.status['release_values'] == chart_test_values
|
||||||
|
|
||||||
- name: Check idempotency after adding vars
|
- name: Check idempotency after adding vars
|
||||||
helm:
|
helm:
|
||||||
binary_path: "{{ helm_binary }}"
|
binary_path: "{{ helm_binary }}"
|
||||||
name: "{{ chart_release_name }}"
|
name: "{{ chart_release_name }}"
|
||||||
chart_ref: "{{ chart_source }}"
|
chart_ref: "{{ chart_source }}"
|
||||||
chart_version: "{{ chart_source_version | default(omit) }}"
|
chart_version: "{{ chart_test_version }}"
|
||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
values: "{{ chart_test_values }}"
|
values: "{{ chart_test_values }}"
|
||||||
register: install
|
register: install
|
||||||
|
diff: true
|
||||||
|
|
||||||
- name: Assert idempotency after add vars
|
- name: Assert idempotency after add vars
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is not changed
|
- install is not changed
|
||||||
- install.status.status | lower == 'deployed'
|
- install.status.status | lower == 'deployed'
|
||||||
- install.status.chart == chart_test+"-"+chart_test_version
|
- install.status.chart == chart_test+"-"+chart_test_version
|
||||||
- "install.status['release_values'].revisionHistoryLimit == 0"
|
- install.status['release_values'] == chart_test_values
|
||||||
|
|
||||||
- name: "Remove Vars to {{ chart_test }} from {{ source }}"
|
- name: "Remove Vars to {{ chart_test }} from {{ source }}"
|
||||||
helm:
|
helm:
|
||||||
binary_path: "{{ helm_binary }}"
|
binary_path: "{{ helm_binary }}"
|
||||||
name: "{{ chart_release_name }}"
|
name: "{{ chart_release_name }}"
|
||||||
chart_ref: "{{ chart_source }}"
|
chart_ref: "{{ chart_source }}"
|
||||||
chart_version: "{{ chart_source_version | default(omit) }}"
|
chart_version: "{{ chart_test_version }}"
|
||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
register: install
|
register: install
|
||||||
|
|
||||||
- name: "Assert that {{ chart_test }} chart is upgraded with new var from {{ source }}"
|
- name: "Assert that {{ chart_test }} chart is upgraded with new var from {{ source }}"
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is changed
|
- install is changed
|
||||||
- install.status.status | lower == 'deployed'
|
- install.status.status | lower == 'deployed'
|
||||||
@@ -173,12 +176,13 @@
|
|||||||
binary_path: "{{ helm_binary }}"
|
binary_path: "{{ helm_binary }}"
|
||||||
name: "{{ chart_release_name }}"
|
name: "{{ chart_release_name }}"
|
||||||
chart_ref: "{{ chart_source }}"
|
chart_ref: "{{ chart_source }}"
|
||||||
chart_version: "{{ chart_source_version | default(omit) }}"
|
chart_version: "{{ chart_test_version }}"
|
||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
register: install
|
register: install
|
||||||
|
diff: true
|
||||||
|
|
||||||
- name: Assert idempotency after removing vars
|
- name: Assert idempotency after removing vars
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is not changed
|
- install is not changed
|
||||||
- install.status.status | lower == 'deployed'
|
- install.status.status | lower == 'deployed'
|
||||||
@@ -190,12 +194,12 @@
|
|||||||
binary_path: "{{ helm_binary }}"
|
binary_path: "{{ helm_binary }}"
|
||||||
name: "{{ chart_release_name }}"
|
name: "{{ chart_release_name }}"
|
||||||
chart_ref: "{{ chart_source_upgrade | default(chart_source) }}"
|
chart_ref: "{{ chart_source_upgrade | default(chart_source) }}"
|
||||||
chart_version: "{{ chart_source_version_upgrade | default(omit) }}"
|
chart_version: "{{ chart_test_version_upgrade }}"
|
||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
register: install
|
register: install
|
||||||
|
|
||||||
- name: "Assert that {{ chart_test }} chart is upgraded with new version from {{ source }}"
|
- name: "Assert that {{ chart_test }} chart is upgraded with new version from {{ source }}"
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is changed
|
- install is changed
|
||||||
- install.status.status | lower == 'deployed'
|
- install.status.status | lower == 'deployed'
|
||||||
@@ -206,12 +210,13 @@
|
|||||||
binary_path: "{{ helm_binary }}"
|
binary_path: "{{ helm_binary }}"
|
||||||
name: "{{ chart_release_name }}"
|
name: "{{ chart_release_name }}"
|
||||||
chart_ref: "{{ chart_source_upgrade | default(chart_source) }}"
|
chart_ref: "{{ chart_source_upgrade | default(chart_source) }}"
|
||||||
chart_version: "{{ chart_source_version_upgrade | default(omit) }}"
|
chart_version: "{{ chart_test_version_upgrade }}"
|
||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
register: install
|
register: install
|
||||||
|
diff: true
|
||||||
|
|
||||||
- name: Assert idempotency after upgrade
|
- name: Assert idempotency after upgrade
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is not changed
|
- install is not changed
|
||||||
- install.status.status | lower == 'deployed'
|
- install.status.status | lower == 'deployed'
|
||||||
@@ -226,7 +231,7 @@
|
|||||||
register: install
|
register: install
|
||||||
|
|
||||||
- name: "Assert that {{ chart_test }} chart is removed from {{ source }}"
|
- name: "Assert that {{ chart_test }} chart is removed from {{ source }}"
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is changed
|
- install is changed
|
||||||
|
|
||||||
@@ -237,9 +242,10 @@
|
|||||||
name: "{{ chart_release_name }}"
|
name: "{{ chart_release_name }}"
|
||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
register: install
|
register: install
|
||||||
|
diff: true
|
||||||
|
|
||||||
- name: Assert idempotency
|
- name: Assert idempotency
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is not changed
|
- install is not changed
|
||||||
|
|
||||||
@@ -249,12 +255,12 @@
|
|||||||
binary_path: "{{ helm_binary }}"
|
binary_path: "{{ helm_binary }}"
|
||||||
name: "{{ chart_release_replaced_name }}"
|
name: "{{ chart_release_replaced_name }}"
|
||||||
chart_ref: "{{ chart_source }}"
|
chart_ref: "{{ chart_source }}"
|
||||||
chart_version: "{{ chart_source_version | default(omit) }}"
|
chart_version: "{{ chart_test_version }}"
|
||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
register: install
|
register: install
|
||||||
|
|
||||||
- name: "Assert that {{ chart_test }} chart is installed from {{ source }}"
|
- name: "Assert that {{ chart_test }} chart is installed from {{ source }}"
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is changed
|
- install is changed
|
||||||
|
|
||||||
@@ -263,12 +269,12 @@
|
|||||||
binary_path: "{{ helm_binary }}"
|
binary_path: "{{ helm_binary }}"
|
||||||
state: absent
|
state: absent
|
||||||
name: "{{ chart_release_replaced_name }}"
|
name: "{{ chart_release_replaced_name }}"
|
||||||
purge: False
|
purge: false
|
||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
register: install
|
register: install
|
||||||
|
|
||||||
- name: Check if chart is removed
|
- name: Check if chart is removed
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is changed
|
- install is changed
|
||||||
|
|
||||||
@@ -277,13 +283,13 @@
|
|||||||
binary_path: "{{ helm_binary }}"
|
binary_path: "{{ helm_binary }}"
|
||||||
name: "{{ chart_release_replaced_name }}"
|
name: "{{ chart_release_replaced_name }}"
|
||||||
chart_ref: "{{ chart_source }}"
|
chart_ref: "{{ chart_source }}"
|
||||||
chart_version: "{{ chart_source_version | default(omit) }}"
|
chart_version: "{{ chart_test_version }}"
|
||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
replace: True
|
replace: true
|
||||||
register: install
|
register: install
|
||||||
|
|
||||||
- name: "Assert that {{ chart_test }} chart is installed from {{ source }}"
|
- name: "Assert that {{ chart_test }} chart is installed from {{ source }}"
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is changed
|
- install is changed
|
||||||
|
|
||||||
@@ -296,7 +302,7 @@
|
|||||||
register: install
|
register: install
|
||||||
|
|
||||||
- name: Check if chart is removed
|
- name: Check if chart is removed
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is changed
|
- install is changed
|
||||||
|
|
||||||
@@ -305,14 +311,14 @@
|
|||||||
binary_path: "{{ helm_binary }}"
|
binary_path: "{{ helm_binary }}"
|
||||||
name: "{{ chart_release_name }}"
|
name: "{{ chart_release_name }}"
|
||||||
chart_ref: "{{ chart_source }}"
|
chart_ref: "{{ chart_source }}"
|
||||||
chart_version: "{{ chart_source_version | default(omit) }}"
|
chart_version: "{{ chart_test_version }}"
|
||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
values_files:
|
values_files:
|
||||||
- "{{ role_path }}/files/values.yaml"
|
- "{{ role_path }}/files/values.yaml"
|
||||||
register: install
|
register: install
|
||||||
|
|
||||||
- name: "Assert that {{ chart_test }} chart has var from {{ source }}"
|
- name: "Assert that {{ chart_test }} chart has var from {{ source }}"
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is changed
|
- install is changed
|
||||||
- install.status.status | lower == 'deployed'
|
- install.status.status | lower == 'deployed'
|
||||||
@@ -324,14 +330,14 @@
|
|||||||
binary_path: "{{ helm_binary }}"
|
binary_path: "{{ helm_binary }}"
|
||||||
name: "{{ chart_release_name }}"
|
name: "{{ chart_release_name }}"
|
||||||
chart_ref: "{{ chart_source }}"
|
chart_ref: "{{ chart_source }}"
|
||||||
chart_version: "{{ chart_source_version | default(omit) }}"
|
chart_version: "{{ chart_test_version }}"
|
||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
values_files:
|
values_files:
|
||||||
- "{{ role_path }}/files/values.yaml"
|
- "{{ role_path }}/files/values.yaml"
|
||||||
register: install
|
register: install
|
||||||
|
|
||||||
- name: "Assert the result is consistent"
|
- name: "Assert the result is consistent"
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- not (install is changed)
|
- not (install is changed)
|
||||||
|
|
||||||
@@ -346,13 +352,13 @@
|
|||||||
helm_template:
|
helm_template:
|
||||||
binary_path: "{{ helm_binary }}"
|
binary_path: "{{ helm_binary }}"
|
||||||
chart_ref: "{{ chart_source }}"
|
chart_ref: "{{ chart_source }}"
|
||||||
chart_version: "{{ chart_source_version | default(omit) }}"
|
chart_version: "{{ chart_test_version }}"
|
||||||
output_dir: "{{ temp_dir }}"
|
output_dir: "{{ temp_dir }}"
|
||||||
values_files:
|
values_files:
|
||||||
- "{{ role_path }}/files/values.yaml"
|
- "{{ role_path }}/files/values.yaml"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
- result is not failed
|
- result is not failed
|
||||||
@@ -360,11 +366,11 @@
|
|||||||
- result.command is match(helm_binary+" template "+chart_source)
|
- result.command is match(helm_binary+" template "+chart_source)
|
||||||
|
|
||||||
- name: Check templates created
|
- name: Check templates created
|
||||||
stat:
|
ansible.builtin.stat:
|
||||||
path: "{{ temp_dir }}/{{ chart_test }}/templates"
|
path: "{{ temp_dir }}/{{ chart_test }}/templates"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
result.stat.exists
|
result.stat.exists
|
||||||
|
|
||||||
@@ -372,8 +378,8 @@
|
|||||||
helm_template:
|
helm_template:
|
||||||
binary_path: "{{ helm_binary }}"
|
binary_path: "{{ helm_binary }}"
|
||||||
chart_ref: "{{ chart_source }}"
|
chart_ref: "{{ chart_source }}"
|
||||||
chart_version: "{{ chart_source_version | default(omit) }}"
|
chart_version: "{{ chart_test_version }}"
|
||||||
disable_hook: True
|
disable_hook: true
|
||||||
release_name: "myrelease"
|
release_name: "myrelease"
|
||||||
release_namespace: "myreleasenamespace"
|
release_namespace: "myreleasenamespace"
|
||||||
show_only:
|
show_only:
|
||||||
@@ -383,7 +389,7 @@
|
|||||||
register: result
|
register: result
|
||||||
when: chart_source is search("test-chart")
|
when: chart_source is search("test-chart")
|
||||||
|
|
||||||
- assert:
|
- ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
- result is not failed
|
- result is not failed
|
||||||
@@ -398,7 +404,7 @@
|
|||||||
binary_path: "{{ helm_binary }}"
|
binary_path: "{{ helm_binary }}"
|
||||||
name: "{{ chart_release_name }}"
|
name: "{{ chart_release_name }}"
|
||||||
chart_ref: "{{ chart_source }}"
|
chart_ref: "{{ chart_source }}"
|
||||||
chart_version: "{{ chart_source_version | default(omit) }}"
|
chart_version: "{{ chart_test_version }}"
|
||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
create_namespace: true
|
create_namespace: true
|
||||||
context: does-not-exist
|
context: does-not-exist
|
||||||
@@ -406,17 +412,18 @@
|
|||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: Assert that release fails with non-existent context
|
- name: Assert that release fails with non-existent context
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is failed
|
- result is failed
|
||||||
- "'context \"does-not-exist\" does not exist' in result.stderr"
|
- "'context \"does-not-exist\" does not exist' in result.stderr"
|
||||||
|
|
||||||
always:
|
always:
|
||||||
- name: Clean up temp dir
|
- name: Clean up temp dir
|
||||||
file:
|
ansible.builtin.file:
|
||||||
state: absent
|
state: absent
|
||||||
path: "{{ temp_dir }}"
|
path: "{{ temp_dir }}"
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
when: temp_dir is defined
|
||||||
|
|
||||||
- name: Remove helm namespace
|
- name: Remove helm namespace
|
||||||
k8s:
|
k8s:
|
||||||
|
|||||||
@@ -5,18 +5,38 @@
|
|||||||
name: test_helm
|
name: test_helm
|
||||||
repo_url: "{{ chart_test_repo }}"
|
repo_url: "{{ chart_test_repo }}"
|
||||||
|
|
||||||
- name: Install Chart from repository
|
- name: Create temporary file to save values in
|
||||||
include_tasks: "../tests_chart.yml"
|
ansible.builtin.tempfile:
|
||||||
vars:
|
suffix: .helm_values
|
||||||
source: repository
|
register: value_file
|
||||||
chart_source: "test_helm/{{ chart_test }}"
|
|
||||||
chart_source_version: "{{ chart_test_version }}"
|
|
||||||
chart_source_version_upgrade: "{{ chart_test_version_upgrade }}"
|
|
||||||
helm_namespace: "{{ test_namespace[7] }}"
|
|
||||||
|
|
||||||
- name: Remove chart repo
|
- vars:
|
||||||
helm_repository:
|
source: repository
|
||||||
binary_path: "{{ helm_binary }}"
|
chart_test: k8status
|
||||||
name: test_helm
|
chart_source: "test_helm/k8status"
|
||||||
repo_url: "{{ chart_test_repo }}"
|
chart_test_version: "0.16.1"
|
||||||
state: absent
|
chart_test_version_upgrade: "0.16.2"
|
||||||
|
helm_namespace: "{{ test_namespace[7] }}"
|
||||||
|
chart_test_values:
|
||||||
|
replicaCount: 3
|
||||||
|
block:
|
||||||
|
- name: Save values into file
|
||||||
|
ansible.builtin.copy:
|
||||||
|
content: "{{ chart_test_values }}"
|
||||||
|
dest: "{{ value_file.path }}"
|
||||||
|
|
||||||
|
- name: Install Chart from repository
|
||||||
|
ansible.builtin.include_tasks: "../tests_chart.yml"
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: Remove temporary file
|
||||||
|
ansible.builtin.file:
|
||||||
|
state: absent
|
||||||
|
path: "{{ value_file.path }}"
|
||||||
|
|
||||||
|
- name: Remove chart repo
|
||||||
|
helm_repository:
|
||||||
|
binary_path: "{{ helm_binary }}"
|
||||||
|
name: test_helm
|
||||||
|
repo_url: "{{ chart_test_repo }}"
|
||||||
|
state: absent
|
||||||
|
|||||||
@@ -3,6 +3,11 @@
|
|||||||
include_tasks: "../tests_chart.yml"
|
include_tasks: "../tests_chart.yml"
|
||||||
vars:
|
vars:
|
||||||
source: url
|
source: url
|
||||||
chart_source: "https://github.com/kubernetes/ingress-nginx/releases/download/helm-chart-{{ chart_test_version }}/{{ chart_test }}-{{ chart_test_version }}.tgz"
|
chart_test: "k8status"
|
||||||
chart_source_upgrade: "https://github.com/kubernetes/ingress-nginx/releases/download/helm-chart-{{ chart_test_version_upgrade }}/{{ chart_test }}-{{ chart_test_version_upgrade }}.tgz"
|
chart_test_values:
|
||||||
|
replicaCount: 3
|
||||||
|
chart_test_version: "0.16.1"
|
||||||
|
chart_test_version_upgrade: "0.16.2"
|
||||||
|
chart_source: https://github.com/stenic/k8status/releases/download/k8status-0.16.1/k8status-0.16.1.tgz
|
||||||
|
chart_source_upgrade: https://github.com/stenic/k8status/releases/download/k8status-0.16.2/k8status-0.16.2.tgz
|
||||||
helm_namespace: "{{ test_namespace[8] }}"
|
helm_namespace: "{{ test_namespace[8] }}"
|
||||||
|
|||||||
@@ -1,3 +1,2 @@
|
|||||||
---
|
---
|
||||||
helm_binary: "/tmp/helm/{{ ansible_system | lower }}-amd64/helm"
|
|
||||||
helm_namespace: helm-diff
|
helm_namespace: helm-diff
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
dependencies:
|
dependencies:
|
||||||
- remove_namespace
|
- remove_namespace
|
||||||
- install_helm
|
|
||||||
- setup_helm_registry
|
- setup_helm_registry
|
||||||
|
- setup_helm
|
||||||
|
- setup_helm_version
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
- connection: local
|
|
||||||
gather_facts: true
|
|
||||||
hosts: localhost
|
|
||||||
|
|
||||||
roles:
|
|
||||||
- helm_diff
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -eux
|
|
||||||
export ANSIBLE_CALLBACKS_ENABLED=profile_tasks
|
|
||||||
export ANSIBLE_ROLES_PATH=../
|
|
||||||
ansible-playbook playbook.yaml "$@"
|
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
---
|
---
|
||||||
|
- name: Define default value for helm binary path
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
helm_binary: "{{ setup_helm_binary_path | default('helm') }}"
|
||||||
|
|
||||||
- name: Test helm diff functionality
|
- name: Test helm diff functionality
|
||||||
vars:
|
vars:
|
||||||
test_chart_ref: "/tmp/test-chart"
|
test_chart_ref: "/tmp/test-chart"
|
||||||
@@ -10,10 +14,11 @@
|
|||||||
binary_path: "{{ helm_binary }}"
|
binary_path: "{{ helm_binary }}"
|
||||||
state: present
|
state: present
|
||||||
plugin_path: https://github.com/databus23/helm-diff
|
plugin_path: https://github.com/databus23/helm-diff
|
||||||
plugin_version: 3.9.13
|
verify: false
|
||||||
|
plugin_version: "{{ helm_version | string is ansible.builtin.version('4.0.0', '>=') | ternary('3.14.0', '3.10.0') }}"
|
||||||
|
|
||||||
- name: Copy test chart
|
- name: Copy test chart
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
src: "test-chart/"
|
src: "test-chart/"
|
||||||
dest: "{{ test_chart_ref }}"
|
dest: "{{ test_chart_ref }}"
|
||||||
|
|
||||||
@@ -26,13 +31,13 @@
|
|||||||
create_namespace: true
|
create_namespace: true
|
||||||
register: install
|
register: install
|
||||||
|
|
||||||
- assert:
|
- ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is changed
|
- install is changed
|
||||||
|
|
||||||
- name: Modify local chart
|
- name: Modify local chart
|
||||||
blockinfile:
|
ansible.builtin.blockinfile:
|
||||||
create: yes
|
create: true
|
||||||
path: "{{ test_chart_ref }}/templates/anothermap.yaml"
|
path: "{{ test_chart_ref }}/templates/anothermap.yaml"
|
||||||
block: !unsafe |
|
block: !unsafe |
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
@@ -55,7 +60,7 @@
|
|||||||
- name: Check if helm diff check is correct
|
- name: Check if helm diff check is correct
|
||||||
vars:
|
vars:
|
||||||
foo_bar_value: "+ foo: bar"
|
foo_bar_value: "+ foo: bar"
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- foo_bar_value in diff_result.diff.prepared
|
- foo_bar_value in diff_result.diff.prepared
|
||||||
|
|
||||||
@@ -67,7 +72,7 @@
|
|||||||
chart_ref: "{{ test_chart_ref }}"
|
chart_ref: "{{ test_chart_ref }}"
|
||||||
register: install
|
register: install
|
||||||
|
|
||||||
- assert:
|
- ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is changed
|
- install is changed
|
||||||
|
|
||||||
@@ -77,12 +82,12 @@
|
|||||||
name: test-chart
|
name: test-chart
|
||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
chart_ref: "{{ test_chart_ref }}"
|
chart_ref: "{{ test_chart_ref }}"
|
||||||
check_mode: yes
|
check_mode: true
|
||||||
diff: true
|
diff: true
|
||||||
register: diff_result
|
register: diff_result
|
||||||
|
|
||||||
- name: Check if no diff in check mode when no change
|
- name: Check if no diff in check mode when no change
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- '"diff" not in diff_result'
|
- '"diff" not in diff_result'
|
||||||
|
|
||||||
@@ -94,12 +99,12 @@
|
|||||||
chart_ref: "{{ test_chart_ref }}"
|
chart_ref: "{{ test_chart_ref }}"
|
||||||
register: install
|
register: install
|
||||||
|
|
||||||
- assert:
|
- ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is not changed
|
- install is not changed
|
||||||
|
|
||||||
- name: Modify values
|
- name: Modify values
|
||||||
blockinfile:
|
ansible.builtin.blockinfile:
|
||||||
create: true
|
create: true
|
||||||
path: "{{ test_chart_ref }}/values.yml"
|
path: "{{ test_chart_ref }}/values.yml"
|
||||||
block: |
|
block: |
|
||||||
@@ -116,7 +121,7 @@
|
|||||||
- "{{ test_chart_ref }}/values.yml"
|
- "{{ test_chart_ref }}/values.yml"
|
||||||
register: install
|
register: install
|
||||||
|
|
||||||
- assert:
|
- ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is changed
|
- install is changed
|
||||||
|
|
||||||
@@ -130,7 +135,7 @@
|
|||||||
- "{{ test_chart_ref }}/values.yml"
|
- "{{ test_chart_ref }}/values.yml"
|
||||||
register: install
|
register: install
|
||||||
|
|
||||||
- assert:
|
- ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is not changed
|
- install is not changed
|
||||||
|
|
||||||
@@ -146,7 +151,7 @@
|
|||||||
- "{{ test_chart_ref }}/values.yml"
|
- "{{ test_chart_ref }}/values.yml"
|
||||||
register: install
|
register: install
|
||||||
|
|
||||||
- assert:
|
- ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is changed
|
- install is changed
|
||||||
|
|
||||||
@@ -162,7 +167,7 @@
|
|||||||
- "{{ test_chart_ref }}/values.yml"
|
- "{{ test_chart_ref }}/values.yml"
|
||||||
register: install
|
register: install
|
||||||
|
|
||||||
- assert:
|
- ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is not changed
|
- install is not changed
|
||||||
|
|
||||||
@@ -181,7 +186,7 @@
|
|||||||
value_type: string
|
value_type: string
|
||||||
register: install
|
register: install
|
||||||
|
|
||||||
- assert:
|
- ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is changed
|
- install is changed
|
||||||
|
|
||||||
@@ -200,7 +205,7 @@
|
|||||||
value_type: string
|
value_type: string
|
||||||
register: install
|
register: install
|
||||||
|
|
||||||
- assert:
|
- ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- install is not changed
|
- install is not changed
|
||||||
|
|
||||||
@@ -213,7 +218,7 @@
|
|||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- name: Define chart variables
|
- name: Define chart variables
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
test_chart_values:
|
test_chart_values:
|
||||||
myValue: 'Some ConfigMap data value'
|
myValue: 'Some ConfigMap data value'
|
||||||
myConfigmapName: 'ansible-config-from-url'
|
myConfigmapName: 'ansible-config-from-url'
|
||||||
@@ -247,7 +252,9 @@
|
|||||||
path: '{{ _tmpd.path }}'
|
path: '{{ _tmpd.path }}'
|
||||||
|
|
||||||
- name: Log into Helm registry
|
- name: Log into Helm registry
|
||||||
ansible.builtin.command: "{{ helm_binary }} registry login -u testuser -p 'pass123!' localhost:6035"
|
ansible.builtin.shell: >-
|
||||||
|
echo 'pass123!' | {{ helm_binary }} registry login -u testuser --password-stdin localhost:6035
|
||||||
|
{{ helm_version | string is ansible.builtin.version("3.18.0", ">=") | ternary('--plain-http', '--insecure') }}
|
||||||
|
|
||||||
- name: Install chart from remote URL
|
- name: Install chart from remote URL
|
||||||
helm:
|
helm:
|
||||||
@@ -257,6 +264,7 @@
|
|||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
name: another-chart
|
name: another-chart
|
||||||
release_values: "{{ test_chart_values }}"
|
release_values: "{{ test_chart_values }}"
|
||||||
|
plain_http: "{{ helm_version | string is ansible.builtin.version('3.13.0', '>=') }}"
|
||||||
|
|
||||||
- name: Upgrade chart
|
- name: Upgrade chart
|
||||||
helm:
|
helm:
|
||||||
@@ -266,44 +274,21 @@
|
|||||||
namespace: "{{ helm_namespace }}"
|
namespace: "{{ helm_namespace }}"
|
||||||
name: another-chart
|
name: another-chart
|
||||||
release_values: "{{ test_chart_values }}"
|
release_values: "{{ test_chart_values }}"
|
||||||
|
plain_http: "{{ helm_version | string is ansible.builtin.version('3.13.0', '>=') }}"
|
||||||
check_mode: true
|
check_mode: true
|
||||||
register: _upgrade
|
register: _upgrade
|
||||||
|
|
||||||
- name: Assert that module raised a warning
|
- name: Assert that module raised a warning
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- not _upgrade.changed
|
- not _upgrade.changed
|
||||||
- _upgrade.warnings is defined
|
- _upgrade.warnings is defined
|
||||||
- _upgrade.warnings | length == 1
|
- _upgrade.warnings | length == 1
|
||||||
- _upgrade.warnings[0] == "The default idempotency check can fail to report changes in certain cases. Install helm diff >= 3.4.1 for better results."
|
- _upgrade.warnings[0] == "The default idempotency check can fail to report changes in certain cases. Install helm diff >= 3.4.1 for better results."
|
||||||
|
|
||||||
- name: Install helm diff (version=3.4.1)
|
|
||||||
helm_plugin:
|
|
||||||
binary_path: "{{ helm_binary }}"
|
|
||||||
state: present
|
|
||||||
plugin_path: https://github.com/databus23/helm-diff
|
|
||||||
plugin_version: 3.4.1
|
|
||||||
|
|
||||||
- name: Upgrade chart once again
|
|
||||||
helm:
|
|
||||||
binary_path: "{{ helm_binary }}"
|
|
||||||
chart_ref: "{{ test_chart_ref_url }}"
|
|
||||||
chart_version: 0.1.0
|
|
||||||
namespace: "{{ helm_namespace }}"
|
|
||||||
name: another-chart
|
|
||||||
release_values: "{{ test_chart_values }}"
|
|
||||||
check_mode: true
|
|
||||||
register: _upgrade_2
|
|
||||||
|
|
||||||
- name: Assert that module raised a warning
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- _upgrade_2.changed
|
|
||||||
- _upgrade_2.warnings is not defined
|
|
||||||
|
|
||||||
always:
|
always:
|
||||||
- name: Remove chart directory
|
- name: Remove chart directory
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: "{{ test_chart_ref }}"
|
path: "{{ test_chart_ref }}"
|
||||||
state: absent
|
state: absent
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
@@ -324,6 +309,7 @@
|
|||||||
wait: true
|
wait: true
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- include_tasks: reuse_values.yml
|
- ansible.builtin.include_tasks: reuse_values.yml
|
||||||
|
|
||||||
- include_tasks: reset_then_reuse_values.yml
|
- ansible.builtin.include_tasks: reset_then_reuse_values.yml
|
||||||
|
when: helm_version | string is ansible.builtin.version('3.8.0', '>')
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user