mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 11:21:25 -07:00
Fixup removed and deprecated modules
* 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
This commit is contained in:
parent
8ec973b453
commit
b2932a41b0
16 changed files with 112 additions and 1718 deletions
|
@ -1,20 +1,48 @@
|
|||
# Copyright (c) 2018, Ansible Project
|
||||
# Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause)
|
||||
|
||||
from ansible.module_utils._text import to_text
|
||||
import json
|
||||
import sys
|
||||
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
|
||||
def removed_module(msg=u'This module has been removed. The module documentation may contain hints for porting'):
|
||||
def removed_module(removed_in, msg='This module has been removed. The module documentation for'
|
||||
' Ansible-%(version)s may contain hints for porting'):
|
||||
"""
|
||||
When a module is removed, we want the documentation available for a few releases to aid in
|
||||
porting playbooks. So leave the documentation but remove the actual code and instead have this
|
||||
boilerplate::
|
||||
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()
|
||||
removed_module("2.4")
|
||||
"""
|
||||
# We may not have an AnsibleModule when this is called
|
||||
msg = to_text(msg).translate({ord(u'"'): u'\\"'})
|
||||
print('\n{{"msg": "{0}", "failed": true}}'.format(msg))
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue