From 9fae3b5ebdbae140ce94f8acf82b6af2ee348c5b Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Wed, 22 Jan 2025 18:48:34 +0000 Subject: [PATCH] Drop code related to unsupported ansible versions (#4376) Related: https://github.com/ansible/ansible-compat/pull/449 --- README.md | 4 +--- docs/index.md | 4 +--- docs/installation.md | 4 +--- src/molecule/config.py | 17 ++--------------- src/molecule/provisioner/ansible.py | 2 +- .../scenarios/driver/delegated/meta/main.yml | 2 +- .../meta/main.yml | 2 +- .../resources/roles/molecule/meta/main.yml | 2 +- tox.ini | 2 +- 9 files changed, 10 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 8176893258..6fbe026ce8 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,7 @@ testing scenarios. Molecule encourages an approach that results in consistently developed roles that are well-written, easily understood and maintained. -Molecule supports only the latest two major versions of Ansible (N/N-1), -meaning that if the latest version is 2.9.x, we will also test our code -with 2.8.x. +Molecule supports only the latest two major versions of Ansible (N/N-1). Once installed, the command line can be called using any of the methods below: diff --git a/docs/index.md b/docs/index.md index 4383114396..45cea687b2 100644 --- a/docs/index.md +++ b/docs/index.md @@ -16,9 +16,7 @@ testing scenarios. Molecule encourages an approach that results in consistently developed roles that are well-written, easily understood and maintained. -Molecule supports only the latest two major versions of Ansible (N/N-1), -meaning that if the latest version is 2.9.x, we will also test our code -with 2.8.x. +Molecule supports only the latest two major versions of Ansible (N/N-1). Once installed, the command line can be called using any of the methods below: diff --git a/docs/installation.md b/docs/installation.md index c3e837dbfd..6baca58dd7 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -6,13 +6,11 @@ Molecule. ## Requirements -- ansible-core >= 2.12 +A recent version of `ansible-core` that is still under support. Depending on the driver chosen, you may need to install additional OS packages. -- Python >= 3.10 - === "CentOS" ``` bash diff --git a/src/molecule/config.py b/src/molecule/config.py index ad6ca1a704..a24ff014a0 100644 --- a/src/molecule/config.py +++ b/src/molecule/config.py @@ -30,7 +30,6 @@ from uuid import uuid4 from ansible_compat.ports import cache, cached_property -from packaging.version import Version from molecule import api, interpolation, platforms, scenario, state, util from molecule.app import get_app @@ -45,6 +44,8 @@ from collections.abc import MutableMapping from typing import Literal + from packaging.version import Version + from molecule.dependency.base import Base as Dependency from molecule.driver.base import Driver from molecule.state import State @@ -134,20 +135,6 @@ def write(self) -> None: """Write config file to filesystem.""" util.write_file(self.config_file, util.safe_dump(self.config)) - @property - def ansible_collections_path( - self, - ) -> str: - """Return collection path variable for current version of Ansible. - - Returns: - The correct ansible collection path to use. - """ - # https://github.com/ansible/ansible/pull/70007 - if self.runtime.version >= Version("2.10.0.dev0"): - return "ANSIBLE_COLLECTIONS_PATH" - return "ANSIBLE_COLLECTIONS_PATHS" - @property def config_file(self) -> str: """Path to the config file. diff --git a/src/molecule/provisioner/ansible.py b/src/molecule/provisioner/ansible.py index d62217dc5c..111c5933fb 100644 --- a/src/molecule/provisioner/ansible.py +++ b/src/molecule/provisioner/ansible.py @@ -537,7 +537,7 @@ def default_env(self) -> dict[str, str]: { "ANSIBLE_CONFIG": self.config_file, "ANSIBLE_ROLES_PATH": ":".join(roles_path_list), - self._config.ansible_collections_path: ":".join(collections_path_list), + "ANSIBLE_COLLECTIONS_PATH": ":".join(collections_path_list), "ANSIBLE_LIBRARY": ":".join(self._get_modules_directories()), "ANSIBLE_FILTER_PLUGINS": ":".join( self._get_filter_plugins_directories(), diff --git a/tests/fixtures/integration/test_command/scenarios/driver/delegated/meta/main.yml b/tests/fixtures/integration/test_command/scenarios/driver/delegated/meta/main.yml index 5079e25fbb..904dff96c2 100644 --- a/tests/fixtures/integration/test_command/scenarios/driver/delegated/meta/main.yml +++ b/tests/fixtures/integration/test_command/scenarios/driver/delegated/meta/main.yml @@ -7,4 +7,4 @@ galaxy_info: namespace: molecule role_name: delegated_test license: GPL - min_ansible_version: "2.9" + min_ansible_version: "2.15" diff --git a/tests/fixtures/integration/test_command/scenarios/driver/delegated_invalid_role_name_with_role_name_check_equals_to_1/meta/main.yml b/tests/fixtures/integration/test_command/scenarios/driver/delegated_invalid_role_name_with_role_name_check_equals_to_1/meta/main.yml index 04085aed21..1ae1f254db 100644 --- a/tests/fixtures/integration/test_command/scenarios/driver/delegated_invalid_role_name_with_role_name_check_equals_to_1/meta/main.yml +++ b/tests/fixtures/integration/test_command/scenarios/driver/delegated_invalid_role_name_with_role_name_check_equals_to_1/meta/main.yml @@ -8,4 +8,4 @@ galaxy_info: namespace: molecule role_name: delegated-test license: GPL - min_ansible_version: "2.10" + min_ansible_version: "2.15" diff --git a/tests/fixtures/resources/roles/molecule/meta/main.yml b/tests/fixtures/resources/roles/molecule/meta/main.yml index 9ac05cbadf..8c15717fab 100644 --- a/tests/fixtures/resources/roles/molecule/meta/main.yml +++ b/tests/fixtures/resources/roles/molecule/meta/main.yml @@ -3,7 +3,7 @@ galaxy_info: author: Ansible Molecule by Red Hat description: Test Molecule role license: MIT - min_ansible_version: "2.10" + min_ansible_version: "2.15" platforms: - name: GenericLinux versions: diff --git a/tox.ini b/tox.ini index 65daeebad2..305b558406 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] requires = tox>=4.23.2 - tox-uv>=1.16 + tox-uv>=1.20.1 env_list = py deps