summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJordan Borean <jborean93@gmail.com>2023-05-18 21:49:07 +0200
committerGitHub <noreply@github.com>2023-05-18 21:49:07 +0200
commit8db9bd757444fba6dd23fcb067e261d877926a33 (patch)
tree6409b7bb8ee20d6efe02e77d9d24073684add0d9
parentcommand - Add option to disable argument var expansion (#80512) (diff)
downloadansible-8db9bd757444fba6dd23fcb067e261d877926a33.tar.xz
ansible-8db9bd757444fba6dd23fcb067e261d877926a33.zip
Remove deprecated include (#80752)
* Remove deprecated include * Add tombstone entry for include * Use string for date * Use todays date * Remove uneeded if statement
-rw-r--r--changelogs/fragments/remove-include.yml3
-rw-r--r--lib/ansible/config/ansible_builtin_runtime.yml4
-rw-r--r--lib/ansible/constants.py6
-rw-r--r--lib/ansible/executor/task_executor.py2
-rw-r--r--lib/ansible/modules/_include.py80
-rw-r--r--lib/ansible/playbook/block.py1
-rw-r--r--lib/ansible/playbook/helpers.py18
-rw-r--r--lib/ansible/playbook/included_file.py4
-rw-r--r--lib/ansible/playbook/task_include.py25
-rw-r--r--test/integration/targets/include_when_parent_is_dynamic/tasks.yml2
-rw-r--r--test/integration/targets/include_when_parent_is_static/tasks.yml2
-rw-r--r--test/integration/targets/includes/include_on_playbook_should_fail.yml2
-rw-r--r--test/integration/targets/includes/roles/test_includes/handlers/main.yml2
-rw-r--r--test/integration/targets/includes/roles/test_includes/tasks/main.yml40
-rw-r--r--test/integration/targets/includes/roles/test_includes_free/tasks/main.yml4
-rw-r--r--test/integration/targets/includes/roles/test_includes_host_pinned/tasks/main.yml2
-rwxr-xr-xtest/integration/targets/includes/runme.sh2
-rw-r--r--test/integration/targets/includes/test_includes2.yml4
-rw-r--r--test/integration/targets/includes/test_includes3.yml2
-rw-r--r--test/integration/targets/parsing/roles/test_good_parsing/tasks/main.yml19
-rw-r--r--test/integration/targets/parsing/roles/test_good_parsing/tasks/test_include_conditional.yml2
-rwxr-xr-xtest/integration/targets/var_precedence/ansible-var-precedence-check.py4
-rw-r--r--test/sanity/ignore.txt3
-rw-r--r--test/units/executor/test_play_iterator.py15
-rw-r--r--test/units/parsing/test_dataloader.py4
-rw-r--r--test/units/playbook/test_helpers.py54
-rw-r--r--test/units/playbook/test_included_file.py14
27 files changed, 87 insertions, 233 deletions
diff --git a/changelogs/fragments/remove-include.yml b/changelogs/fragments/remove-include.yml
new file mode 100644
index 0000000000..9caddd8297
--- /dev/null
+++ b/changelogs/fragments/remove-include.yml
@@ -0,0 +1,3 @@
+removed_features:
+- >-
+ Removed ``include`` which has been deprecated in Ansible 2.12. Use ``include_tasks`` or ``import_tasks`` instead.
diff --git a/lib/ansible/config/ansible_builtin_runtime.yml b/lib/ansible/config/ansible_builtin_runtime.yml
index 953b17fbb7..570ccb051c 100644
--- a/lib/ansible/config/ansible_builtin_runtime.yml
+++ b/lib/ansible/config/ansible_builtin_runtime.yml
@@ -9084,6 +9084,10 @@ plugin_routing:
redirect: dellemc.os6.os6
vyos:
redirect: vyos.vyos.vyos
+ include:
+ tombstone:
+ removal_date: "2023-05-16"
+ warning_text: Use include_tasks or import_tasks instead.
become:
doas:
redirect: community.general.doas
diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py
index 8eaadc7018..514357b0bc 100644
--- a/lib/ansible/constants.py
+++ b/lib/ansible/constants.py
@@ -64,7 +64,6 @@ _ACTION_DEBUG = add_internal_fqcns(('debug', ))
_ACTION_IMPORT_PLAYBOOK = add_internal_fqcns(('import_playbook', ))
_ACTION_IMPORT_ROLE = add_internal_fqcns(('import_role', ))
_ACTION_IMPORT_TASKS = add_internal_fqcns(('import_tasks', ))
-_ACTION_INCLUDE = add_internal_fqcns(('include', ))
_ACTION_INCLUDE_ROLE = add_internal_fqcns(('include_role', ))
_ACTION_INCLUDE_TASKS = add_internal_fqcns(('include_tasks', ))
_ACTION_INCLUDE_VARS = add_internal_fqcns(('include_vars', ))
@@ -74,12 +73,11 @@ _ACTION_SET_FACT = add_internal_fqcns(('set_fact', ))
_ACTION_SETUP = add_internal_fqcns(('setup', ))
_ACTION_HAS_CMD = add_internal_fqcns(('command', 'shell', 'script'))
_ACTION_ALLOWS_RAW_ARGS = _ACTION_HAS_CMD + add_internal_fqcns(('raw', ))
-_ACTION_ALL_INCLUDES = _ACTION_INCLUDE + _ACTION_INCLUDE_TASKS + _ACTION_INCLUDE_ROLE
-_ACTION_ALL_INCLUDE_IMPORT_TASKS = _ACTION_INCLUDE + _ACTION_INCLUDE_TASKS + _ACTION_IMPORT_TASKS
+_ACTION_ALL_INCLUDES = _ACTION_INCLUDE_TASKS + _ACTION_INCLUDE_ROLE
+_ACTION_ALL_INCLUDE_IMPORT_TASKS = _ACTION_INCLUDE_TASKS + _ACTION_IMPORT_TASKS
_ACTION_ALL_PROPER_INCLUDE_IMPORT_ROLES = _ACTION_INCLUDE_ROLE + _ACTION_IMPORT_ROLE
_ACTION_ALL_PROPER_INCLUDE_IMPORT_TASKS = _ACTION_INCLUDE_TASKS + _ACTION_IMPORT_TASKS
_ACTION_ALL_INCLUDE_ROLE_TASKS = _ACTION_INCLUDE_ROLE + _ACTION_INCLUDE_TASKS
-_ACTION_ALL_INCLUDE_TASKS = _ACTION_INCLUDE + _ACTION_INCLUDE_TASKS
_ACTION_FACT_GATHERING = _ACTION_SETUP + add_internal_fqcns(('gather_facts', ))
_ACTION_WITH_CLEAN_FACTS = _ACTION_SET_FACT + _ACTION_INCLUDE_VARS
diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py
index a0e9c110a8..dc0632ecab 100644
--- a/lib/ansible/executor/task_executor.py
+++ b/lib/ansible/executor/task_executor.py
@@ -514,7 +514,7 @@ class TaskExecutor:
# if this task is a TaskInclude, we just return now with a success code so the
# main thread can expand the task list for the given host
- if self._task.action in C._ACTION_ALL_INCLUDE_TASKS:
+ if self._task.action in C._ACTION_INCLUDE_TASKS:
include_args = self._task.args.copy()
include_file = include_args.pop('_raw_params', None)
if not include_file:
diff --git a/lib/ansible/modules/_include.py b/lib/ansible/modules/_include.py
deleted file mode 100644
index 60deb9476c..0000000000
--- a/lib/ansible/modules/_include.py
+++ /dev/null
@@ -1,80 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Copyright: 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
-
-
-DOCUMENTATION = r'''
----
-author: Ansible Core Team (@ansible)
-module: include
-short_description: Include a task list
-description:
- - Includes a file with a list of tasks to be executed in the current playbook.
- - Lists of tasks can only be included where tasks
- normally run (in play).
- - Before Ansible 2.0, all includes were 'static' and were executed when the play was compiled.
- - Static includes are not subject to most directives. For example, loops or conditionals are applied instead to each
- inherited task.
- - Since Ansible 2.0, task includes are dynamic and behave more like real tasks. This means they can be looped,
- skipped and use variables from any source. Ansible tries to auto detect this, but you can use the C(static)
- 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:
- - This module allows you to specify the name of the file directly without any other options.
-notes:
- - This is a core feature of Ansible, rather than a module, and cannot be overridden like a module.
- - Include has some unintuitive behaviours depending on if it is running in a static or dynamic in play or in playbook context,
- in an effort to clarify behaviours we are moving to a new set modules (M(ansible.builtin.include_tasks),
- M(ansible.builtin.include_role), M(ansible.builtin.import_playbook), M(ansible.builtin.import_tasks))
- that have well established and clear behaviours.
- - This module no longer supporst including plays. Use M(ansible.builtin.import_playbook) instead.
-seealso:
-- module: ansible.builtin.import_playbook
-- module: ansible.builtin.import_role
-- module: ansible.builtin.import_tasks
-- module: ansible.builtin.include_role
-- module: ansible.builtin.include_tasks
-- ref: playbooks_reuse_includes
- description: More information related to including and importing playbooks, roles and tasks.
-'''
-
-EXAMPLES = r'''
-
-- hosts: all
- tasks:
- - ansible.builtin.debug:
- msg: task1
-
- - name: Include task list in play
- ansible.builtin.include: stuff.yaml
-
- - ansible.builtin.debug:
- msg: task10
-
-- hosts: all
- tasks:
- - ansible.builtin.debug:
- msg: task1
-
- - name: Include task list in play only if the condition is true
- ansible.builtin.include: "{{ hostvar }}.yaml"
- static: no
- when: hostvar is defined
-'''
-
-RETURN = r'''
-# This module does not return anything except tasks to execute.
-'''
diff --git a/lib/ansible/playbook/block.py b/lib/ansible/playbook/block.py
index 109b3aa37c..e585fb7de9 100644
--- a/lib/ansible/playbook/block.py
+++ b/lib/ansible/playbook/block.py
@@ -377,7 +377,6 @@ class Block(Base, Conditional, CollectionSearch, Taggable, Notifiable, Delegatab
if filtered_block.has_tasks():
tmp_list.append(filtered_block)
elif ((task.action in C._ACTION_META and task.implicit) or
- (task.action in C._ACTION_INCLUDE and task.evaluate_tags([], self._play.skip_tags, all_vars=all_vars)) or
task.evaluate_tags(self._play.only_tags, self._play.skip_tags, all_vars=all_vars)):
tmp_list.append(task)
return tmp_list
diff --git a/lib/ansible/playbook/helpers.py b/lib/ansible/playbook/helpers.py
index 1c44448a5f..6baab37aad 100644
--- a/lib/ansible/playbook/helpers.py
+++ b/lib/ansible/playbook/helpers.py
@@ -150,23 +150,9 @@ def load_list_of_tasks(ds, play, block=None, role=None, task_include=None, use_h
templar = Templar(loader=loader, variables=all_vars)
# check to see if this include is dynamic or static:
- # 1. the user has set the 'static' option to false or true
- # 2. one of the appropriate config options was set
- if action in C._ACTION_INCLUDE_TASKS:
- is_static = False
- elif action in C._ACTION_IMPORT_TASKS:
- is_static = True
- else:
- include_link = get_versioned_doclink('user_guide/playbooks_reuse_includes.html')
- display.deprecated('"include" is deprecated, use include_tasks/import_tasks instead. See %s for details' % include_link, "2.16")
- is_static = not templar.is_template(t.args['_raw_params']) and t.all_parents_static() and not t.loop
-
- if is_static:
+ if action in C._ACTION_IMPORT_TASKS:
if t.loop is not None:
- if action in C._ACTION_IMPORT_TASKS:
- raise AnsibleParserError("You cannot use loops on 'import_tasks' statements. You should use 'include_tasks' instead.", obj=task_ds)
- else:
- raise AnsibleParserError("You cannot use 'static' on an include with a loop", obj=task_ds)
+ raise AnsibleParserError("You cannot use loops on 'import_tasks' statements. You should use 'include_tasks' instead.", obj=task_ds)
# we set a flag to indicate this include was static
t.statically_loaded = True
diff --git a/lib/ansible/playbook/included_file.py b/lib/ansible/playbook/included_file.py
index c1e815b1ad..25ee28b2cc 100644
--- a/lib/ansible/playbook/included_file.py
+++ b/lib/ansible/playbook/included_file.py
@@ -72,8 +72,6 @@ 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:
@@ -118,7 +116,7 @@ class IncludedFile:
templar = Templar(loader=loader, variables=task_vars)
- if original_task.action in C._ACTION_ALL_INCLUDE_TASKS:
+ if original_task.action in C._ACTION_INCLUDE_TASKS:
include_file = None
if original_task._parent:
diff --git a/lib/ansible/playbook/task_include.py b/lib/ansible/playbook/task_include.py
index 9c335c6e07..fc0988987a 100644
--- a/lib/ansible/playbook/task_include.py
+++ b/lib/ansible/playbook/task_include.py
@@ -35,7 +35,7 @@ class TaskInclude(Task):
"""
A task include is derived from a regular task to handle the special
- circumstances related to the `- include: ...` task.
+ circumstances related to the `- include_*: ...` task.
"""
BASE = frozenset(('file', '_raw_params')) # directly assigned
@@ -105,29 +105,6 @@ class TaskInclude(Task):
new_me.statically_loaded = self.statically_loaded
return new_me
- def get_vars(self):
- '''
- We override the parent Task() classes get_vars here because
- we need to include the args of the include into the vars as
- they are params to the included tasks. But ONLY for 'include'
- '''
- if self.action not in C._ACTION_INCLUDE:
- all_vars = super(TaskInclude, self).get_vars()
- else:
- all_vars = dict()
- if self._parent:
- all_vars |= self._parent.get_vars()
-
- all_vars |= self.vars
- all_vars |= self.args
-
- if 'tags' in all_vars:
- del all_vars['tags']
- if 'when' in all_vars:
- del all_vars['when']
-
- return all_vars
-
def build_parent_block(self):
'''
This method is used to create the parent block for the included tasks
diff --git a/test/integration/targets/include_when_parent_is_dynamic/tasks.yml b/test/integration/targets/include_when_parent_is_dynamic/tasks.yml
index 6831245c92..d500f0df7d 100644
--- a/test/integration/targets/include_when_parent_is_dynamic/tasks.yml
+++ b/test/integration/targets/include_when_parent_is_dynamic/tasks.yml
@@ -9,4 +9,4 @@
# perform an include task which should be static if all of the task's parents are static, otherwise it should be dynamic
# this file was loaded using include_tasks, which is dynamic, so this include should also be dynamic
-- include: syntax_error.yml
+- include_tasks: syntax_error.yml
diff --git a/test/integration/targets/include_when_parent_is_static/tasks.yml b/test/integration/targets/include_when_parent_is_static/tasks.yml
index a234a3dd33..50dd2341c1 100644
--- a/test/integration/targets/include_when_parent_is_static/tasks.yml
+++ b/test/integration/targets/include_when_parent_is_static/tasks.yml
@@ -9,4 +9,4 @@
# perform an include task which should be static if all of the task's parents are static, otherwise it should be dynamic
# this file was loaded using import_tasks, which is static, so this include should also be static
-- include: syntax_error.yml
+- import_tasks: syntax_error.yml
diff --git a/test/integration/targets/includes/include_on_playbook_should_fail.yml b/test/integration/targets/includes/include_on_playbook_should_fail.yml
index 953459dcf8..c9b1e81ac3 100644
--- a/test/integration/targets/includes/include_on_playbook_should_fail.yml
+++ b/test/integration/targets/includes/include_on_playbook_should_fail.yml
@@ -1 +1 @@
-- include: test_includes3.yml
+- include_tasks: test_includes3.yml
diff --git a/test/integration/targets/includes/roles/test_includes/handlers/main.yml b/test/integration/targets/includes/roles/test_includes/handlers/main.yml
index 7d3e625f7f..453fa96d7f 100644
--- a/test/integration/targets/includes/roles/test_includes/handlers/main.yml
+++ b/test/integration/targets/includes/roles/test_includes/handlers/main.yml
@@ -1 +1 @@
-- include: more_handlers.yml
+- import_tasks: more_handlers.yml
diff --git a/test/integration/targets/includes/roles/test_includes/tasks/main.yml b/test/integration/targets/includes/roles/test_includes/tasks/main.yml
index 83ca468baf..2ba1ae637a 100644
--- a/test/integration/targets/includes/roles/test_includes/tasks/main.yml
+++ b/test/integration/targets/includes/roles/test_includes/tasks/main.yml
@@ -17,47 +17,9 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-- include: included_task1.yml a=1 b=2 c=3
-
-- name: verify non-variable include params
- assert:
- that:
- - "ca == '1'"
- - "cb == '2'"
- - "cc == '3'"
-
-- set_fact:
- a: 101
- b: 102
- c: 103
-
-- include: included_task1.yml a={{a}} b={{b}} c=103
-
-- name: verify variable include params
- assert:
- that:
- - "ca == 101"
- - "cb == 102"
- - "cc == 103"
-
-# Test that strings are not turned into numbers
-- set_fact:
- a: "101"
- b: "102"
- c: "103"
-
-- include: included_task1.yml a={{a}} b={{b}} c=103
-
-- name: verify variable include params
- assert:
- that:
- - "ca == '101'"
- - "cb == '102'"
- - "cc == '103'"
-
# now try long form includes
-- include: included_task1.yml
+- include_tasks: included_task1.yml
vars:
a: 201
b: 202
diff --git a/test/integration/targets/includes/roles/test_includes_free/tasks/main.yml b/test/integration/targets/includes/roles/test_includes_free/tasks/main.yml
index 5ae7882f4c..d7bcf8eb5b 100644
--- a/test/integration/targets/includes/roles/test_includes_free/tasks/main.yml
+++ b/test/integration/targets/includes/roles/test_includes_free/tasks/main.yml
@@ -1,9 +1,9 @@
- name: this needs to be here
debug:
msg: "hello"
-- include: inner.yml
+- include_tasks: inner.yml
with_items:
- '1'
-- ansible.builtin.include: inner_fqcn.yml
+- ansible.builtin.include_tasks: inner_fqcn.yml
with_items:
- '1'
diff --git a/test/integration/targets/includes/roles/test_includes_host_pinned/tasks/main.yml b/test/integration/targets/includes/roles/test_includes_host_pinned/tasks/main.yml
index 7bc19faae1..c06d3febd9 100644
--- a/test/integration/targets/includes/roles/test_includes_host_pinned/tasks/main.yml
+++ b/test/integration/targets/includes/roles/test_includes_host_pinned/tasks/main.yml
@@ -1,6 +1,6 @@
- name: this needs to be here
debug:
msg: "hello"
-- include: inner.yml
+- include_tasks: inner.yml
with_items:
- '1'
diff --git a/test/integration/targets/includes/runme.sh b/test/integration/targets/includes/runme.sh
index e619feaf2a..8622cf6653 100755
--- a/test/integration/targets/includes/runme.sh
+++ b/test/integration/targets/includes/runme.sh
@@ -10,7 +10,7 @@ echo "EXPECTED ERROR: Ensure we fail if using 'include' to include a playbook."
set +e
result="$(ansible-playbook -i ../../inventory include_on_playbook_should_fail.yml -v "$@" 2>&1)"
set -e
-grep -q "ERROR! 'include' is not a valid attribute for a Play" <<< "$result"
+grep -q "ERROR! 'include_tasks' is not a valid attribute for a Play" <<< "$result"
ansible-playbook includes_loop_rescue.yml --extra-vars strategy=linear "$@"
ansible-playbook includes_loop_rescue.yml --extra-vars strategy=free "$@"
diff --git a/test/integration/targets/includes/test_includes2.yml b/test/integration/targets/includes/test_includes2.yml
index a32e851384..da6b914fee 100644
--- a/test/integration/targets/includes/test_includes2.yml
+++ b/test/integration/targets/includes/test_includes2.yml
@@ -13,8 +13,8 @@
- role: test_includes
tags: test_includes
tasks:
- - include: roles/test_includes/tasks/not_a_role_task.yml
- - include: roles/test_includes/tasks/empty.yml
+ - include_tasks: roles/test_includes/tasks/not_a_role_task.yml
+ - include_tasks: roles/test_includes/tasks/empty.yml
- assert:
that:
- "ca == 33000"
diff --git a/test/integration/targets/includes/test_includes3.yml b/test/integration/targets/includes/test_includes3.yml
index 0b4c631210..f3c4964ee8 100644
--- a/test/integration/targets/includes/test_includes3.yml
+++ b/test/integration/targets/includes/test_includes3.yml
@@ -1,6 +1,6 @@
- hosts: testhost
tasks:
- - include: test_includes4.yml
+ - include_tasks: test_includes4.yml
with_items: ["a"]
loop_control:
loop_var: r
diff --git a/test/integration/targets/parsing/roles/test_good_parsing/tasks/main.yml b/test/integration/targets/parsing/roles/test_good_parsing/tasks/main.yml
index d225c0f9f9..25e91f289f 100644
--- a/test/integration/targets/parsing/roles/test_good_parsing/tasks/main.yml
+++ b/test/integration/targets/parsing/roles/test_good_parsing/tasks/main.yml
@@ -121,7 +121,10 @@
- result.cmd == "echo foo --arg=a --arg=b"
- name: test includes with params
- include: test_include.yml fact_name=include_params param="{{ test_input }}"
+ include_tasks: test_include.yml
+ vars:
+ fact_name: include_params
+ param: "{{ test_input }}"
- name: assert the include set the correct fact for the param
assert:
@@ -129,7 +132,10 @@
- include_params == test_input
- name: test includes with quoted params
- include: test_include.yml fact_name=double_quoted_param param="this is a param with double quotes"
+ include_tasks: test_include.yml
+ vars:
+ fact_name: double_quoted_param
+ param: "this is a param with double quotes"
- name: assert the include set the correct fact for the double quoted param
assert:
@@ -137,7 +143,10 @@
- double_quoted_param == "this is a param with double quotes"
- name: test includes with single quoted params
- include: test_include.yml fact_name=single_quoted_param param='this is a param with single quotes'
+ include_tasks: test_include.yml
+ vars:
+ fact_name: single_quoted_param
+ param: 'this is a param with single quotes'
- name: assert the include set the correct fact for the single quoted param
assert:
@@ -145,7 +154,7 @@
- single_quoted_param == "this is a param with single quotes"
- name: test includes with quoted params in complex args
- include: test_include.yml
+ include_tasks: test_include.yml
vars:
fact_name: complex_param
param: "this is a param in a complex arg with double quotes"
@@ -165,7 +174,7 @@
- result.msg == "this should be debugged"
- name: test conditional includes
- include: test_include_conditional.yml
+ include_tasks: test_include_conditional.yml
when: false
- name: assert the nested include from test_include_conditional was not set
diff --git a/test/integration/targets/parsing/roles/test_good_parsing/tasks/test_include_conditional.yml b/test/integration/targets/parsing/roles/test_good_parsing/tasks/test_include_conditional.yml
index 070888dad3..a1d8b7ce8a 100644
--- a/test/integration/targets/parsing/roles/test_good_parsing/tasks/test_include_conditional.yml
+++ b/test/integration/targets/parsing/roles/test_good_parsing/tasks/test_include_conditional.yml
@@ -1 +1 @@
-- include: test_include_nested.yml
+- include_tasks: test_include_nested.yml
diff --git a/test/integration/targets/var_precedence/ansible-var-precedence-check.py b/test/integration/targets/var_precedence/ansible-var-precedence-check.py
index a6c1dab0f6..b03c87b80f 100755
--- a/test/integration/targets/var_precedence/ansible-var-precedence-check.py
+++ b/test/integration/targets/var_precedence/ansible-var-precedence-check.py
@@ -363,9 +363,9 @@ class VarTestMaker(object):
block_wrapper = [debug_task, test_task]
if 'include_params' in self.features:
- self.tasks.append(dict(name='including tasks', include='included_tasks.yml', vars=dict(findme='include_params')))
+ self.tasks.append(dict(name='including tasks', include_tasks='included_tasks.yml', vars=dict(findme='include_params')))
else:
- self.tasks.append(dict(include='included_tasks.yml'))
+ self.tasks.append(dict(include_tasks='included_tasks.yml'))
fname = os.path.join(TESTDIR, 'included_tasks.yml')
with open(fname, 'w') as f:
diff --git a/test/sanity/ignore.txt b/test/sanity/ignore.txt
index 63a31a2ba1..8cbfa1dd7a 100644
--- a/test/sanity/ignore.txt
+++ b/test/sanity/ignore.txt
@@ -21,7 +21,6 @@ lib/ansible/parsing/yaml/constructor.py mypy-3.9:type-var # too many occurrence
lib/ansible/parsing/yaml/constructor.py mypy-3.10:type-var # too many occurrences to ignore inline
lib/ansible/parsing/yaml/constructor.py mypy-3.11:type-var # too many occurrences to ignore inline
lib/ansible/keyword_desc.yml no-unwanted-files
-lib/ansible/modules/_include.py validate-modules:ansible-deprecated-module
lib/ansible/modules/apt.py validate-modules:parameter-invalid
lib/ansible/modules/apt_repository.py validate-modules:parameter-invalid
lib/ansible/modules/assemble.py validate-modules:nonexistent-parameter-documented
@@ -242,5 +241,3 @@ test/units/utils/collection_loader/fixtures/collections_masked/ansible_collectio
test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/testns/__init__.py empty-init # testing that collections don't need inits
test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/testns/testcoll/__init__.py empty-init # testing that collections don't need inits
test/units/utils/collection_loader/test_collection_loader.py pylint:undefined-variable # magic runtime local var splatting
-lib/ansible/playbook/helpers.py pylint:ansible-deprecated-version
-lib/ansible/playbook/included_file.py pylint:ansible-deprecated-version
diff --git a/test/units/executor/test_play_iterator.py b/test/units/executor/test_play_iterator.py
index 23301da0ef..d08cfda16c 100644
--- a/test/units/executor/test_play_iterator.py
+++ b/test/units/executor/test_play_iterator.py
@@ -86,7 +86,8 @@ class TestPlayIterator(unittest.TestCase):
always:
- name: role always task
debug: msg="always task in block in role"
- - include: foo.yml
+ - name: role include_tasks
+ include_tasks: foo.yml
- name: role task after include
debug: msg="after include in role"
- block:
@@ -171,12 +172,12 @@ class TestPlayIterator(unittest.TestCase):
self.assertIsNotNone(task)
self.assertEqual(task.name, "role always task")
self.assertIsNotNone(task._role)
- # role include task
- # (host_state, task) = itr.get_next_task_for_host(hosts[0])
- # self.assertIsNotNone(task)
- # self.assertEqual(task.action, 'debug')
- # self.assertEqual(task.name, "role included task")
- # self.assertIsNotNone(task._role)
+ # role include_tasks
+ (host_state, task) = itr.get_next_task_for_host(hosts[0])
+ self.assertIsNotNone(task)
+ self.assertEqual(task.action, 'include_tasks')
+ self.assertEqual(task.name, "role include_tasks")
+ self.assertIsNotNone(task._role)
# role task after include
(host_state, task) = itr.get_next_task_for_host(hosts[0])
self.assertIsNotNone(task)
diff --git a/test/units/parsing/test_dataloader.py b/test/units/parsing/test_dataloader.py
index f60d33ab69..e3a26716a4 100644
--- a/test/units/parsing/test_dataloader.py
+++ b/test/units/parsing/test_dataloader.py
@@ -92,11 +92,11 @@ class TestDataLoader(unittest.TestCase):
- { role: 'testrole' }
testrole/tasks/main.yml:
- - include: "include1.yml"
+ - include_tasks: "include1.yml"
static: no
testrole/tasks/include1.yml:
- - include: include2.yml
+ - include_tasks: include2.yml
static: no
testrole/tasks/include2.yml:
diff --git a/test/units/playbook/test_helpers.py b/test/units/playbook/test_helpers.py
index 03a9062849..23385c00ef 100644
--- a/test/units/playbook/test_helpers.py
+++ b/test/units/playbook/test_helpers.py
@@ -65,11 +65,11 @@ class MixinForMocks(object):
self._test_data_path = os.path.dirname(__file__)
self.fake_include_loader = DictDataLoader({"/dev/null/includes/test_include.yml": """
- - include: other_test_include.yml
+ - include_tasks: other_test_include.yml
- shell: echo 'hello world'
""",
"/dev/null/includes/static_test_include.yml": """
- - include: other_test_include.yml
+ - include_tasks: other_test_include.yml
- shell: echo 'hello static world'
""",
"/dev/null/includes/other_test_include.yml": """
@@ -160,57 +160,57 @@ class TestLoadListOfTasks(unittest.TestCase, MixinForMocks):
ds, play=self.mock_play, use_handlers=True,
variable_manager=self.mock_variable_manager, loader=self.fake_loader)
- def test_one_bogus_include(self):
- ds = [{'include': 'somefile.yml'}]
+ def test_one_bogus_include_tasks(self):
+ ds = [{'include_tasks': 'somefile.yml'}]
res = helpers.load_list_of_tasks(ds, play=self.mock_play,
variable_manager=self.mock_variable_manager, loader=self.fake_loader)
self.assertIsInstance(res, list)
- self.assertEqual(len(res), 0)
+ self.assertEqual(len(res), 1)
+ self.assertIsInstance(res[0], TaskInclude)
- def test_one_bogus_include_use_handlers(self):
- ds = [{'include': 'somefile.yml'}]
+ def test_one_bogus_include_tasks_use_handlers(self):
+ ds = [{'include_tasks': 'somefile.yml'}]
res = helpers.load_list_of_tasks(ds, play=self.mock_play, use_handlers=True,
variable_manager=self.mock_variable_manager, loader=self.fake_loader)
self.assertIsInstance(res, list)
- self.assertEqual(len(res), 0)
+ self.assertEqual(len(res), 1)
+ self.assertIsInstance(res[0], TaskInclude)
- def test_one_bogus_include_static(self):
+ def test_one_bogus_import_tasks(self):
ds = [{'import_tasks': 'somefile.yml'}]
res = helpers.load_list_of_tasks(ds, play=self.mock_play,
variable_manager=self.mock_variable_manager, loader=self.fake_loader)
self.assertIsInstance(res, list)
self.assertEqual(len(res), 0)
- def test_one_include(self):
- ds = [{'include': '/dev/null/includes/other_test_include.yml'}]
+ def test_one_include_tasks(self):
+ ds = [{'include_tasks': '/dev/null/includes/other_test_include.yml'}]
res = helpers.load_list_of_tasks(ds, play=self.mock_play,
variable_manager=self.mock_variable_manager, loader=self.fake_include_loader)
self.assertEqual(len(res), 1)
self._assert_is_task_list_or_blocks(res)
- def test_one_parent_include(self):
- ds = [{'include': '/dev/null/includes/test_include.yml'}]
+ def test_one_parent_include_tasks(self):
+ ds = [{'include_tasks': '/dev/null/includes/test_include.yml'}]
res = helpers.load_list_of_tasks(ds, play=self.mock_play,
variable_manager=self.mock_variable_manager, loader=self.fake_include_loader)
self._assert_is_task_list_or_blocks(res)
- self.assertIsInstance(res[0], Block)
- self.assertIsInstance(res[0]._parent, TaskInclude)
+ self.assertIsInstance(res[0], TaskInclude)
+ self.assertIsNone(res[0]._parent)
- # TODO/FIXME: do this non deprecated way
- def test_one_include_tags(self):
- ds = [{'include': '/dev/null/includes/other_test_include.yml',
+ def test_one_include_tasks_tags(self):
+ ds = [{'include_tasks': '/dev/null/includes/other_test_include.yml',
'tags': ['test_one_include_tags_tag1', 'and_another_tagB']
}]
res = helpers.load_list_of_tasks(ds, play=self.mock_play,
variable_manager=self.mock_variable_manager, loader=self.fake_include_loader)
self._assert_is_task_list_or_blocks(res)
- self.assertIsInstance(res[0], Block)
+ self.assertIsInstance(res[0], TaskInclude)
self.assertIn('test_one_include_tags_tag1', res[0].tags)
self.assertIn('and_another_tagB', res[0].tags)
- # TODO/FIXME: do this non deprecated way
- def test_one_parent_include_tags(self):
- ds = [{'include': '/dev/null/includes/test_include.yml',
+ def test_one_parent_include_tasks_tags(self):
+ ds = [{'include_tasks': '/dev/null/includes/test_include.yml',
# 'vars': {'tags': ['test_one_parent_include_tags_tag1', 'and_another_tag2']}
'tags': ['test_one_parent_include_tags_tag1', 'and_another_tag2']
}
@@ -218,20 +218,20 @@ class TestLoadListOfTasks(unittest.TestCase, MixinForMocks):
res = helpers.load_list_of_tasks(ds, play=self.mock_play,
variable_manager=self.mock_variable_manager, loader=self.fake_include_loader)
self._assert_is_task_list_or_blocks(res)
- self.assertIsInstance(res[0], Block)
+ self.assertIsInstance(res[0], TaskInclude)
self.assertIn('test_one_parent_include_tags_tag1', res[0].tags)
self.assertIn('and_another_tag2', res[0].tags)
- def test_one_include_use_handlers(self):
- ds = [{'include': '/dev/null/includes/other_test_include.yml'}]
+ def test_one_include_tasks_use_handlers(self):
+ ds = [{'include_tasks': '/dev/null/includes/other_test_include.yml'}]
res = helpers.load_list_of_tasks(ds, play=self.mock_play,
use_handlers=True,
variable_manager=self.mock_variable_manager, loader=self.fake_include_loader)
self._assert_is_task_list_or_blocks(res)
self.assertIsInstance(res[0], Handler)
- def test_one_parent_include_use_handlers(self):
- ds = [{'include': '/dev/null/includes/test_include.yml'}]
+ def test_one_parent_include_tasks_use_handlers(self):
+ ds = [{'include_tasks': '/dev/null/includes/test_include.yml'}]
res = helpers.load_list_of_tasks(ds, play=self.mock_play,
use_handlers=True,
variable_manager=self.mock_variable_manager, loader=self.fake_include_loader)
diff --git a/test/units/playbook/test_included_file.py b/test/units/playbook/test_included_file.py
index 7341dffa6b..c7a66b06dc 100644
--- a/test/units/playbook/test_included_file.py
+++ b/test/units/playbook/test_included_file.py
@@ -105,7 +105,7 @@ def test_included_file_instantiation():
assert inc_file._task is None
-def test_process_include_results(mock_iterator, mock_variable_manager):
+def test_process_include_tasks_results(mock_iterator, mock_variable_manager):
hostname = "testhost1"
hostname2 = "testhost2"
@@ -113,7 +113,7 @@ def test_process_include_results(mock_iterator, mock_variable_manager):
parent_task = Task.load(parent_task_ds)
parent_task._play = None
- task_ds = {'include': 'include_test.yml'}
+ task_ds = {'include_tasks': 'include_test.yml'}
loaded_task = TaskInclude.load(task_ds, task_include=parent_task)
return_data = {'include': 'include_test.yml'}
@@ -133,7 +133,7 @@ def test_process_include_results(mock_iterator, mock_variable_manager):
assert res[0]._vars == {}
-def test_process_include_diff_files(mock_iterator, mock_variable_manager):
+def test_process_include_tasks_diff_files(mock_iterator, mock_variable_manager):
hostname = "testhost1"
hostname2 = "testhost2"
@@ -141,11 +141,11 @@ def test_process_include_diff_files(mock_iterator, mock_variable_manager):
parent_task = Task.load(parent_task_ds)
parent_task._play = None
- task_ds = {'include': 'include_test.yml'}
+ task_ds = {'include_tasks': 'include_test.yml'}
loaded_task = TaskInclude.load(task_ds, task_include=parent_task)
loaded_task._play = None
- child_task_ds = {'include': 'other_include_test.yml'}
+ child_task_ds = {'include_tasks': 'other_include_test.yml'}
loaded_child_task = TaskInclude.load(child_task_ds, task_include=loaded_task)
loaded_child_task._play = None
@@ -175,7 +175,7 @@ def test_process_include_diff_files(mock_iterator, mock_variable_manager):
assert res[1]._vars == {}
-def test_process_include_simulate_free(mock_iterator, mock_variable_manager):
+def test_process_include_tasks_simulate_free(mock_iterator, mock_variable_manager):
hostname = "testhost1"
hostname2 = "testhost2"
@@ -186,7 +186,7 @@ def test_process_include_simulate_free(mock_iterator, mock_variable_manager):
parent_task1._play = None
parent_task2._play = None
- task_ds = {'include': 'include_test.yml'}
+ task_ds = {'include_tasks': 'include_test.yml'}
loaded_task1 = TaskInclude.load(task_ds, task_include=parent_task1)
loaded_task2 = TaskInclude.load(task_ds, task_include=parent_task2)