Debian Codegraph @

lib/ansible/modules/include_tasks.py

raw
1 # -*- coding: utf-8 -*-
2
3 # Copyright: Ansible Project
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 from __future__ import annotations
7
8
9 DOCUMENTATION = r"""
10 ---
11 author: Ansible Core Team (@ansible)
12 module: include_tasks
13 short_description: Dynamically include a task list
14 description:
15 - Includes a file with a list of tasks to be executed in the current playbook.
16 version_added: '2.4'
17 options:
18 file:
19 description:
20 - Specifies the name of the file that lists tasks to add to the current playbook.
21 type: str
22 version_added: '2.7'
23 apply:
24 description:
25 - Accepts a hash of task keywords (for example C(tags), C(become)) that will be applied to the tasks within the include.
26 type: str
27 version_added: '2.7'
28 free-form:
29 description:
30 - |
31 Specifies the name of the imported file directly without any other option C(- include_tasks: file.yml).
32 - Is the equivalent of specifying an argument for the O(file) parameter.
33 - Most keywords, including loop, with_items, and conditionals, apply to this statement unlike M(ansible.builtin.import_tasks).
34 - The do-until loop is not supported.
35 extends_documentation_fragment:
36 - action_common_attributes
37 - action_common_attributes.conn
38 - action_common_attributes.flow
39 - action_core
40 - action_core.include
41 attributes:
42 check_mode:
43 support: none
44 diff_mode:
45 support: none
46 seealso:
47 - module: ansible.builtin.import_playbook
48 - module: ansible.builtin.import_role
49 - module: ansible.builtin.import_tasks
50 - module: ansible.builtin.include_role
51 - ref: playbooks_reuse
52 description: More information related to including and importing playbooks, roles and tasks.
53 """
54
55 EXAMPLES = r"""
56 - hosts: all
57 tasks:
58 - ansible.builtin.debug:
59 msg: task1
60
61 - name: Include task list in play
62 ansible.builtin.include_tasks:
63 file: stuff.yaml
64
65 - ansible.builtin.debug:
66 msg: task10
67
68 - hosts: all
69 tasks:
70 - ansible.builtin.debug:
71 msg: task1
72
73 - name: Include task list in play only if the condition is true
74 ansible.builtin.include_tasks: "{{ hostvar }}.yaml"
75 when: hostvar is defined
76
77 - name: Apply tags to tasks within included file
78 ansible.builtin.include_tasks:
79 file: install.yml
80 apply:
81 tags:
82 - install
83 tags:
84 - always
85
86 - name: Apply tags to tasks within included file when using free-form
87 ansible.builtin.include_tasks: install.yml
88 args:
89 apply:
90 tags:
91 - install
92 tags:
93 - always
94 """
95
96 RETURN = r"""
97 # This module does not return anything except tasks to execute.
98 """