From 2dbb33a3d7732276fd8f1de1652625fae270d3e8 Mon Sep 17 00:00:00 2001 From: ERIK Date: Sat, 26 Sep 2026 23:18:27 +0800 Subject: [PATCH] build: upgrade to Ansible 14 (#13549) Raise ansible-core support to 2.21 for maintained upstream support through November 2027. This requires Python 3.12-3.14 on control nodes and 3.9-3.14 on targets. Signed-off-by: bo.jiang --- .ansible-lint | 3 +++ .ansible-lint-ignore | 2 ++ .pre-commit-config.yaml | 9 +++++---- README.md | 2 +- docs/ansible/ansible.md | 16 ++++++++-------- docs/developers/vagrant.md | 6 ++++-- meta/runtime.yml | 2 +- playbooks/ansible_version.yml | 4 ++-- requirements.txt | 2 +- 9 files changed, 27 insertions(+), 19 deletions(-) create mode 100644 .ansible-lint-ignore diff --git a/.ansible-lint b/.ansible-lint index 00df7f92f..653ec467c 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -1,4 +1,7 @@ --- +supported_ansible_also: + - '2.21.' + skip_list: # see https://docs.ansible.com/ansible-lint/rules/default_rules.html for a list of all default rules diff --git a/.ansible-lint-ignore b/.ansible-lint-ignore new file mode 100644 index 000000000..3e420d696 --- /dev/null +++ b/.ansible-lint-ignore @@ -0,0 +1,2 @@ +# astl v0.5.1 does not honor supported_ansible_also for this rule; ansible-lint validates it. +meta/runtime.yml meta-runtime[unsupported-version] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6a4dbd179..125284068 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,12 +34,13 @@ repos: - id: astl - repo: https://github.com/ansible/ansible-lint - rev: v25.11.0 + rev: v26.9.0 hooks: - id: ansible-lint + language_version: python3 stages: [manual] additional_dependencies: - - ansible-core>=2.18.0,<2.19.0 + - ansible-core>=2.21.0,<2.22.0 - jmespath==1.0.1 - netaddr==1.3.0 - distlib @@ -58,7 +59,7 @@ repos: name: Build and install kubernetes-sigs.kubespray Ansible collection language: python additional_dependencies: - - ansible-core>=2.18.0,<2.19.0 + - ansible-core>=2.21.0,<2.22.0 - distlib entry: tests/scripts/collection-build-install.sh pass_filenames: false @@ -100,7 +101,7 @@ repos: name: Update static files referencing default kubespray values language: python additional_dependencies: - - ansible-core>=2.18.0,<2.19.0 + - ansible-core>=2.21.0,<2.22.0 entry: scripts/propagate_ansible_variables.yml pass_filenames: false diff --git a/README.md b/README.md index 8211ab27a..cce6e7441 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,7 @@ Note: - **Minimum required version of Kubernetes is v1.35.0** -- **Ansible v2.14+, Jinja 2.11+ and python-netaddr is installed on the machine that will run Ansible commands** +- **Ansible 14 (ansible-core 2.21), Jinja 3.1+ and python-netaddr are installed on the machine that will run Ansible commands** - The target servers must have **access to the Internet** in order to pull docker images. Otherwise, additional configuration is required (See [Offline Environment](docs/operations/offline-environment.md)) - The target servers are configured to allow **IPv4 forwarding**. - If using IPv6 for pods and services, the target servers are configured to allow **IPv6 forwarding**. diff --git a/docs/ansible/ansible.md b/docs/ansible/ansible.md index d17e3e44e..46ba7748c 100644 --- a/docs/ansible/ansible.md +++ b/docs/ansible/ansible.md @@ -2,8 +2,8 @@ ## Installing Ansible -Kubespray supports multiple ansible versions and ships different `requirements.txt` files for them. -Depending on your available python version you may be limited in choosing which ansible version to use. +Kubespray pins its supported Ansible version in `requirements.txt`. +Your available Python version may limit which Ansible version you can use. It is recommended to deploy the ansible version used by kubespray into a python virtual environment. @@ -19,20 +19,20 @@ pip install -r requirements.txt In case you have a similar message when installing the requirements: ```ShellSession -ERROR: Could not find a version that satisfies the requirement ansible==7.6.0 (from -r requirements.txt (line 1)) (from versions: [...], 6.7.0) -ERROR: No matching distribution found for ansible==7.6.0 (from -r requirements.txt (line 1)) +ERROR: Could not find a version that satisfies the requirement ansible==14.4.0 (from -r requirements.txt (line 1)) (from versions: [...]) +ERROR: No matching distribution found for ansible==14.4.0 (from -r requirements.txt (line 1)) ``` It means that the version of Python you are running is not compatible with the version of Ansible that Kubespray supports. -If the latest version supported according to pip is 6.7.0 it means you are running Python 3.8 or lower while you need at least Python 3.9 (see the table below). +Ansible 14 supports Python 3.12 through 3.14 on the Ansible control node (see the table below). ### Ansible Python Compatibility Based on the table below and the available python version for your ansible host you should choose the appropriate ansible version to use with kubespray. -| Ansible Version | Python Version | -|-------------------|----------------| -| >=2.19.0, <2.20.0 | 3.11-3.13 | +| ansible-core Version | Control Node Python Version | Target Node Python Version | +|----------------------|-----------------------------|----------------------------| +| >=2.21.0, <2.22.0 | 3.12-3.14 | 3.9-3.14 | ## Customize Ansible vars diff --git a/docs/developers/vagrant.md b/docs/developers/vagrant.md index 0510713ce..e7884124c 100644 --- a/docs/developers/vagrant.md +++ b/docs/developers/vagrant.md @@ -79,9 +79,11 @@ The following is an example of setting up and running kubespray using `vagrant`. Customize your settings as shown, above, then run the commands: ```ShellSession -# use virtualenv to install all python requirements +# python3 must be version 3.12 through 3.14 +$ python3 --version +# use venv to install all Python requirements VENVDIR=venv -$ virtualenv --python=/usr/bin/python3.7 $VENVDIR +$ python3 -m venv $VENVDIR $ source $VENVDIR/bin/activate $ pip install -r requirements.txt diff --git a/meta/runtime.yml b/meta/runtime.yml index a59573fc4..12b88fb09 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -1,2 +1,2 @@ --- -requires_ansible: ">=2.19.0,<2.20.0" +requires_ansible: ">=2.21.0,<2.22.0" diff --git a/playbooks/ansible_version.yml b/playbooks/ansible_version.yml index 611d0f76a..5c98dee4e 100644 --- a/playbooks/ansible_version.yml +++ b/playbooks/ansible_version.yml @@ -5,8 +5,8 @@ become: false run_once: true vars: - minimal_ansible_version: 2.19.0 - maximal_ansible_version: 2.20.0 + minimal_ansible_version: 2.21.0 + maximal_ansible_version: 2.22.0 tags: always tasks: - name: "Check {{ minimal_ansible_version }} <= Ansible version < {{ maximal_ansible_version }}" diff --git a/requirements.txt b/requirements.txt index c0075ad1b..b39d8feed 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -ansible==12.3.0 +ansible==14.4.0 # Prevented passlib version conflicts bcrypt<6 # Needed for community.crypto module