forked from ansible/ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
16 changed files
with
112 additions
and
1,718 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright: (c) 2018, Ansible Project | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import absolute_import, division, print_function | ||
__metaclass__ = type | ||
|
||
ANSIBLE_METADATA = {'metadata_version': '1.1', | ||
'status': ['removed'], | ||
'supported_by': 'community'} | ||
|
||
|
||
from ansible.module_utils.common.removed import removed_module | ||
|
||
|
||
if __name__ == '__main__': | ||
removed_module(removed_in='2.7') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright: (c) 2018, Ansible Project | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import absolute_import, division, print_function | ||
__metaclass__ = type | ||
|
||
ANSIBLE_METADATA = {'metadata_version': '1.1', | ||
'status': ['removed'], | ||
'supported_by': 'community'} | ||
|
||
|
||
from ansible.module_utils.common.removed import removed_module | ||
|
||
|
||
if __name__ == '__main__': | ||
removed_module(removed_in='2.7') |
Oops, something went wrong.