Bump version of main to 8.0.0; remove deprecations, deprecate some leftovers (#7358)

* Remove disable_facts from xfconf module.

* Remove deprecated module_helper CmdMixin and users.

* Deprecate ArgFormat as well, which wasn't explicitly deprecated yet.

* Remove state=get from gconftool2.

* Remove default of access_level in gitlab_runner.

* Remove state=list from manageiq_polices.

* Remove state=list from manageiq_tags.

* Consul: when state=absent, certain options can no longer be specified.

* Remove support for Ansible 2.9 and ansible-base 2.10 from ansible_galaxy_install.

* Bump community.general version to 8.0.0.

* Fix gconftool2 tests.

* Remove mh.mixins.cmd module_utils completely.

* Re-add removed anchor on its first non-removed usage.

* remove references in return doc, refactor method _setup210plus

* remove no longer needed check in function parse_check

* improve expression

* Fix YAML.

* Lint.

---------

Co-authored-by: Alexei Znamensky <russoz@gmail.com>
This commit is contained in:
Felix Fontein 2023-10-09 13:31:27 +02:00 committed by GitHub
parent c7084c6c30
commit 40809ed953
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 88 additions and 514 deletions

View file

@ -17,15 +17,13 @@ version_added: 3.5.0
description:
- This module allows the installation of Ansible collections or roles using C(ansible-galaxy).
notes:
- >
B(Ansible 2.9/2.10): The C(ansible-galaxy) command changed significantly between Ansible 2.9 and
ansible-base 2.10 (later ansible-core 2.11). See comments in the parameters.
- Support for B(Ansible 2.9/2.10) was removed in community.general 8.0.0.
- >
The module will try and run using the C(C.UTF-8) locale.
If that fails, it will try C(en_US.UTF-8).
If that one also fails, the module will fail.
requirements:
- Ansible 2.9, ansible-base 2.10, or ansible-core 2.11 or newer
- ansible-core 2.11 or newer
extends_documentation_fragment:
- community.general.attributes
attributes:
@ -75,24 +73,16 @@ options:
description:
- Force overwriting an existing role or collection.
- Using O(force=true) is mandatory when downgrading.
- "B(Ansible 2.9 and 2.10): Must be V(true) to upgrade roles and collections."
type: bool
default: false
ack_ansible29:
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.
- This option has no longer any effect and will be removed in community.general 9.0.0.
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 V(true) implies O(ack_ansible29=true).
- This option has no longer any effect and will be removed in community.general 9.0.0.
type: bool
default: false
"""
@ -147,7 +137,6 @@ RETURN = """
description:
- If O(requirements_file) is specified instead, returns dictionary with all the roles installed per path.
- If O(name) is specified, returns that role name and the version installed per path.
- "B(Ansible 2.9): Returns empty because C(ansible-galaxy) has no C(list) subcommand."
type: dict
returned: always when installing roles
contains:
@ -164,7 +153,6 @@ RETURN = """
description:
- If O(requirements_file) is specified instead, returns dictionary with all the collections installed per path.
- If O(name) is specified, returns that collection name and the version installed per path.
- "B(Ansible 2.9): Returns empty because C(ansible-galaxy) has no C(list) subcommand."
type: dict
returned: always when installing collections
contains:
@ -206,7 +194,6 @@ class AnsibleGalaxyInstall(ModuleHelper):
_RE_LIST_ROLE = re.compile(r'^- (?P<elem>\w+\.\w+),\s+(?P<version>[\d\.]+)\s*$')
_RE_INSTALL_OUTPUT = None # Set after determining ansible version, see __init_module__()
ansible_version = None
is_ansible29 = None
output_params = ('type', 'name', 'dest', 'requirements_file', 'force', 'no_deps')
module = dict(
@ -217,8 +204,18 @@ class AnsibleGalaxyInstall(ModuleHelper):
dest=dict(type='path'),
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),
ack_ansible29=dict(
type='bool',
default=False,
removed_in_version='9.0.0',
removed_from_collection='community.general',
),
ack_min_ansiblecore211=dict(
type='bool',
default=False,
removed_in_version='9.0.0',
removed_from_collection='community.general',
),
),
mutually_exclusive=[('name', 'requirements_file')],
required_one_of=[('name', 'requirements_file')],
@ -268,26 +265,22 @@ class AnsibleGalaxyInstall(ModuleHelper):
def __init_module__(self):
# self.runner = CmdRunner(self.module, command=self.command, arg_formats=self.command_args_formats, force_lang=self.force_lang)
self.runner, 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 suppress this message.",
version="8.0.0",
collection_name="community.general",
if self.ansible_version < (2, 11):
self.module.fail_json(
msg="Support for Ansible 2.9 and ansible-base 2.10 has ben removed."
)
self.is_ansible29 = self.ansible_version < (2, 10)
if self.is_ansible29:
self._RE_INSTALL_OUTPUT = re.compile(r"^(?:.*Installing '(?P<collection>\w+\.\w+):(?P<cversion>[\d\.]+)'.*"
r'|- (?P<role>\w+\.\w+) \((?P<rversion>[\d\.]+)\)'
r' was installed successfully)$')
else:
# Collection install output changed:
# ansible-base 2.10: "coll.name (x.y.z)"
# ansible-core 2.11+: "coll.name:x.y.z"
self._RE_INSTALL_OUTPUT = re.compile(r'^(?:(?P<collection>\w+\.\w+)(?: \(|:)(?P<cversion>[\d\.]+)\)?'
r'|- (?P<role>\w+\.\w+) \((?P<rversion>[\d\.]+)\))'
r' was installed successfully$')
# Collection install output changed:
# ansible-base 2.10: "coll.name (x.y.z)"
# ansible-core 2.11+: "coll.name:x.y.z"
self._RE_INSTALL_OUTPUT = re.compile(r'^(?:(?P<collection>\w+\.\w+)(?: \(|:)(?P<cversion>[\d\.]+)\)?'
r'|- (?P<role>\w+\.\w+) \((?P<rversion>[\d\.]+)\))'
r' was installed successfully$')
self.vars.set("new_collections", {}, change=True)
self.vars.set("new_roles", {}, change=True)
if self.vars.type != "collection":
self.vars.installed_roles = self._list_roles()
if self.vars.type != "roles":
self.vars.installed_collections = self._list_collections()
def _list_element(self, _type, path_re, elem_re):
def process(rc, out, err):
@ -322,24 +315,8 @@ class AnsibleGalaxyInstall(ModuleHelper):
def _list_roles(self):
return self._list_element('role', self._RE_LIST_PATH, self._RE_LIST_ROLE)
def _setup29(self):
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 or self.vars.ack_min_ansiblecore211):
self.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.warn("Ansible 2.9 or older: will install only roles from requirement files")
def _setup210plus(self):
self.vars.set("new_collections", {}, change=True)
self.vars.set("new_roles", {}, change=True)
if self.vars.type != "collection":
self.vars.installed_roles = self._list_roles()
if self.vars.type != "roles":
self.vars.installed_collections = self._list_collections()
def __run__(self):
def process(rc, out, err):
for line in out.splitlines():
match = self._RE_INSTALL_OUTPUT.match(line)
@ -347,19 +324,9 @@ class AnsibleGalaxyInstall(ModuleHelper):
continue
if match.group("collection"):
self.vars.new_collections[match.group("collection")] = match.group("cversion")
if self.is_ansible29:
self.vars.ansible29_change = True
elif match.group("role"):
self.vars.new_roles[match.group("role")] = match.group("rversion")
if self.is_ansible29:
self.vars.ansible29_change = True
if self.is_ansible29:
if self.vars.type == 'both':
raise ValueError("Type 'both' not supported in Ansible 2.9")
self._setup29()
else:
self._setup210plus()
with self.runner("type galaxy_cmd force no_deps dest requirements_file name", output_process=process) as ctx:
ctx.run(galaxy_cmd="install")
if self.verbosity > 2: