mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-12 20:42:08 +00:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7103da38ff | ||
|
|
ed3969fc54 | ||
|
|
7e6c2cdd18 | ||
|
|
818f06f215 | ||
|
|
e9ae1fee21 | ||
|
|
c255d11c6e | ||
|
|
b01f78b0b7 | ||
|
|
d40f478552 | ||
|
|
bb45bb676f | ||
|
|
ea54179b23 | ||
|
|
9e41291489 | ||
|
|
15da427a34 | ||
|
|
0a6d3b604b |
7
.ansible-lint
Normal file
7
.ansible-lint
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
profile: production
|
||||
skip_list:
|
||||
- meta-runtime[unsupported-version]
|
||||
exclude_paths:
|
||||
- tests/integration
|
||||
- tests/sanity
|
||||
1
.github/stale.yml
vendored
1
.github/stale.yml
vendored
@@ -12,7 +12,6 @@ daysUntilClose: 30
|
||||
# Only issues or pull requests with all of these labels are check if stale.
|
||||
# Defaults to `[]` (disabled)
|
||||
onlyLabels: []
|
||||
|
||||
# Issues or Pull Requests with these labels will never be considered stale. Set
|
||||
# to `[]` to disable
|
||||
exemptLabels:
|
||||
|
||||
21
.github/workflows/changelog.yaml
vendored
Normal file
21
.github/workflows/changelog.yaml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
---
|
||||
name: Changelog
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- reopened
|
||||
- labeled
|
||||
- unlabeled
|
||||
- synchronize
|
||||
branches:
|
||||
- main
|
||||
- stable-*
|
||||
|
||||
jobs:
|
||||
changelog:
|
||||
uses: ansible-network/github_actions/.github/workflows/changelog.yml@main
|
||||
14
.github/workflows/galaxy-import.yaml
vendored
Normal file
14
.github/workflows/galaxy-import.yaml
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
name: galaxy-import
|
||||
concurrency:
|
||||
group: ${{ github.head_ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- stable-*
|
||||
|
||||
jobs:
|
||||
galaxy_importer:
|
||||
uses: ansible-network/github_actions/.github/workflows/galaxy_importer.yml@main
|
||||
146
.github/workflows/integration-tests.yaml
vendored
Normal file
146
.github/workflows/integration-tests.yaml
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
name: Integration tests
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- reopened
|
||||
- labeled
|
||||
- unlabeled
|
||||
- synchronize
|
||||
branches:
|
||||
- main
|
||||
- stable-*
|
||||
|
||||
jobs:
|
||||
splitter:
|
||||
env:
|
||||
source_dir: "./source"
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
test_targets: ${{ steps.splitter.outputs.test_targets }}
|
||||
test_targets_json: ${{ steps.splitter.outputs.test_targets_json }}
|
||||
test_jobs: ${{ steps.splitter.outputs.test_jobs }}
|
||||
steps:
|
||||
- name: Checkout the collection repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
path: ${{ env.source_dir }}
|
||||
fetch-depth: "0"
|
||||
|
||||
- name: list changes for pull request
|
||||
id: splitter
|
||||
uses: ansible-network/github_actions/.github/actions/ansible_test_splitter@main
|
||||
with:
|
||||
collections_to_test: ${{ env.source_dir }}
|
||||
total_jobs: 8
|
||||
|
||||
- name: Display splitter output
|
||||
run: |
|
||||
echo "test_targets=${{ steps.splitter.outputs.test_targets }}"
|
||||
echo "test_targets_json=${{ steps.splitter.outputs.test_targets_json }}"
|
||||
echo "test_jobs=${{ steps.splitter.outputs.test_jobs }}"
|
||||
shell: bash
|
||||
integration:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
needs:
|
||||
- splitter
|
||||
if: ${{ needs.splitter.outputs.test_targets != '' }}
|
||||
env:
|
||||
source: "./source"
|
||||
cloud_common: "./cloudcommon"
|
||||
ansible_posix: "./ansible_posix"
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
ansible-version:
|
||||
- milestone
|
||||
python-version:
|
||||
- "3.12"
|
||||
enable-turbo-mode:
|
||||
- true
|
||||
- false
|
||||
workflow-id: ${{ fromJson(needs.splitter.outputs.test_jobs) }}
|
||||
name: "integration-py${{ matrix.python-version }}-${{ matrix.ansible-version }}-${{ matrix.workflow-id }}"
|
||||
steps:
|
||||
- name: Read target
|
||||
id: read-targets
|
||||
run: |
|
||||
import json, os
|
||||
with open(os.environ.get('GITHUB_OUTPUT'), "a", encoding="utf-8") as fh:
|
||||
fh.write(f'ansible_test_targets={json.loads(os.environ.get("ALL_TEST_TARGETS")).get(os.environ.get("WORKFLOW_ID"))}\n')
|
||||
shell: python
|
||||
env:
|
||||
ALL_TEST_TARGETS: ${{ needs.splitter.outputs.test_targets_json }}
|
||||
WORKFLOW_ID: ${{ matrix.workflow-id }}
|
||||
|
||||
- name: Display ansible test targets
|
||||
run: |
|
||||
echo "ansible_test_targets -> ${{ steps.read-targets.outputs.ansible_test_targets }}"
|
||||
|
||||
- name: Checkout kubernetes.core repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
path: ${{ env.source }}
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
# install ansible
|
||||
- name: Install ansible-core (${{ matrix.ansible-version }})
|
||||
run: >-
|
||||
python3 -m pip install
|
||||
https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz
|
||||
--disable-pip-version-check
|
||||
shell: bash
|
||||
|
||||
- name: Build and install collection
|
||||
id: install-src
|
||||
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
|
||||
with:
|
||||
install_python_dependencies: true
|
||||
source_path: ${{ env.source }}
|
||||
|
||||
- name: checkout ansible-collections/cloud.common
|
||||
uses: ansible-network/github_actions/.github/actions/checkout_dependency@main
|
||||
with:
|
||||
repository: ansible-collections/cloud.common
|
||||
path: ${{ env.cloud_common }}
|
||||
ref: main
|
||||
|
||||
- name: checkout ansible-collections/ansible.posix
|
||||
uses: ansible-network/github_actions/.github/actions/checkout_dependency@main
|
||||
with:
|
||||
repository: ansible-collections/ansible.posix
|
||||
path: ${{ env.ansible_posix }}
|
||||
ref: main
|
||||
|
||||
- name: install cloud.common collection
|
||||
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
|
||||
with:
|
||||
install_python_dependencies: true
|
||||
source_path: ${{ env.cloud_common }}
|
||||
|
||||
- name: install ansible.posix collection
|
||||
uses: ansible-network/github_actions/.github/actions/build_install_collection@main
|
||||
with:
|
||||
install_python_dependencies: true
|
||||
source_path: ${{ env.ansible_posix }}
|
||||
|
||||
- name: create kubernetes cluster
|
||||
uses: helm/kind-action@v1.8.0
|
||||
with:
|
||||
node_image: "kindest/node:v1.29.2"
|
||||
|
||||
- name: Run integration tests
|
||||
uses: ansible-network/github_actions/.github/actions/ansible_test_integration@main
|
||||
with:
|
||||
collection_path: ${{ steps.install-src.outputs.collection_path }}
|
||||
python_version: ${{ matrix.python-version }}
|
||||
ansible_version: ${{ matrix.ansible-version }}
|
||||
ansible_test_targets: ${{ steps.read-targets.outputs.ansible_test_targets }}
|
||||
ansible_test_environment: |
|
||||
ENABLE_TURBO_MODE=${{ matrix.enable-turbo-mode }}
|
||||
24
.github/workflows/linters.yaml
vendored
Normal file
24
.github/workflows/linters.yaml
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
---
|
||||
name: Linters
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- stable-*
|
||||
tags:
|
||||
- "*"
|
||||
|
||||
jobs:
|
||||
linters:
|
||||
uses: ansible-network/github_actions/.github/workflows/tox-linters.yml@main
|
||||
ansible-lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Run ansible-lint
|
||||
uses: ansible/ansible-lint@v6.21.0
|
||||
15
.github/workflows/sanity-tests.yaml
vendored
Normal file
15
.github/workflows/sanity-tests.yaml
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
name: Sanity tests
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- stable-*
|
||||
|
||||
jobs:
|
||||
sanity:
|
||||
uses: ansible-network/github_actions/.github/workflows/sanity.yml@main
|
||||
15
.github/workflows/unit-tests.yaml
vendored
Normal file
15
.github/workflows/unit-tests.yaml
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
name: Unit tests
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- stable-*
|
||||
|
||||
jobs:
|
||||
unit-source:
|
||||
uses: ansible-network/github_actions/.github/workflows/unit_source.yml@main
|
||||
@@ -4,6 +4,26 @@ Kubernetes Collection Release Notes
|
||||
|
||||
.. contents:: Topics
|
||||
|
||||
v2.4.2
|
||||
======
|
||||
|
||||
Release Summary
|
||||
---------------
|
||||
|
||||
fix resource discovery when complex subresources present
|
||||
|
||||
Bugfixes
|
||||
--------
|
||||
|
||||
- Resolve Collections util resource discovery fails when complex subresources present (https://github.com/ansible-collections/kubernetes.core/pull/676).
|
||||
|
||||
v2.4.1
|
||||
======
|
||||
|
||||
Release Summary
|
||||
---------------
|
||||
|
||||
The kubernetes.core 2.4.1 release includes several trivial bug fixes related to code sanity.
|
||||
|
||||
v2.4.0
|
||||
======
|
||||
|
||||
2
Makefile
2
Makefile
@@ -1,5 +1,5 @@
|
||||
# Also needs to be updated in galaxy.yml
|
||||
VERSION = 2.4.0
|
||||
VERSION = 2.4.1
|
||||
|
||||
TEST_ARGS ?= ""
|
||||
PYTHON_VERSION ?= `python -c 'import platform; print(".".join(platform.python_version_tuple()[0:2]))'`
|
||||
|
||||
@@ -93,7 +93,7 @@ You can also include it in a `requirements.yml` file and install it via `ansible
|
||||
---
|
||||
collections:
|
||||
- name: kubernetes.core
|
||||
version: 2.4.0
|
||||
version: 2.4.1
|
||||
```
|
||||
|
||||
### Installing the Kubernetes Python Library
|
||||
|
||||
@@ -762,3 +762,20 @@ releases:
|
||||
name: helm_pull
|
||||
namespace: ''
|
||||
release_date: '2023-01-24'
|
||||
2.4.1:
|
||||
changes:
|
||||
release_summary: The kubernetes.core 2.4.1 release includes several trivial
|
||||
bug fixes related to sanity.
|
||||
fragments:
|
||||
- fix_sanity_errors.yml
|
||||
release_date: '2024-02-06'
|
||||
2.4.2:
|
||||
changes:
|
||||
bugfixes:
|
||||
- Resolve Collections util resource discovery fails when complex subresources
|
||||
present (https://github.com/ansible-collections/kubernetes.core/pull/676).
|
||||
release_summary: fix resource discovery when complex subresources present
|
||||
fragments:
|
||||
- 2.4.2.yml
|
||||
- 20240222-Collections-util-resource-discovery-fails-when-complex-subresources-present.yml
|
||||
release_date: '2024-03-01'
|
||||
|
||||
@@ -10,21 +10,21 @@ notesdir: fragments
|
||||
prelude_section_name: release_summary
|
||||
prelude_section_title: Release Summary
|
||||
sections:
|
||||
- - major_changes
|
||||
- Major Changes
|
||||
- - minor_changes
|
||||
- Minor Changes
|
||||
- - breaking_changes
|
||||
- Breaking Changes / Porting Guide
|
||||
- - deprecated_features
|
||||
- Deprecated Features
|
||||
- - removed_features
|
||||
- Removed Features (previously deprecated)
|
||||
- - security_fixes
|
||||
- Security Fixes
|
||||
- - bugfixes
|
||||
- Bugfixes
|
||||
- - known_issues
|
||||
- Known Issues
|
||||
- - major_changes
|
||||
- Major Changes
|
||||
- - minor_changes
|
||||
- Minor Changes
|
||||
- - breaking_changes
|
||||
- Breaking Changes / Porting Guide
|
||||
- - deprecated_features
|
||||
- Deprecated Features
|
||||
- - removed_features
|
||||
- Removed Features (previously deprecated)
|
||||
- - security_fixes
|
||||
- Security Fixes
|
||||
- - bugfixes
|
||||
- Bugfixes
|
||||
- - known_issues
|
||||
- Known Issues
|
||||
title: Kubernetes Collection
|
||||
trivial_section_name: trivial
|
||||
|
||||
@@ -9,8 +9,8 @@ authors:
|
||||
- mmazur (https://github.com/mmazur)
|
||||
- jamescassell (https://github.com/jamescassell)
|
||||
description: Kubernetes Collection for Ansible.
|
||||
documentation: ''
|
||||
homepage: ''
|
||||
documentation: ""
|
||||
homepage: ""
|
||||
issues: https://github.com/ansible-collections/kubernetes.core/issues
|
||||
license_file: LICENSE
|
||||
namespace: kubernetes
|
||||
@@ -25,7 +25,7 @@ tags:
|
||||
- openshift
|
||||
- okd
|
||||
- cluster
|
||||
version: 2.4.0
|
||||
version: 2.4.1
|
||||
build_ignore:
|
||||
- .DS_Store
|
||||
- '*.tar.gz'
|
||||
- "*.tar.gz"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
requires_ansible: '>=2.9.17'
|
||||
requires_ansible: ">=2.9.17"
|
||||
|
||||
action_groups:
|
||||
helm:
|
||||
@@ -29,18 +29,18 @@ plugin_routing:
|
||||
warning_text: Use kubernetes.core.k8s_info instead.
|
||||
k8s_raw:
|
||||
tombstone:
|
||||
removal_version: 0.1.0
|
||||
removal_version: "0.1.0"
|
||||
warning_text: The k8s_raw module was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s instead.
|
||||
openshift_raw:
|
||||
tombstone:
|
||||
removal_version: 0.1.0
|
||||
removal_version: "0.1.0"
|
||||
warning_text: The openshift_raw module was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s instead.
|
||||
openshift_scale:
|
||||
tombstone:
|
||||
removal_version: 0.1.0
|
||||
removal_version: "0.1.0"
|
||||
warning_text: The openshift_scale module was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s_scale instead.
|
||||
lookup:
|
||||
openshift:
|
||||
tombstone:
|
||||
removal_version: 0.1.0
|
||||
removal_version: "0.1.0"
|
||||
warning_text: The openshift lookup plugin was slated for deprecation in Ansible 2.10 and has been removed. Use kubernetes.core.k8s instead.
|
||||
|
||||
@@ -1,12 +1,50 @@
|
||||
# Copyright (c) 2017 Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
DOCUMENTATION = r"""
|
||||
|
||||
name: k8s_config_resource_name
|
||||
short_description: Generate resource name for the given resource of type ConfigMap, Secret
|
||||
description:
|
||||
- Generate resource name for the given resource of type ConfigMap, Secret.
|
||||
- Resource must have a C(metadata.name) key to generate a resource name
|
||||
options:
|
||||
_input:
|
||||
description:
|
||||
- A valid YAML definition for a ConfigMap or a Secret.
|
||||
type: dict
|
||||
required: true
|
||||
author:
|
||||
- ansible cloud team
|
||||
|
||||
"""
|
||||
|
||||
EXAMPLES = r"""
|
||||
# Dump generated name for a configmap into a variable
|
||||
- set_fact:
|
||||
generated_name: '{{ definition | kubernetes.core.k8s_config_resource_name }}'
|
||||
vars:
|
||||
definition:
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: myconfigmap
|
||||
namespace: mynamespace
|
||||
"""
|
||||
|
||||
RETURN = r"""
|
||||
_value:
|
||||
description: Generated resource name.
|
||||
type: str
|
||||
"""
|
||||
|
||||
|
||||
from ansible.errors import AnsibleFilterError
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.hashes import (
|
||||
generate_hash,
|
||||
|
||||
@@ -27,7 +27,7 @@ DOCUMENTATION = """
|
||||
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
|
||||
'~/.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:
|
||||
@@ -38,7 +38,7 @@ DOCUMENTATION = """
|
||||
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
|
||||
configuration file from '~/.kube/config'. Can also be specified via K8S_AUTH_KUBECONFIG
|
||||
environment variable.
|
||||
context:
|
||||
description:
|
||||
@@ -94,24 +94,24 @@ DOCUMENTATION = """
|
||||
EXAMPLES = """
|
||||
# File must be named k8s.yaml or k8s.yml
|
||||
|
||||
# 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: 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
|
||||
|
||||
# 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 default config (~/.kube/config) file and active context, and return objects for a specific namespace
|
||||
plugin: kubernetes.core.k8s
|
||||
connections:
|
||||
- namespaces:
|
||||
- testing
|
||||
|
||||
# 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'
|
||||
- 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
|
||||
|
||||
@@ -114,7 +114,7 @@ class Discoverer(kubernetes.dynamic.discovery.Discoverer):
|
||||
filter(lambda resource: "/" in resource["name"], resources_response)
|
||||
)
|
||||
for subresource in subresources_raw:
|
||||
resource, name = subresource["name"].split("/")
|
||||
resource, name = subresource["name"].split("/", 1)
|
||||
subresources[resource][name] = subresource
|
||||
|
||||
for resource in resources_raw:
|
||||
|
||||
@@ -52,6 +52,7 @@ options:
|
||||
- If set to C(uninstalling), show releases that are currently being uninstalled.
|
||||
type: list
|
||||
elements: str
|
||||
default: []
|
||||
version_added: "2.3.0"
|
||||
get_all_values:
|
||||
description:
|
||||
|
||||
@@ -98,6 +98,7 @@ options:
|
||||
required: false
|
||||
type: list
|
||||
elements: str
|
||||
default: []
|
||||
version_added: 2.4.0
|
||||
values_files:
|
||||
description:
|
||||
|
||||
@@ -257,10 +257,10 @@ EXAMPLES = r"""
|
||||
kubernetes.core.k8s:
|
||||
state: present
|
||||
template:
|
||||
- path: '/testing/deployment_one.j2'
|
||||
- path: '/testing/deployment_two.j2'
|
||||
variable_start_string: '[['
|
||||
variable_end_string: ']]'
|
||||
- path: '/testing/deployment_one.j2'
|
||||
- path: '/testing/deployment_two.j2'
|
||||
variable_start_string: '[['
|
||||
variable_end_string: ']]'
|
||||
|
||||
- name: fail on validation errors
|
||||
kubernetes.core.k8s:
|
||||
|
||||
@@ -46,6 +46,7 @@ options:
|
||||
description:
|
||||
- Specify options to delete pods.
|
||||
- This option has effect only when C(state) is set to I(drain).
|
||||
default: {}
|
||||
suboptions:
|
||||
terminate_grace_period:
|
||||
description:
|
||||
@@ -103,7 +104,7 @@ EXAMPLES = r"""
|
||||
state: drain
|
||||
name: foo
|
||||
delete_options:
|
||||
terminate_grace_period: 900
|
||||
terminate_grace_period: 900
|
||||
|
||||
- name: Mark node "foo" as schedulable.
|
||||
kubernetes.core.k8s_drain:
|
||||
@@ -114,7 +115,6 @@ EXAMPLES = r"""
|
||||
kubernetes.core.k8s_drain:
|
||||
state: cordon
|
||||
name: foo
|
||||
|
||||
"""
|
||||
|
||||
RETURN = r"""
|
||||
|
||||
@@ -38,10 +38,12 @@ options:
|
||||
description: List of label selectors to use to filter results
|
||||
type: list
|
||||
elements: str
|
||||
default: []
|
||||
field_selectors:
|
||||
description: List of field selectors to use to filter results
|
||||
type: list
|
||||
elements: str
|
||||
default: []
|
||||
|
||||
extends_documentation_fragment:
|
||||
- kubernetes.core.k8s_auth_options
|
||||
|
||||
@@ -47,6 +47,7 @@ options:
|
||||
- Only one of I(name) or I(label_selectors) may be provided.
|
||||
type: list
|
||||
elements: str
|
||||
default: []
|
||||
container:
|
||||
description:
|
||||
- Use to specify the container within a pod to grab the log from.
|
||||
|
||||
@@ -24,10 +24,12 @@ options:
|
||||
description: List of label selectors to use to filter results.
|
||||
type: list
|
||||
elements: str
|
||||
default: []
|
||||
field_selectors:
|
||||
description: List of field selectors to use to filter results.
|
||||
type: list
|
||||
elements: str
|
||||
default: []
|
||||
extends_documentation_fragment:
|
||||
- kubernetes.core.k8s_auth_options
|
||||
- kubernetes.core.k8s_name_options
|
||||
|
||||
@@ -36,6 +36,7 @@ options:
|
||||
description: List of label selectors to use to filter results.
|
||||
type: list
|
||||
elements: str
|
||||
default: []
|
||||
version_added: 2.0.0
|
||||
continue_on_error:
|
||||
description:
|
||||
|
||||
@@ -5,3 +5,5 @@ pytest
|
||||
pytest-xdist
|
||||
pytest-mock
|
||||
pytest-forked
|
||||
virtualenv
|
||||
pytest-ansible
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
---
|
||||
- name: Test helm with in-memory kubeconfig
|
||||
include_tasks: "from_in_memory_kubeconfig.yml"
|
||||
loop_control:
|
||||
loop_var: test_helm_version
|
||||
with_items:
|
||||
- "v3.10.3"
|
||||
|
||||
- name: Test helm with custom kubeconfig and validate_certs=false
|
||||
include_tasks: "from_kubeconfig_with_validate_certs.yml"
|
||||
@@ -8,12 +12,10 @@
|
||||
loop_var: test_helm_version
|
||||
with_items:
|
||||
- "v3.10.3"
|
||||
- "v3.8.2"
|
||||
|
||||
- name: Test helm with custom kubeconfig and ca_cert
|
||||
include_tasks: "from_kubeconfig_with_cacert.yml"
|
||||
loop_control:
|
||||
loop_var: test_helm_version
|
||||
with_items:
|
||||
- "v3.5.1"
|
||||
- "v3.4.2"
|
||||
- "v3.10.3"
|
||||
|
||||
32
tests/integration/targets/k8s_info/tasks/discovery.yml
Normal file
32
tests/integration/targets/k8s_info/tasks/discovery.yml
Normal file
@@ -0,0 +1,32 @@
|
||||
---
|
||||
# Testing fix for issue https://github.com/ansible-collections/kubernetes.core/pull/676
|
||||
- vars:
|
||||
kubevirt_release: "v1.1.1"
|
||||
block:
|
||||
- name: Delete existing namespace
|
||||
kubernetes.core.k8s:
|
||||
kind: namespace
|
||||
namespace: kubevirt
|
||||
state: absent
|
||||
|
||||
- name: Create kubevirt resources
|
||||
kubernetes.core.k8s:
|
||||
state: present
|
||||
apply: true
|
||||
src: "{{ item }}"
|
||||
with_items:
|
||||
- "https://github.com/kubevirt/kubevirt/releases/download/{{ kubevirt_release }}/kubevirt-operator.yaml"
|
||||
- "https://github.com/kubevirt/kubevirt/releases/download/{{ kubevirt_release }}/kubevirt-cr.yaml"
|
||||
|
||||
- name: Read kubevirt Deployment
|
||||
k8s_info:
|
||||
kind: Deployment
|
||||
namespace: kubevirt
|
||||
always:
|
||||
- name: Delete existing namespace
|
||||
kubernetes.core.k8s:
|
||||
kind: namespace
|
||||
namespace: kubevirt
|
||||
state: absent
|
||||
wait: true
|
||||
ignore_errors: true
|
||||
@@ -3,3 +3,4 @@
|
||||
with_items:
|
||||
- wait
|
||||
- api-server-caching
|
||||
- discovery
|
||||
|
||||
@@ -3,16 +3,19 @@ plugins/module_utils/client/discovery.py import-3.7!skip
|
||||
plugins/module_utils/client/discovery.py import-3.8!skip
|
||||
plugins/module_utils/client/discovery.py import-3.9!skip
|
||||
plugins/module_utils/client/discovery.py import-3.10!skip
|
||||
plugins/module_utils/client/discovery.py import-3.11!skip
|
||||
plugins/module_utils/client/resource.py import-3.6!skip
|
||||
plugins/module_utils/client/resource.py import-3.7!skip
|
||||
plugins/module_utils/client/resource.py import-3.8!skip
|
||||
plugins/module_utils/client/resource.py import-3.9!skip
|
||||
plugins/module_utils/client/resource.py import-3.10!skip
|
||||
plugins/module_utils/client/resource.py import-3.11!skip
|
||||
plugins/module_utils/k8sdynamicclient.py import-3.6!skip
|
||||
plugins/module_utils/k8sdynamicclient.py import-3.7!skip
|
||||
plugins/module_utils/k8sdynamicclient.py import-3.8!skip
|
||||
plugins/module_utils/k8sdynamicclient.py import-3.9!skip
|
||||
plugins/module_utils/k8sdynamicclient.py import-3.10!skip
|
||||
plugins/module_utils/k8sdynamicclient.py import-3.11!skip
|
||||
plugins/modules/k8s.py validate-modules:parameter-type-not-in-doc
|
||||
plugins/modules/k8s_scale.py validate-modules:parameter-type-not-in-doc
|
||||
plugins/modules/k8s_service.py validate-modules:parameter-type-not-in-doc
|
||||
@@ -25,7 +28,6 @@ tests/integration/targets/helm/files/test-chart-v2/templates/configmap.yaml yaml
|
||||
tests/integration/targets/helm/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm_diff/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/k8s_scale/files/deployment.yaml yamllint!skip
|
||||
tests/sanity/refresh_ignore_files shebang!skip
|
||||
plugins/modules/k8s.py validate-modules:return-syntax-error
|
||||
plugins/modules/k8s_scale.py validate-modules:return-syntax-error
|
||||
plugins/modules/k8s_service.py validate-modules:return-syntax-error
|
||||
|
||||
@@ -16,6 +16,7 @@ plugins/module_utils/k8sdynamicclient.py import-3.8!skip
|
||||
plugins/module_utils/k8sdynamicclient.py import-3.9!skip
|
||||
plugins/module_utils/k8sdynamicclient.py import-3.10!skip
|
||||
plugins/module_utils/k8sdynamicclient.py import-3.11!skip
|
||||
plugins/module_utils/version.py pylint!skip
|
||||
plugins/modules/k8s.py validate-modules:parameter-type-not-in-doc
|
||||
plugins/modules/k8s_scale.py validate-modules:parameter-type-not-in-doc
|
||||
plugins/modules/k8s_service.py validate-modules:parameter-type-not-in-doc
|
||||
@@ -28,7 +29,6 @@ tests/integration/targets/helm/files/test-chart-v2/templates/configmap.yaml yaml
|
||||
tests/integration/targets/helm/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm_diff/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/k8s_scale/files/deployment.yaml yamllint!skip
|
||||
tests/sanity/refresh_ignore_files shebang!skip
|
||||
plugins/modules/k8s.py validate-modules:return-syntax-error
|
||||
plugins/modules/k8s_scale.py validate-modules:return-syntax-error
|
||||
plugins/modules/k8s_service.py validate-modules:return-syntax-error
|
||||
|
||||
38
tests/sanity/ignore-2.16.txt
Normal file
38
tests/sanity/ignore-2.16.txt
Normal file
@@ -0,0 +1,38 @@
|
||||
plugins/module_utils/client/discovery.py import-3.6!skip
|
||||
plugins/module_utils/client/discovery.py import-3.7!skip
|
||||
plugins/module_utils/client/discovery.py import-3.8!skip
|
||||
plugins/module_utils/client/discovery.py import-3.9!skip
|
||||
plugins/module_utils/client/discovery.py import-3.10!skip
|
||||
plugins/module_utils/client/discovery.py import-3.11!skip
|
||||
plugins/module_utils/client/discovery.py import-3.12!skip
|
||||
plugins/module_utils/client/resource.py import-3.6!skip
|
||||
plugins/module_utils/client/resource.py import-3.7!skip
|
||||
plugins/module_utils/client/resource.py import-3.8!skip
|
||||
plugins/module_utils/client/resource.py import-3.9!skip
|
||||
plugins/module_utils/client/resource.py import-3.10!skip
|
||||
plugins/module_utils/client/resource.py import-3.11!skip
|
||||
plugins/module_utils/client/resource.py import-3.12!skip
|
||||
plugins/module_utils/k8sdynamicclient.py import-3.6!skip
|
||||
plugins/module_utils/k8sdynamicclient.py import-3.7!skip
|
||||
plugins/module_utils/k8sdynamicclient.py import-3.8!skip
|
||||
plugins/module_utils/k8sdynamicclient.py import-3.9!skip
|
||||
plugins/module_utils/k8sdynamicclient.py import-3.10!skip
|
||||
plugins/module_utils/k8sdynamicclient.py import-3.11!skip
|
||||
plugins/module_utils/k8sdynamicclient.py import-3.12!skip
|
||||
plugins/module_utils/version.py pylint!skip
|
||||
plugins/modules/k8s.py validate-modules:parameter-type-not-in-doc
|
||||
plugins/modules/k8s_scale.py validate-modules:parameter-type-not-in-doc
|
||||
plugins/modules/k8s_service.py validate-modules:parameter-type-not-in-doc
|
||||
tests/unit/module_utils/fixtures/definitions.yml yamllint!skip
|
||||
tests/unit/module_utils/fixtures/deployments.yml yamllint!skip
|
||||
tests/unit/module_utils/fixtures/pods.yml yamllint!skip
|
||||
tests/integration/targets/helm/files/appversionless-chart-v2/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm/files/appversionless-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm/files/test-chart-v2/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm_diff/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/k8s_scale/files/deployment.yaml yamllint!skip
|
||||
plugins/modules/k8s.py validate-modules:return-syntax-error
|
||||
plugins/modules/k8s_scale.py validate-modules:return-syntax-error
|
||||
plugins/modules/k8s_service.py validate-modules:return-syntax-error
|
||||
plugins/modules/k8s_taint.py validate-modules:return-syntax-error
|
||||
29
tests/sanity/ignore-2.17.txt
Normal file
29
tests/sanity/ignore-2.17.txt
Normal file
@@ -0,0 +1,29 @@
|
||||
plugins/module_utils/client/discovery.py import-3.9!skip
|
||||
plugins/module_utils/client/discovery.py import-3.10!skip
|
||||
plugins/module_utils/client/discovery.py import-3.11!skip
|
||||
plugins/module_utils/client/discovery.py import-3.12!skip
|
||||
plugins/module_utils/client/resource.py import-3.9!skip
|
||||
plugins/module_utils/client/resource.py import-3.10!skip
|
||||
plugins/module_utils/client/resource.py import-3.11!skip
|
||||
plugins/module_utils/client/resource.py import-3.12!skip
|
||||
plugins/module_utils/k8sdynamicclient.py import-3.9!skip
|
||||
plugins/module_utils/k8sdynamicclient.py import-3.10!skip
|
||||
plugins/module_utils/k8sdynamicclient.py import-3.11!skip
|
||||
plugins/module_utils/k8sdynamicclient.py import-3.12!skip
|
||||
plugins/module_utils/version.py pylint!skip
|
||||
plugins/modules/k8s.py validate-modules:parameter-type-not-in-doc
|
||||
plugins/modules/k8s_scale.py validate-modules:parameter-type-not-in-doc
|
||||
plugins/modules/k8s_service.py validate-modules:parameter-type-not-in-doc
|
||||
tests/unit/module_utils/fixtures/definitions.yml yamllint!skip
|
||||
tests/unit/module_utils/fixtures/deployments.yml yamllint!skip
|
||||
tests/unit/module_utils/fixtures/pods.yml yamllint!skip
|
||||
tests/integration/targets/helm/files/appversionless-chart-v2/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm/files/appversionless-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm/files/test-chart-v2/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/helm_diff/files/test-chart/templates/configmap.yaml yamllint!skip
|
||||
tests/integration/targets/k8s_scale/files/deployment.yaml yamllint!skip
|
||||
plugins/modules/k8s.py validate-modules:return-syntax-error
|
||||
plugins/modules/k8s_scale.py validate-modules:return-syntax-error
|
||||
plugins/modules/k8s_service.py validate-modules:return-syntax-error
|
||||
plugins/modules/k8s_taint.py validate-modules:return-syntax-error
|
||||
@@ -1,216 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
import itertools
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
# Mapping of Ansible versions to supported Python versions
|
||||
ANSIBLE_VERSIONS = {
|
||||
"2.9": ["3.6", "3.7", "3.8"],
|
||||
"2.10": ["3.6", "3.7", "3.8", "3.9"],
|
||||
"2.11": ["3.6", "3.7", "3.8", "3.9"],
|
||||
"2.12": ["3.6", "3.7", "3.8", "3.9", "3.10"],
|
||||
"2.13": ["3.6", "3.7", "3.8", "3.9", "3.10"],
|
||||
"2.14": ["3.6", "3.7", "3.8", "3.9", "3.10"],
|
||||
"2.15": ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"],
|
||||
}
|
||||
|
||||
IMPORT_SKIPS = [
|
||||
"plugins/module_utils/client/discovery.py",
|
||||
"plugins/module_utils/client/resource.py",
|
||||
"plugins/module_utils/k8sdynamicclient.py",
|
||||
]
|
||||
|
||||
# Adds validate-modules:parameter-type-not-in-doc
|
||||
PARAM_TYPE_SKIPS = [
|
||||
"plugins/modules/k8s.py",
|
||||
"plugins/modules/k8s_scale.py",
|
||||
"plugins/modules/k8s_service.py",
|
||||
]
|
||||
|
||||
# Adds validate-modules:return-syntax-error
|
||||
RETURN_SYNTAX_SKIPS = [
|
||||
"plugins/modules/k8s.py",
|
||||
"plugins/modules/k8s_scale.py",
|
||||
"plugins/modules/k8s_service.py",
|
||||
"plugins/modules/k8s_taint.py",
|
||||
]
|
||||
|
||||
YAML_LINT_SKIPS = [
|
||||
"tests/unit/module_utils/fixtures/definitions.yml",
|
||||
"tests/unit/module_utils/fixtures/deployments.yml",
|
||||
"tests/unit/module_utils/fixtures/pods.yml",
|
||||
"tests/integration/targets/helm/files/appversionless-chart-v2/templates/configmap.yaml",
|
||||
"tests/integration/targets/helm/files/appversionless-chart/templates/configmap.yaml",
|
||||
"tests/integration/targets/helm/files/test-chart-v2/templates/configmap.yaml",
|
||||
"tests/integration/targets/helm/files/test-chart/templates/configmap.yaml",
|
||||
"tests/integration/targets/helm_diff/files/test-chart/templates/configmap.yaml",
|
||||
"tests/integration/targets/k8s_scale/files/deployment.yaml",
|
||||
]
|
||||
|
||||
# Add shebang!skip
|
||||
SHEBANG_SKIPS = [
|
||||
"tests/sanity/refresh_ignore_files",
|
||||
]
|
||||
|
||||
# Add validate-modules:import-error
|
||||
VALIDATE_IMPORT_SKIPS = [
|
||||
"plugins/modules/k8s.py",
|
||||
"plugins/modules/k8s_cp.py",
|
||||
"plugins/modules/k8s_drain.py",
|
||||
"plugins/modules/k8s_exec.py",
|
||||
"plugins/modules/k8s_info.py",
|
||||
"plugins/modules/k8s_json_patch.py",
|
||||
"plugins/modules/k8s_log.py",
|
||||
"plugins/modules/k8s_rollback.py",
|
||||
"plugins/modules/k8s_scale.py",
|
||||
"plugins/modules/k8s_service.py",
|
||||
"plugins/modules/k8s_taint.py",
|
||||
]
|
||||
|
||||
|
||||
def import_skips(*versions):
|
||||
for f in IMPORT_SKIPS:
|
||||
for v in versions:
|
||||
yield f"{f} import-{v}!skip"
|
||||
|
||||
def param_type_skips(ansible_version):
|
||||
if ansible_version not in ("2.9", "2.10"):
|
||||
for f in PARAM_TYPE_SKIPS:
|
||||
yield f"{f} validate-modules:parameter-type-not-in-doc"
|
||||
|
||||
|
||||
def return_syntax_skips(ansible_version):
|
||||
if ansible_version not in ("2.9", "2.10"):
|
||||
for f in RETURN_SYNTAX_SKIPS:
|
||||
yield f"{f} validate-modules:return-syntax-error"
|
||||
else:
|
||||
yield
|
||||
|
||||
|
||||
def yaml_lint_skips():
|
||||
for f in YAML_LINT_SKIPS:
|
||||
yield f"{f} yamllint!skip"
|
||||
|
||||
|
||||
def shebang_skips():
|
||||
for f in SHEBANG_SKIPS:
|
||||
yield f"{f} shebang!skip"
|
||||
|
||||
|
||||
def import_boilerplate(path, ansible_version):
|
||||
if ansible_version in ("2.9", "2.10", "2.11"):
|
||||
for f in (p for p in path.glob("**/*.py") if not p.is_symlink()):
|
||||
yield f"{f} future-import-boilerplate!skip"
|
||||
else:
|
||||
yield
|
||||
|
||||
|
||||
def metaclass_boilerplate(path, ansible_version):
|
||||
if ansible_version in ("2.9", "2.10", "2.11"):
|
||||
for f in (p for p in path.glob("**/*.py") if not p.is_symlink()):
|
||||
yield f"{f} metaclass-boilerplate!skip"
|
||||
else:
|
||||
yield
|
||||
|
||||
|
||||
def unsupported_compile_skips(path, ansible_version):
|
||||
"""This adds rules for compile skips for all unsupported versions of python.
|
||||
|
||||
These aren't needed for Ansible version 2.12+ as that can be managed on a
|
||||
global level in tests/config.yml.
|
||||
"""
|
||||
if ansible_version in ("2.9", "2.10", "2.11"):
|
||||
for f in (p for p in path.glob("**/*.py") if not p.is_symlink()):
|
||||
yield (
|
||||
f"{f} compile-2.6!skip\n"
|
||||
f"{f} compile-2.7!skip\n"
|
||||
f"{f} compile-3.5!skip"
|
||||
)
|
||||
|
||||
|
||||
def unsupported_import_skips(path, ansible_version):
|
||||
"""This adds rules for import skips for all unsupported versions of python.
|
||||
|
||||
These aren't needed for Ansible version 2.12+ as that can be managed on a
|
||||
global level in tests/config.yml.
|
||||
"""
|
||||
if ansible_version in ("2.9", "2.10", "2.11"):
|
||||
if ansible_version in ("2.9", "2.10") and path.name == "plugins":
|
||||
pathglob = itertools.chain(
|
||||
path.joinpath("modules").glob("**/*.py"),
|
||||
path.joinpath("module_utils").glob("**/*.py")
|
||||
)
|
||||
else:
|
||||
pathglob = path.glob("**/*.py")
|
||||
for f in (p for p in pathglob if not p.is_symlink()):
|
||||
yield (
|
||||
f"{f} import-2.6!skip\n"
|
||||
f"{f} import-2.7!skip\n"
|
||||
f"{f} import-3.5!skip"
|
||||
)
|
||||
|
||||
|
||||
def unsupported_pylint_skips(path, ansible_version):
|
||||
"""This adds rules to skip pylint checks.
|
||||
|
||||
This is only a problem on Ansible version 2.9 and 2.10 with python 3.5,
|
||||
but there's no way to restrict this to a specific version of python.
|
||||
"""
|
||||
if ansible_version in ("2.9", "2.10"):
|
||||
pathglob = itertools.chain(
|
||||
path.joinpath("plugins/modules").glob("**/*.py"),
|
||||
path.joinpath("plugins/module_utils").glob("**/*.py"),
|
||||
path.joinpath("tests").glob("**/*.py"),
|
||||
)
|
||||
for f in (p for p in pathglob if not p.is_symlink()):
|
||||
yield f"{f} pylint!skip"
|
||||
|
||||
|
||||
def unsupported_validate_modules_skips(ansible_version):
|
||||
"""Disable validate-modules test.
|
||||
|
||||
Unfortunately, this is overly broad. Applying a validate-modules:import-error
|
||||
skip fixes ansible 2.9 and python <3.6, but causes validation of the ignores
|
||||
file itself to fail in python 3.6+. The only solution here is to simply
|
||||
skip validate-modules altogether.
|
||||
"""
|
||||
if ansible_version in ("2.9", "2.10"):
|
||||
for f in VALIDATE_IMPORT_SKIPS:
|
||||
yield f"{f} validate-modules!skip"
|
||||
|
||||
|
||||
def main():
|
||||
target_dir = Path('.')
|
||||
sanity_dir = target_dir / "tests" / "sanity"
|
||||
plugins = target_dir / "plugins"
|
||||
units = target_dir / "tests" / "unit"
|
||||
integration = target_dir / "tests" / "integration"
|
||||
|
||||
for ansible, python in ANSIBLE_VERSIONS.items():
|
||||
with open(sanity_dir / f"ignore-{ansible}.txt", "w") as fp:
|
||||
ignores = itertools.chain(
|
||||
import_skips(*python),
|
||||
param_type_skips(ansible),
|
||||
yaml_lint_skips(),
|
||||
shebang_skips(),
|
||||
return_syntax_skips(ansible),
|
||||
import_boilerplate(plugins, ansible),
|
||||
import_boilerplate(units, ansible),
|
||||
metaclass_boilerplate(plugins, ansible),
|
||||
metaclass_boilerplate(units, ansible),
|
||||
unsupported_import_skips(plugins, ansible),
|
||||
unsupported_compile_skips(plugins, ansible),
|
||||
unsupported_compile_skips(units, ansible),
|
||||
unsupported_compile_skips(integration, ansible),
|
||||
unsupported_pylint_skips(target_dir, ansible),
|
||||
unsupported_validate_modules_skips(ansible),
|
||||
)
|
||||
for f in filter(None, ignores):
|
||||
fp.write(f + "\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user