mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
b2932a41b0
* Removed modules no longer have documentation Decided this was causing people to think that modules were supported even after being removed. This change is a new strategy to have the error message trying to use a removed module point people to the older documentation. * Add stubs for modules removed in 2.7 These are freshly removed so we want people who are still using them when they upgrade Ansible to have a hint as to where to find information on how to port. * Finish properly undeprecating include include was undeprecated earlier but not all of the pieces that marked it as deprecated were reverted. This change fixes the remaining pieces
48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
# Copyright (c) 2018, Ansible Project
|
|
# Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause)
|
|
|
|
import json
|
|
import sys
|
|
|
|
from ansible.module_utils._text import to_native
|
|
|
|
|
|
def removed_module(removed_in, msg='This module has been removed. The module documentation for'
|
|
' Ansible-%(version)s may contain hints for porting'):
|
|
"""
|
|
Returns module failure along with a message about the module being removed
|
|
|
|
:arg removed_in: The version that the module was removed in
|
|
:kwarg msg: Message to use in the module's failure message. The default says that the module
|
|
has been removed and what version of the Ansible documentation to search for porting help.
|
|
|
|
Remove the actual code and instead have boilerplate like this::
|
|
|
|
from ansible.module_utils.common.removed import removed_module
|
|
|
|
if __name__ == '__main__':
|
|
removed_module("2.4")
|
|
"""
|
|
results = {'failed': True}
|
|
|
|
# Convert numbers into strings
|
|
removed_in = to_native(removed_in)
|
|
|
|
version = removed_in.split('.')
|
|
try:
|
|
numeric_minor = int(version[-1])
|
|
except Exception as e:
|
|
last_version = None
|
|
else:
|
|
version = version[:-1]
|
|
version.append(to_native(numeric_minor - 1))
|
|
last_version = '.'.join(version)
|
|
|
|
if last_version is None:
|
|
results['warnings'] = ['removed modules should specify the version they were removed in']
|
|
results['msg'] = 'This module has been removed'
|
|
else:
|
|
results['msg'] = msg % {'version': last_version}
|
|
|
|
print('\n{0}\n'.format(json.dumps(results)))
|
|
sys.exit(1)
|