Bump version of main to 12.0.0; execute announced deprecations (#10883)

* Bump version to 12.0.0.

* Remove deprecated modules and plugins.

* state is now required.

* Change default of prepend_hash from auto to never.

* Remove support for force=''.

* Always delegate 'debug'.

* Remove ignore_value_none and ctx_ignore_none parameters.

* Remove parameters on_success and on_failure.

* Update BOTMETA.

* Adjust docs reference.

* Forgot required=True.

* Fix changelog fragment.

* Adjust unit tests.

* Fix changelog.

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>

---------

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
Felix Fontein 2025-10-09 13:50:07 +02:00 committed by GitHub
commit 0b72737cab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 43 additions and 901 deletions

View file

@ -15,9 +15,8 @@ from ansible_collections.community.general.plugins.module_utils.mh.deco import m
class ModuleHelperBase(object):
module = None
ModuleHelperException = _MHE
# in 12.0.0 add 'debug' to the tuple
_delegated_to_module = (
'check_mode', 'get_bin_path', 'warn', 'deprecate',
'check_mode', 'get_bin_path', 'warn', 'deprecate', 'debug',
)
def __init__(self, module=None):
@ -29,18 +28,6 @@ class ModuleHelperBase(object):
if not isinstance(self.module, AnsibleModule):
self.module = AnsibleModule(**self.module)
# in 12.0.0 remove this if statement entirely
if hasattr(self, 'debug'):
msg = (
"This class ({cls}) has an attribute 'debug' defined and that is deprecated. "
"Method 'debug' will be an integral part of ModuleHelper in community.general "
"12.0.0, delegated to the underlying AnsibleModule object. "
"Please rename the existing attribute to prevent this message from showing.".format(cls=self.__class__.__name__)
)
self.deprecate(msg, version="12.0.0", collection_name="community.general")
else:
self._delegated_to_module = self._delegated_to_module + ('debug',)
@property
def diff_mode(self):
return self.module._diff

View file

@ -13,22 +13,16 @@ from functools import wraps
from ansible_collections.community.general.plugins.module_utils.mh.exceptions import ModuleHelperException
def cause_changes(on_success=None, on_failure=None, when=None):
# Parameters on_success and on_failure are deprecated and should be removed in community.general 12.0.0
def cause_changes(when=None):
def deco(func):
@wraps(func)
def wrapper(self, *args, **kwargs):
try:
func(self, *args, **kwargs)
if on_success is not None:
self.changed = on_success
elif when == "success":
if when == "success":
self.changed = True
except Exception:
if on_failure is not None:
self.changed = on_failure
elif when == "failure":
if when == "failure":
self.changed = True
raise
finally: