Debian Codegraph @

lib/ansible/modules/import_playbook.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_playbook
13 short_description: Import a playbook
14 description:
15 - Includes a file with a list of plays to be executed.
16 - Files with a list of plays can only be included at the top level.
17 - You cannot use this action inside a play.
18 version_added: "2.4"
19 options:
20 free-form:
21 description:
22 - The name of the imported playbook is specified directly without any other option.
23 extends_documentation_fragment:
24 - action_common_attributes
25 - action_common_attributes.conn
26 - action_common_attributes.flow
27 - action_core
28 - action_core.import
29 attributes:
30 check_mode:
31 support: full
32 diff_mode:
33 support: none
34 platform:
35 platforms: all
36 notes:
37 - This is a core feature of Ansible, rather than a module, and cannot be overridden like a module.
38 seealso:
39 - module: ansible.builtin.import_role
40 - module: ansible.builtin.import_tasks
41 - module: ansible.builtin.include_role
42 - module: ansible.builtin.include_tasks
43 - ref: playbooks_reuse
44 description: More information related to including and importing playbooks, roles and tasks.
45 """
46
47 EXAMPLES = r"""
48 - hosts: localhost
49 tasks:
50 - ansible.builtin.debug:
51 msg: play1
52
53 - name: Include a play after another play
54 ansible.builtin.import_playbook: otherplays.yaml
55
56 - name: Set variables on an imported playbook
57 ansible.builtin.import_playbook: otherplays.yml
58 vars:
59 service: httpd
60
61 - name: Include a playbook from a collection
62 ansible.builtin.import_playbook: my_namespace.my_collection.my_playbook
63
64 - name: This DOES NOT WORK
65 hosts: all
66 tasks:
67 - ansible.builtin.debug:
68 msg: task1
69
70 - name: This fails because I'm inside a play already
71 ansible.builtin.import_playbook: stuff.yaml
72 """
73
74 RETURN = r"""
75 # This module does not return anything except plays to execute.
76 """