mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
We have had only_if, when_foo, etc, deprecated for a while and said they would be removed in 1.5. Now they are, with friendly error messages still.
Users of these features should use "when:" as documented at docs.ansible.com. Similarly, include + with_items has been removed. The solution is to loop inside the task files, see with_nested / with_together, etc.
This commit is contained in:
@@ -979,12 +979,21 @@ def listify_lookup_plugin_terms(terms, basedir, inject):
|
||||
|
||||
return terms
|
||||
|
||||
def deprecated(msg, version):
|
||||
def deprecated(msg, version, removed=False):
|
||||
''' used to print out a deprecation message.'''
|
||||
if not C.DEPRECATION_WARNINGS:
|
||||
|
||||
if not removed and not C.DEPRECATION_WARNINGS:
|
||||
return
|
||||
new_msg = "\n[DEPRECATION WARNING]: %s. This feature will be removed in version %s." % (msg, version)
|
||||
new_msg = new_msg + " Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.\n\n"
|
||||
|
||||
if not removed:
|
||||
if version:
|
||||
new_msg = "\n[DEPRECATION WARNING]: %s. This feature will be removed in version %s." % (msg, version)
|
||||
else:
|
||||
new_msg = "\n[DEPRECATION WARNING]: %s. This feature will be removed in a future release." % (msg)
|
||||
new_msg = new_msg + " Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.\n\n"
|
||||
else:
|
||||
raise errors.AnsibleError("[DEPRECATED]: %s. Please update your playbooks." % msg)
|
||||
|
||||
wrapped = textwrap.wrap(new_msg, 79)
|
||||
new_msg = "\n".join(wrapped) + "\n"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user