clarify import_ docs (#28395)
* clarify import_ docs * fixed izpellz * Copy edits.
This commit is contained in:
parent
0d69b63c01
commit
f4fff54f68
3 changed files with 14 additions and 5 deletions
|
@ -9,7 +9,7 @@ Creating Reusable Playbooks
|
|||
|
||||
While it is possible to write a playbook in one very large file (and you might start out learning playbooks this way), eventually you'll want to reuse files and start to organize things. In Ansible, there are three ways to do this: includes, imports, and roles.
|
||||
|
||||
Includes and imports allow users to break up large playbooks into smaller files, which can be used across multiple parent playbooks or even multiple times within the same Playbook.
|
||||
Includes and imports (added in 2.4) allow users to break up large playbooks into smaller files, which can be used across multiple parent playbooks or even multiple times within the same Playbook.
|
||||
|
||||
Roles allow more than just tasks to be packaged together and can include variables, handlers, or even modules and other plugins. Unlike includes and imports, roles can also be uploaded and shared via Ansible Galaxy.
|
||||
|
||||
|
|
|
@ -13,17 +13,25 @@ As noted in :doc:`playbooks_reuse`, include and import statements are very simil
|
|||
|
||||
Please refer to :doc:`playbooks_reuse` for documentation concerning the trade-offs one may encounter when using each type.
|
||||
|
||||
Also be aware that this behaviour changed in 2.4; prior to that Ansible version only ``include`` was available, and it behaved differently depending on context.
|
||||
|
||||
.. versionadded:: 2.4
|
||||
|
||||
Importing Playbooks
|
||||
```````````````````
|
||||
|
||||
It is possible to include playbooks inside a master playbook. For example::
|
||||
|
||||
---
|
||||
import_playbook: webservers.yml
|
||||
import_playbook: databases.yml
|
||||
- import_playbook: webservers.yml
|
||||
- import_playbook: databases.yml
|
||||
|
||||
Each playbook listed will be run in the order they are listed.
|
||||
The plays and tasks in each playbook listed will be run in the order they are listed, just as if they had been defined here directly.
|
||||
|
||||
Prior to 2.4 only ``include`` was available and worked for both playbooks and tasks as both import and include.
|
||||
|
||||
|
||||
.. versionadded:: 2.4
|
||||
|
||||
Including and Importing Task Files
|
||||
``````````````````````````````````
|
||||
|
|
|
@ -42,7 +42,8 @@ Roles expect files to be in certain directory names. Roles must include at least
|
|||
Other YAML files may be included in certain directories. For example, it is common practice to have platform-specific tasks included from the ``tasks/main.yml`` file::
|
||||
|
||||
# roles/example/tasks/main.yml
|
||||
- import_tasks: redhat.yml
|
||||
- name: added in 2.4, previouslly you used 'include'
|
||||
import_tasks: redhat.yml
|
||||
when: ansible_os_platform|lower == 'redhat'
|
||||
- import_tasks: debian.yml
|
||||
when: ansible_os_platform|lower == 'debian'
|
||||
|
|
Loading…
Reference in a new issue