diff --git a/changelogs/fragments/deprecate_include.yml b/changelogs/fragments/deprecate_include.yml new file mode 100644 index 00000000000..36464333c8a --- /dev/null +++ b/changelogs/fragments/deprecate_include.yml @@ -0,0 +1,2 @@ +deprecated_features: + - include action is deprecated in favor of include_tasks, import_tasks and import_playbook. diff --git a/lib/ansible/modules/include.py b/lib/ansible/modules/_include.py similarity index 88% rename from lib/ansible/modules/include.py rename to lib/ansible/modules/_include.py index d9d5d51b155..d9f45aa15ce 100644 --- a/lib/ansible/modules/include.py +++ b/lib/ansible/modules/_include.py @@ -25,6 +25,12 @@ description: directive (which was added in Ansible 2.1) to bypass autodetection. - This module is also supported for Windows targets. version_added: "0.6" +deprecated: + why: it has too many conflicting behaviours depending on keyword combinations and it was unclear how it should behave in each case. + new actions were developed that were specific about each case and related behaviours. + alternative: include_tasks, import_tasks, import_playbook + removed_in: "2.16" + removed_from_collection: 'ansible.builtin' options: free-form: description: diff --git a/lib/ansible/playbook/included_file.py b/lib/ansible/playbook/included_file.py index 36108c07e03..c7ca3a94a23 100644 --- a/lib/ansible/playbook/included_file.py +++ b/lib/ansible/playbook/included_file.py @@ -70,6 +70,9 @@ class IncludedFile: original_task = res._task if original_task.action in C._ACTION_ALL_INCLUDES: + if original_task.action in C._ACTION_INCLUDE: + display.deprecated('"include" is deprecated, use include_tasks/import_tasks/import_playbook instead', "2.16") + if original_task.loop: if 'results' not in res._result: continue diff --git a/test/lib/ansible_test/_data/sanity/validate-modules/validate_modules/main.py b/test/lib/ansible_test/_data/sanity/validate-modules/validate_modules/main.py index 1a75193318d..1e713674faf 100644 --- a/test/lib/ansible_test/_data/sanity/validate-modules/validate_modules/main.py +++ b/test/lib/ansible_test/_data/sanity/validate-modules/validate_modules/main.py @@ -1122,7 +1122,7 @@ class ModuleValidator(Validator): if not (filename_deprecated_or_removed or removed or deprecated or doc_deprecated): mismatched_deprecation = False else: - if (filename_deprecated_or_removed and deprecated and doc_deprecated): + if (filename_deprecated_or_removed and doc_deprecated): mismatched_deprecation = False if (filename_deprecated_or_removed and removed and not (documentation_exists or examples_exist or returns_exist)): mismatched_deprecation = False diff --git a/test/lib/ansible_test/_data/sanity/validate-modules/validate_modules/schema.py b/test/lib/ansible_test/_data/sanity/validate-modules/validate_modules/schema.py index ecf63557f71..fc64c960491 100644 --- a/test/lib/ansible_test/_data/sanity/validate-modules/validate_modules/schema.py +++ b/test/lib/ansible_test/_data/sanity/validate-modules/validate_modules/schema.py @@ -450,8 +450,7 @@ def deprecation_schema(for_collection): # Deprecation cycle changed at 2.4 (though not retroactively) # 2.3 -> removed_in: "2.5" + n for docs stub # 2.4 -> removed_in: "2.8" + n for docs stub - Required('removed_in'): Any( - "2.2", "2.3", "2.4", "2.5", "2.6", "2.8", "2.9", "2.10", "2.11", "2.12", "2.13", "2.14"), + Required('removed_in'): Any("2.12", "2.13", "2.14", "2.15", "2.16"), } version_schema.update(main_fields)