What's the difference between Import vs Include in Ansible?

Card Puncher Data Processing


This page shows you examples and differences between Import and Include tasks.

What are the Differences

Statement Type Show the child if skipped Apply the properties
import static Yes directly
include Dynamic No from the parent



- 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/.


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 }}'
    - name: Install Service Pack 1022SP1
      include_tasks: user_install_1022sp1.yml

Discover More
Card Puncher Data Processing
Ansible PlayBook - Task

A task is a call to an ansible module with arguments located in a play list. Variables can be used in arguments to modules. Tasks are executed top to bottom one at a time, against matched by the...

Share this page:
Follow us:
Task Runner