Debian Codegraph @

lib/ansible/modules/import_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: import_tasks
13 short_description: Import a task list
14 description:
15 - Imports a list of tasks to be added to the current playbook for subsequent execution.
16 version_added: "2.4"
17 options:
18 free-form:
19 description:
20 - |
21 Specifies the name of the imported file directly without any other option C(- import_tasks: file.yml).
22 - Most keywords, including loops and conditionals, only apply to the imported tasks, not to this statement itself.
23 - If you need any of those to apply, use M(ansible.builtin.include_tasks) instead.
24 file:
25 description:
26 - Specifies the name of the file that lists tasks to add to the current playbook.
27 type: str
28 version_added: '2.7'
29 extends_documentation_fragment:
30 - action_common_attributes
31 - action_common_attributes.conn
32 - action_common_attributes.flow
33 - action_core
34 - action_core.import
35 attributes:
36 check_mode:
37 support: none
38 diff_mode:
39 support: none
40 notes:
41 - This is a core feature of Ansible, rather than a module, and cannot be overridden like a module
42 seealso:
43 - module: ansible.builtin.import_playbook
44 - module: ansible.builtin.import_role
45 - module: ansible.builtin.include_role
46 - module: ansible.builtin.include_tasks
47 - ref: playbooks_reuse
48 description: More information related to including and importing playbooks, roles and tasks.
49 """
50
51 EXAMPLES = r"""
52 - hosts: all
53 tasks:
54 - ansible.builtin.debug:
55 msg: task1
56
57 - name: Include task list in play
58 ansible.builtin.import_tasks:
59 file: stuff.yaml
60
61 - ansible.builtin.debug:
62 msg: task10
63
64 - hosts: all
65 tasks:
66 - ansible.builtin.debug:
67 msg: task1
68
69 - name: Apply conditional to all imported tasks
70 ansible.builtin.import_tasks: stuff.yaml
71 when: hostvar is defined
72 """
73
74 RETURN = r"""
75 # This module does not return anything except tasks to execute.
76 """