From 4ea40e9473ef266e2dbe7d8d4e47c32cf2b26872 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 11 Oct 2023 16:13:14 +0200 Subject: [PATCH] Drop support for ansible-core 2.11 and 2.12 (#7269) * Drop support for ansible-core 2.11 and 2.12. Also move ansible-core 2.13 from regular CI to EOL CI. * Remove some compatibility code. * Remove no longer needed import. * Update README. Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --------- Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --- .azure-pipelines/azure-pipelines.yml | 4 +- .github/workflows/ansible-test.yml | 116 +----------------- README.md | 4 +- .../fragments/ansible-core-2.11-2.12.yml | 12 ++ meta/runtime.yml | 2 +- plugins/callback/selective.py | 17 +-- plugins/lookup/collection_version.py | 11 +- plugins/module_utils/version.py | 11 +- 8 files changed, 29 insertions(+), 148 deletions(-) create mode 100644 changelogs/fragments/ansible-core-2.11-2.12.yml diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml index 071d5b81d1..f2f1c2e963 100644 --- a/.azure-pipelines/azure-pipelines.yml +++ b/.azure-pipelines/azure-pipelines.yml @@ -244,10 +244,10 @@ stages: parameters: testFormat: 2.14/{0} targets: - - name: RHEL 9.0 - test: rhel/9.0 - name: macOS 12.0 test: macos/12.0 + - name: RHEL 9.0 + test: rhel/9.0 #- name: FreeBSD 12.4 # test: freebsd/12.4 groups: diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index e38e438094..bc9daaa43e 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -29,23 +29,17 @@ jobs: strategy: matrix: ansible: - - '2.11' - - '2.12' - '2.13' # Ansible-test on various stable branches does not yet work well with cgroups v2. # Since ubuntu-latest now uses Ubuntu 22.04, we need to fall back to the ubuntu-20.04 # image for these stable branches. The list of branches where this is necessary will # shrink over time, check out https://github.com/ansible-collections/news-for-maintainers/issues/28 # for the latest list. - runs-on: >- - ${{ contains(fromJson( - '["2.9", "2.10", "2.11"]' - ), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }} + runs-on: ubuntu-latest steps: - name: Perform sanity testing uses: felixfontein/ansible-test-gh-action@main with: - ansible-core-github-repository-slug: ${{ contains(fromJson('["2.10", "2.11"]'), matrix.ansible) && 'felixfontein/ansible' || 'ansible/ansible' }} ansible-core-version: stable-${{ matrix.ansible }} coverage: ${{ github.event_name == 'schedule' && 'always' || 'never' }} pull-request-change-detection: 'true' @@ -57,10 +51,7 @@ jobs: # image for these stable branches. The list of branches where this is necessary will # shrink over time, check out https://github.com/ansible-collections/news-for-maintainers/issues/28 # for the latest list. - runs-on: >- - ${{ contains(fromJson( - '["2.9", "2.10", "2.11"]' - ), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }} + runs-on: ubuntu-latest name: EOL Units (Ⓐ${{ matrix.ansible }}+py${{ matrix.python }}) strategy: # As soon as the first unit test fails, cancel the others to free up the CI queue @@ -73,13 +64,9 @@ jobs: exclude: - ansible: '' include: - - ansible: '2.11' + - ansible: '2.13' python: '2.7' - - ansible: '2.11' - python: '3.5' - - ansible: '2.12' - python: '2.6' - - ansible: '2.12' + - ansible: '2.13' python: '3.8' - ansible: '2.13' python: '2.7' @@ -92,7 +79,6 @@ jobs: Ansible version ${{ matrix.ansible }} uses: felixfontein/ansible-test-gh-action@main with: - ansible-core-github-repository-slug: ${{ contains(fromJson('["2.10", "2.11"]'), matrix.ansible) && 'felixfontein/ansible' || 'ansible/ansible' }} ansible-core-version: stable-${{ matrix.ansible }} coverage: ${{ github.event_name == 'schedule' && 'always' || 'never' }} pre-test-cmd: >- @@ -109,10 +95,7 @@ jobs: # image for these stable branches. The list of branches where this is necessary will # shrink over time, check out https://github.com/ansible-collections/news-for-maintainers/issues/28 # for the latest list. - runs-on: >- - ${{ contains(fromJson( - '["2.9", "2.10", "2.11"]' - ), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }} + runs-on: ubuntu-latest name: EOL I (Ⓐ${{ matrix.ansible }}+${{ matrix.docker }}+py${{ matrix.python }}:${{ matrix.target }}) strategy: fail-fast: false @@ -128,94 +111,6 @@ jobs: exclude: - ansible: '' include: - # 2.11 - - ansible: '2.11' - docker: fedora32 - python: '' - target: azp/posix/1/ - - ansible: '2.11' - docker: fedora32 - python: '' - target: azp/posix/2/ - - ansible: '2.11' - docker: fedora32 - python: '' - target: azp/posix/3/ - - ansible: '2.11' - docker: fedora33 - python: '' - target: azp/posix/1/ - - ansible: '2.11' - docker: fedora33 - python: '' - target: azp/posix/2/ - - ansible: '2.11' - docker: fedora33 - python: '' - target: azp/posix/3/ - - ansible: '2.11' - docker: alpine3 - python: '' - target: azp/posix/1/ - - ansible: '2.11' - docker: alpine3 - python: '' - target: azp/posix/2/ - - ansible: '2.11' - docker: alpine3 - python: '' - target: azp/posix/3/ - # Right now all generic tests are disabled. Uncomment when at least one of them is re-enabled. - # - ansible: '2.11' - # docker: default - # python: '2.7' - # target: azp/generic/1/ - # - ansible: '2.11' - # docker: default - # python: '3.5' - # target: azp/generic/1/ - # 2.12 - - ansible: '2.12' - docker: centos6 - python: '' - target: azp/posix/1/ - - ansible: '2.12' - docker: centos6 - python: '' - target: azp/posix/2/ - - ansible: '2.12' - docker: centos6 - python: '' - target: azp/posix/3/ - - ansible: '2.12' - docker: fedora34 - python: '' - target: azp/posix/1/ - - ansible: '2.12' - docker: fedora34 - python: '' - target: azp/posix/2/ - - ansible: '2.12' - docker: fedora34 - python: '' - target: azp/posix/3/ - - ansible: '2.12' - docker: ubuntu1804 - python: '' - target: azp/posix/1/ - - ansible: '2.12' - docker: ubuntu1804 - python: '' - target: azp/posix/2/ - - ansible: '2.12' - docker: ubuntu1804 - python: '' - target: azp/posix/3/ - # Right now all generic tests are disabled. Uncomment when at least one of them is re-enabled. - # - ansible: '2.12' - # docker: default - # python: '3.8' - # target: azp/generic/1/ # 2.13 - ansible: '2.13' docker: fedora35 @@ -266,7 +161,6 @@ jobs: under Python ${{ matrix.python }} uses: felixfontein/ansible-test-gh-action@main with: - ansible-core-github-repository-slug: ${{ contains(fromJson('["2.10", "2.11"]'), matrix.ansible) && 'felixfontein/ansible' || 'ansible/ansible' }} ansible-core-version: stable-${{ matrix.ansible }} coverage: ${{ github.event_name == 'schedule' && 'always' || 'never' }} docker-image: ${{ matrix.docker }} diff --git a/README.md b/README.md index 274e0b6d29..f4f3647f5e 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,7 @@ If you encounter abusive behavior violating the [Ansible Code of Conduct](https: ## Tested with Ansible -Tested with the current ansible-core 2.11, ansible-core 2.12, ansible-core 2.13, ansible-core 2.14, ansible-core 2.15, ansible-core 2.16 releases and the current development version of ansible-core. Ansible-core versions before 2.11.0 are not supported. This includes all ansible-base 2.10 and Ansible 2.9 releases. - -Parts of this collection will not work with ansible-core 2.11 on Python 3.12+. +Tested with the current ansible-core 2.13, ansible-core 2.14, ansible-core 2.15, ansible-core 2.16 releases and the current development version of ansible-core. Ansible-core versions before 2.13.0 are not supported. This includes all ansible-base 2.10 and Ansible 2.9 releases. ## External requirements diff --git a/changelogs/fragments/ansible-core-2.11-2.12.yml b/changelogs/fragments/ansible-core-2.11-2.12.yml new file mode 100644 index 0000000000..74c182f2ab --- /dev/null +++ b/changelogs/fragments/ansible-core-2.11-2.12.yml @@ -0,0 +1,12 @@ +removed_features: + - "The collection no longer supports ansible-core 2.11 and ansible-core 2.12. + Parts of the collection might still work on these ansible-core versions, but others might not + (https://github.com/ansible-collections/community.general/pull/7269)." +breaking_changes: + - "selective callback plugin - remove compatibility code for Ansible 2.9 and ansible-core 2.10 + (https://github.com/ansible-collections/community.general/pull/7269)." + - "collection_version lookup plugin - remove compatibility code for ansible-base 2.10 and ansible-core 2.11 + (https://github.com/ansible-collections/community.general/pull/7269)." + - "version module util - remove fallback for ansible-core 2.11. All modules and plugins that do + version collections no longer work with ansible-core 2.11 + (https://github.com/ansible-collections/community.general/pull/7269)." diff --git a/meta/runtime.yml b/meta/runtime.yml index 677a3f1fce..2ea3dbebd2 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -3,7 +3,7 @@ # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # SPDX-License-Identifier: GPL-3.0-or-later -requires_ansible: '>=2.11.0' +requires_ansible: '>=2.13.0' plugin_routing: connection: docker: diff --git a/plugins/callback/selective.py b/plugins/callback/selective.py index 526975bd2c..3ad36fb120 100644 --- a/plugins/callback/selective.py +++ b/plugins/callback/selective.py @@ -44,26 +44,17 @@ from ansible import constants as C from ansible.plugins.callback import CallbackBase from ansible.module_utils.common.text.converters import to_text -try: - codeCodes = C.COLOR_CODES -except AttributeError: - # This constant was moved to ansible.constants in - # https://github.com/ansible/ansible/commit/1202dd000f10b0e8959019484f1c3b3f9628fc67 - # (will be included in ansible-core 2.11.0). For older Ansible/ansible-base versions, - # we include from the original location. - from ansible.utils.color import codeCodes - DONT_COLORIZE = False COLORS = { 'normal': '\033[0m', - 'ok': '\033[{0}m'.format(codeCodes[C.COLOR_OK]), + 'ok': '\033[{0}m'.format(C.COLOR_CODES[C.COLOR_OK]), 'bold': '\033[1m', 'not_so_bold': '\033[1m\033[34m', - 'changed': '\033[{0}m'.format(codeCodes[C.COLOR_CHANGED]), - 'failed': '\033[{0}m'.format(codeCodes[C.COLOR_ERROR]), + 'changed': '\033[{0}m'.format(C.COLOR_CODES[C.COLOR_CHANGED]), + 'failed': '\033[{0}m'.format(C.COLOR_CODES[C.COLOR_ERROR]), 'endc': '\033[0m', - 'skipped': '\033[{0}m'.format(codeCodes[C.COLOR_SKIP]), + 'skipped': '\033[{0}m'.format(C.COLOR_CODES[C.COLOR_SKIP]), } diff --git a/plugins/lookup/collection_version.py b/plugins/lookup/collection_version.py index 0e2388a181..33316fc2b0 100644 --- a/plugins/lookup/collection_version.py +++ b/plugins/lookup/collection_version.py @@ -98,15 +98,10 @@ def load_collection_meta(collection_pkg, no_version='*'): if os.path.exists(manifest_path): return load_collection_meta_manifest(manifest_path) - # Try to load galaxy.y(a)ml + # Try to load galaxy.yml galaxy_path = os.path.join(path, 'galaxy.yml') - galaxy_alt_path = os.path.join(path, 'galaxy.yaml') - # galaxy.yaml was only supported in ansible-base 2.10 and ansible-core 2.11. Support was removed - # in https://github.com/ansible/ansible/commit/595413d11346b6f26bb3d9df2d8e05f2747508a3 for - # ansible-core 2.12. - for path in (galaxy_path, galaxy_alt_path): - if os.path.exists(path): - return load_collection_meta_galaxy(path, no_version=no_version) + if os.path.exists(galaxy_path): + return load_collection_meta_galaxy(galaxy_path, no_version=no_version) return {} diff --git a/plugins/module_utils/version.py b/plugins/module_utils/version.py index 3699881978..935e8005e5 100644 --- a/plugins/module_utils/version.py +++ b/plugins/module_utils/version.py @@ -10,13 +10,4 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type -from ansible.module_utils.six import raise_from - -try: - from ansible.module_utils.compat.version import LooseVersion # noqa: F401, pylint: disable=unused-import -except ImportError: - try: - from distutils.version import LooseVersion # noqa: F401, pylint: disable=unused-import - except ImportError as exc: - msg = 'To use this plugin or module with ansible-core 2.11, you need to use Python < 3.12 with distutils.version present' - raise_from(ImportError(msg), exc) +from ansible.module_utils.compat.version import LooseVersion # noqa: F401, pylint: disable=unused-import