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:
Michael DeHaan
2014-01-03 13:46:31 -05:00
parent 5d50bcf6dc
commit 28b9fd4e30
4 changed files with 18 additions and 14 deletions

View File

@@ -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"