# Difference between import and include statements

**URL:** <https://forum.ansible.com/t/difference-between-import-and-include-statements/25022>\
**Category:** Ansible Project\
**Created:** [July 19, 2017, 9:30pm UTC](https://forum.ansible.com/t/difference-between-import-and-include-statements/25022 "2017-07-19T21:30:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nick\_Kakouros](https://avatars.discourse-cdn.com/v4/letter/n/d26b3c/32.png) [@Nick\_Kakouros](https://forum.ansible.com/u/Nick_Kakouros)\
**Post date:** [July 19, 2017, 9:30pm UTC](https://forum.ansible.com/t/difference-between-import-and-include-statements/25022/1 "2017-07-19T21:30:49Z")

</div>

I read on the changelog for 2.4:

> New import/include keywords to replace the old bare `include` directives. The use of `static: {yes|no}` on such includes is now deprecated.
> 
> - Using `import_*` (`import_playbook`, `import_tasks`, `import_role`) directives are static.
> - Using `include_*` (`include_tasks`, `include_role`) directives are dynamic.

Can someone provide a use case where the one would benefit the other?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [July 19, 2017, 9:39pm UTC](https://forum.ansible.com/t/difference-between-import-and-include-statements/25022/2 "2017-07-19T21:39:24Z")

</div>

Well, there are many different behaviours, depends on what you want to  
do, here is simple example:

- import\_tasks: x.yml  
&nbsp;&nbsp;with\_items: [1,2,3]

This willi import x.yml one time and every imported task will now run  
and loop over 1,2,3

- include\_tasks: x.yml  
&nbsp;&nbsp;with\_items: [1,2,3]

This will include x.yml 3 times and set the 'item' variable to 1, 2  
and 3 respectively
