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
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:

View file

@ -104,6 +104,7 @@ options:
description:
- The script/command that will be run periodically to check the health of the service.
- Requires O(interval) to be provided.
- Mutually exclusive with O(ttl), O(tcp) and O(http).
interval:
type: str
description:
@ -131,6 +132,7 @@ options:
Similar to the interval this is a number with a V(s) or V(m) suffix to
signify the units of seconds or minutes, for example V(15s) or V(1m).
If no suffix is supplied V(s) will be used by default, for example V(10) will be V(10s).
- Mutually exclusive with O(script), O(tcp) and O(http).
tcp:
type: str
description:
@ -138,6 +140,7 @@ options:
will check if the connection attempt to that port is successful (that is, the port is currently accepting connections).
The format is V(host:port), for example V(localhost:80).
- Requires O(interval) to be provided.
- Mutually exclusive with O(script), O(ttl) and O(http).
version_added: '1.3.0'
http:
type: str
@ -145,6 +148,7 @@ options:
- Checks can be registered with an HTTP endpoint. This means that consul
will check that the http endpoint returns a successful HTTP status.
- Requires O(interval) to be provided.
- Mutually exclusive with O(script), O(ttl) and O(tcp).
timeout:
type: str
description:
@ -159,7 +163,7 @@ options:
ack_params_state_absent:
type: bool
description:
- Disable deprecation warning when using parameters incompatible with O(state=absent).
- This parameter has no more effect and is deprecated. It will be removed in community.general 10.0.0.
'''
EXAMPLES = '''
@ -377,13 +381,7 @@ def get_service_by_id_or_name(consul_api, service_id_or_name):
def parse_check(module):
_checks = [module.params[p] for p in ('script', 'ttl', 'tcp', 'http') if module.params[p]]
if len(_checks) > 1:
module.fail_json(
msg='checks are either script, tcp, http or ttl driven, supplying more than one does not make sense')
if module.params['check_id'] or _checks:
if module.params['check_id'] or any(module.params[p] is not None for p in ('script', 'ttl', 'tcp', 'http')):
return ConsulCheck(
module.params['check_id'],
module.params['check_name'],
@ -501,15 +499,9 @@ class ConsulCheck(object):
self.check = consul.Check.ttl(self.ttl)
if http:
if interval is None:
raise Exception('http check must specify interval')
self.check = consul.Check.http(http, self.interval, self.timeout)
if tcp:
if interval is None:
raise Exception('tcp check must specify interval')
regex = r"(?P<host>.*):(?P<port>(?:[0-9]+))$"
match = re.match(regex, tcp)
@ -596,30 +588,33 @@ def main():
timeout=dict(type='str'),
tags=dict(type='list', elements='str'),
token=dict(no_log=True),
ack_params_state_absent=dict(type='bool'),
ack_params_state_absent=dict(
type='bool',
removed_in_version='10.0.0',
removed_from_collection='community.general',
),
),
mutually_exclusive=[
('script', 'ttl', 'tcp', 'http'),
],
required_if=[
('state', 'present', ['service_name']),
('state', 'absent', ['service_id', 'service_name', 'check_id', 'check_name'], True),
],
required_by={
'script': 'interval',
'http': 'interval',
'tcp': 'interval',
},
supports_check_mode=False,
)
p = module.params
test_dependencies(module)
if p['state'] == 'absent' and any(p[x] for x in ['script', 'ttl', 'tcp', 'http', 'interval']) and not p['ack_params_state_absent']:
module.deprecate(
"The use of parameters 'script', 'ttl', 'tcp', 'http', 'interval' along with 'state=absent' is deprecated. "
"In community.general 8.0.0 their use will become an error. "
"To suppress this deprecation notice, set parameter ack_params_state_absent=true.",
version="8.0.0",
collection_name="community.general",
if p['state'] == 'absent' and any(p[x] for x in ['script', 'ttl', 'tcp', 'http', 'interval']):
module.fail_json(
msg="The use of parameters 'script', 'ttl', 'tcp', 'http', 'interval' along with 'state=absent' is no longer allowed."
)
# When reaching c.g 8.0.0:
# - Replace the deprecation with a fail_json(), remove the "ack_params_state_absent" condition from the "if"
# - Add mutually_exclusive for ('script', 'ttl', 'tcp', 'http'), then remove that validation from parse_check()
# - Add required_by {'script': 'interval', 'http': 'interval', 'tcp': 'interval'}, then remove checks for 'interval' in ConsulCheck.__init__()
# - Deprecate the parameter ack_params_state_absent
try:
register_with_consul(module)

View file

@ -47,9 +47,8 @@ options:
type: str
description:
- The action to take upon the key/value.
- State V(get) is deprecated and will be removed in community.general 8.0.0. Please use the module M(community.general.gconftool2_info) instead.
required: true
choices: [ absent, get, present ]
choices: [ absent, present ]
config_source:
type: str
description:
@ -114,7 +113,7 @@ class GConftool(StateModuleHelper):
key=dict(type='str', required=True, no_log=False),
value_type=dict(type='str', choices=['bool', 'float', 'int', 'string']),
value=dict(type='str'),
state=dict(type='str', required=True, choices=['absent', 'get', 'present']),
state=dict(type='str', required=True, choices=['absent', 'present']),
direct=dict(type='bool', default=False),
config_source=dict(type='str'),
),
@ -149,12 +148,6 @@ class GConftool(StateModuleHelper):
def _get(self):
return self.runner("state key", output_process=self._make_process(False)).run(state="get")
def state_get(self):
self.deprecate(
msg="State 'get' is deprecated. Please use the module community.general.gconftool2_info instead",
version="8.0.0", collection_name="community.general"
)
def state_absent(self):
with self.runner("state key", output_process=self._make_process(False)) as ctx:
ctx.run()

View file

@ -103,9 +103,9 @@ options:
is only applied on updates.
- If set to V(not_protected), runner can pick up jobs from both protected and unprotected branches.
- If set to V(ref_protected), runner can pick up jobs only from protected branches.
- The current default is V(ref_protected). This will change to no default in community.general 8.0.0.
From that version on, if this option is not specified explicitly, GitLab will use V(not_protected)
on creation, and the value set will not be changed on any updates.
- Before community.general 8.0.0 the default was V(ref_protected). This was changed to no default in community.general 8.0.0.
If this option is not specified explicitly, GitLab will use V(not_protected) on creation, and the value set
will not be changed on any updates.
required: false
choices: ["not_protected", "ref_protected"]
type: str
@ -398,15 +398,6 @@ def main():
project = module.params['project']
group = module.params['group']
if access_level is None:
message = "The option 'access_level' is unspecified, so 'ref_protected' is assumed. "\
"In order to align the module with GitLab's runner API, this option will lose "\
"its default value in community.general 8.0.0. From that version on, you must set "\
"this option to 'ref_protected' explicitly, if you want to have a protected runner, "\
"otherwise GitLab's default access level gets applied, which is 'not_protected'"
module.deprecate(message, version='8.0.0', collection_name='community.general')
access_level = 'ref_protected'
gitlab_instance = gitlab_authentication(module)
gitlab_project = None
gitlab_group = None

View file

@ -34,11 +34,7 @@ options:
description:
- V(absent) - policy_profiles should not exist,
- V(present) - policy_profiles should exist,
- >
V(list) - list current policy_profiles and policies.
This state is deprecated and will be removed 8.0.0.
Please use the module M(community.general.manageiq_policies_info) instead.
choices: ['absent', 'present', 'list']
choices: ['absent', 'present']
default: 'present'
policy_profiles:
type: list
@ -133,7 +129,7 @@ from ansible_collections.community.general.plugins.module_utils.manageiq import
def main():
actions = {'present': 'assign', 'absent': 'unassign', 'list': 'list'}
actions = {'present': 'assign', 'absent': 'unassign'}
argument_spec = dict(
policy_profiles=dict(type='list', elements='dict'),
resource_id=dict(type='int'),
@ -141,7 +137,7 @@ def main():
resource_type=dict(required=True, type='str',
choices=list(manageiq_entities().keys())),
state=dict(required=False, type='str',
choices=['present', 'absent', 'list'], default='present'),
choices=['present', 'absent'], default='present'),
)
# add the manageiq connection arguments to the arguments
argument_spec.update(manageiq_argument_spec())
@ -162,13 +158,6 @@ def main():
resource_name = module.params['resource_name']
state = module.params['state']
if state == "list":
module.deprecate(
'The value "list" for "state" is deprecated. Please use community.general.manageiq_policies_info instead.',
version='8.0.0',
collection_name='community.general'
)
# get the action and resource type
action = actions[state]
resource_type = manageiq_entities()[resource_type_key]
@ -176,13 +165,8 @@ def main():
manageiq = ManageIQ(module)
manageiq_policies = manageiq.policies(resource_id, resource_type, resource_name)
if action == 'list':
# return a list of current profiles for this object
current_profiles = manageiq_policies.query_resource_profiles()
res_args = dict(changed=False, profiles=current_profiles)
else:
# assign or unassign the profiles
res_args = manageiq_policies.assign_or_unassign_profiles(policy_profiles, action)
# assign or unassign the profiles
res_args = manageiq_policies.assign_or_unassign_profiles(policy_profiles, action)
module.exit_json(**res_args)

View file

@ -34,11 +34,7 @@ options:
description:
- V(absent) - tags should not exist.
- V(present) - tags should exist.
- >
V(list) - list current tags.
This state is deprecated and will be removed 8.0.0.
Please use the module M(community.general.manageiq_tags_info) instead.
choices: ['absent', 'present', 'list']
choices: ['absent', 'present']
default: 'present'
tags:
type: list
@ -125,7 +121,7 @@ from ansible_collections.community.general.plugins.module_utils.manageiq import
def main():
actions = {'present': 'assign', 'absent': 'unassign', 'list': 'list'}
actions = {'present': 'assign', 'absent': 'unassign'}
argument_spec = dict(
tags=dict(type='list', elements='dict'),
resource_id=dict(type='int'),
@ -133,7 +129,7 @@ def main():
resource_type=dict(required=True, type='str',
choices=list(manageiq_entities().keys())),
state=dict(required=False, type='str',
choices=['present', 'absent', 'list'], default='present'),
choices=['present', 'absent'], default='present'),
)
# add the manageiq connection arguments to the arguments
argument_spec.update(manageiq_argument_spec())
@ -154,13 +150,6 @@ def main():
resource_name = module.params['resource_name']
state = module.params['state']
if state == "list":
module.deprecate(
'The value "list" for "state" is deprecated. Please use community.general.manageiq_tags_info instead.',
version='8.0.0',
collection_name='community.general'
)
# get the action and resource type
action = actions[state]
resource_type = manageiq_entities()[resource_type_key]
@ -173,13 +162,8 @@ def main():
manageiq_tags = ManageIQTags(manageiq, resource_type, resource_id)
if action == 'list':
# return a list of current tags for this object
current_tags = manageiq_tags.query_resource_tags()
res_args = dict(changed=False, tags=current_tags)
else:
# assign or unassign the tags
res_args = manageiq_tags.assign_or_unassign_tags(tags, action)
# assign or unassign the tags
res_args = manageiq_tags.assign_or_unassign_tags(tags, action)
module.exit_json(**res_args)

View file

@ -84,13 +84,6 @@ options:
default: false
aliases: ['array']
version_added: 1.0.0
disable_facts:
description:
- The value V(false) is no longer allowed since community.general 4.0.0.
- This option is deprecated, and will be removed in community.general 8.0.0.
type: bool
default: true
version_added: 2.1.0
'''
EXAMPLES = """
@ -189,11 +182,6 @@ class XFConfProperty(StateModuleHelper):
choices=('string', 'int', 'double', 'bool', 'uint', 'uchar', 'char', 'uint64', 'int64', 'float')),
value=dict(type='list', elements='raw'),
force_array=dict(type='bool', default=False, aliases=['array']),
disable_facts=dict(
type='bool', default=True,
removed_in_version='8.0.0',
removed_from_collection='community.general'
),
),
required_if=[('state', 'present', ['value', 'value_type'])],
required_together=[('value', 'value_type')],
@ -210,9 +198,6 @@ class XFConfProperty(StateModuleHelper):
self.vars.set('type', self.vars.value_type)
self.vars.meta('value').set(initial_value=self.vars.previous_value)
if self.vars.disable_facts is False:
self.do_raise('Returning results as facts has been removed. Stop using disable_facts=false.')
def process_command_output(self, rc, out, err):
if err.rstrip() == self.does_not:
return None