About
This page shows you examples and differences between the Import and Include tasks.
They import both playbook but with different behavior.
What are the Differences
Statement | Type | Show the child if skipped | Apply the properties |
---|---|---|---|
import | static | Yes | to all child |
include | Dynamic | No | no only to the include node |
For instance, a tag property would be applied:
- on all child with an import
- on no child with an include (You would need to set the tag on each child that you want to run)
Example
import_tasks
- name: Test TCP connectivity
become: true
become_user: foo
import_tasks: 'tasks/tcp_connectivity_infa_sql_server.yml'
where the relative search path is
- for a play, playdir/{files|vars|templates}/, playdir/.
- for a role, rolename/{files|vars|templates}/, rolename/tasks/.
Include_Tasks
An Include_Tasks should always be wrapped around a block because it inherits the sudo property of its parent
- name: Service Pack Installation
become: yes
become_user: '{{ bdm_install_user }}'
block:
- name: Install Service Pack 1022SP1
include_tasks: user_install_1022sp1.yml