From 73cea82fe7e4def92ca5e1f97dddc3d900898b9b Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Tue, 10 May 2022 15:59:45 +1200 Subject: [PATCH] ansible_galaxy_install: added deprecation for ansible 2.9 and ansible-base 2.10 (#4601) * ansible_galaxy_install: added deprecation for ansible 2.9 and ansible-base 2.10 * added changelog fragment * Update plugins/modules/packaging/language/ansible_galaxy_install.py Co-authored-by: Felix Fontein * Update plugins/modules/packaging/language/ansible_galaxy_install.py Co-authored-by: Felix Fontein * Update plugins/modules/packaging/language/ansible_galaxy_install.py Co-authored-by: Felix Fontein * Update plugins/modules/packaging/language/ansible_galaxy_install.py Co-authored-by: Felix Fontein * ansible29 condition * Update plugins/modules/packaging/language/ansible_galaxy_install.py Co-authored-by: Felix Fontein * Update plugins/modules/packaging/language/ansible_galaxy_install.py Co-authored-by: Felix Fontein * Update plugins/modules/packaging/language/ansible_galaxy_install.py Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- ...y-install-deprecate-ansible29-and-210.yaml | 2 ++ .../language/ansible_galaxy_install.py | 22 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/4601-ansible-galaxy-install-deprecate-ansible29-and-210.yaml diff --git a/changelogs/fragments/4601-ansible-galaxy-install-deprecate-ansible29-and-210.yaml b/changelogs/fragments/4601-ansible-galaxy-install-deprecate-ansible29-and-210.yaml new file mode 100644 index 0000000000..40b67375d6 --- /dev/null +++ b/changelogs/fragments/4601-ansible-galaxy-install-deprecate-ansible29-and-210.yaml @@ -0,0 +1,2 @@ +deprecated_features: + - ansible_galaxy_install - deprecated support for ``ansible`` 2.9 and ``ansible-base`` 2.10 (https://github.com/ansible-collections/community.general/pull/4601). diff --git a/plugins/modules/packaging/language/ansible_galaxy_install.py b/plugins/modules/packaging/language/ansible_galaxy_install.py index 076e2b2d6a..968a8d093d 100644 --- a/plugins/modules/packaging/language/ansible_galaxy_install.py +++ b/plugins/modules/packaging/language/ansible_galaxy_install.py @@ -70,6 +70,17 @@ options: description: - Acknowledge using Ansible 2.9 with its limitations, and prevents the module from generating warnings about them. - This option is completely ignored if using a version of Ansible greater than C(2.9.x). + - Note that this option will be removed without any further deprecation warning once support + for Ansible 2.9 is removed from this module. + type: bool + default: false + ack_min_ansiblecore211: + description: + - Acknowledge the module is deprecating support for Ansible 2.9 and ansible-base 2.10. + - Support for those versions will be removed in community.general 8.0.0. + At the same time, this option will be removed without any deprecation warning! + - This option is completely ignored if using a version of ansible-core/ansible-base/Ansible greater than C(2.11). + - For the sake of conciseness, setting this parameter to C(true) implies I(ack_ansible29=true). type: bool default: false """ @@ -194,6 +205,7 @@ class AnsibleGalaxyInstall(CmdModuleHelper): force=dict(type='bool', default=False), no_deps=dict(type='bool', default=False), ack_ansible29=dict(type='bool', default=False), + ack_min_ansiblecore211=dict(type='bool', default=False), ), mutually_exclusive=[('name', 'requirements_file')], required_one_of=[('name', 'requirements_file')], @@ -226,6 +238,14 @@ class AnsibleGalaxyInstall(CmdModuleHelper): def __init_module__(self): self.ansible_version = self._get_ansible_galaxy_version() + if self.ansible_version < (2, 11) and not self.vars.ack_min_ansiblecore211: + self.module.deprecate( + "Support for Ansible 2.9 and ansible-base 2.10 is being deprecated. " + "At the same time support for them is ended, also the ack_ansible29 option will be removed. " + "Upgrading is strongly recommended, or set 'ack_min_ansiblecore211' to supress this message.", + version="8.0.0", + collection_name="community.general", + ) self.is_ansible29 = self.ansible_version < (2, 10) if self.is_ansible29: self._RE_INSTALL_OUTPUT = re.compile(r"^(?:.*Installing '(?P\w+\.\w+):(?P[\d\.]+)'.*" @@ -281,7 +301,7 @@ class AnsibleGalaxyInstall(CmdModuleHelper): self.vars.set("new_collections", {}) self.vars.set("new_roles", {}) self.vars.set("ansible29_change", False, change=True, output=False) - if not self.vars.ack_ansible29: + if not (self.vars.ack_ansible29 or self.vars.ack_min_ansiblecore211): self.module.warn("Ansible 2.9 or older: unable to retrieve lists of roles and collections already installed") if self.vars.requirements_file is not None and self.vars.type == 'both': self.module.warn("Ansible 2.9 or older: will install only roles from requirement files")