# Import/Include a Single task from one play book to another play book.

**URL:** <https://forum.ansible.com/t/import-include-a-single-task-from-one-play-book-to-another-play-book/26990>\
**Category:** Ansible Project\
**Created:** [March 14, 2018, 5:31am UTC](https://forum.ansible.com/t/import-include-a-single-task-from-one-play-book-to-another-play-book/26990 "2018-03-14T05:31:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vino\_B](https://avatars.discourse-cdn.com/v4/letter/v/839c29/32.png) [@Vino\_B](https://forum.ansible.com/u/Vino_B)\
**Post date:** [March 14, 2018, 5:31am UTC](https://forum.ansible.com/t/import-include-a-single-task-from-one-play-book-to-another-play-book/26990/1 "2018-03-14T05:31:34Z")

</div>

Hi All,

Not sure whether it is possible, but let me raise the question, it is possible to import/include a single task for one play book to another play book rather than importing the entire play book.e.g

common.yml

- task1  
tags: T1

- task2  
tags: T2

- task3  
tags: T3

one.yml  
include common.yml --tag T1

two.yml  
include common.yml --tag T2

include common.yml --tag T3

From,  
Vino.B

---

<div class="post-metadata">

**Author:** ![SUMIT\_SAHAY](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@SUMIT\_SAHAY](https://forum.ansible.com/u/SUMIT_SAHAY)\
**Post date:** [March 14, 2018, 11:32am UTC](https://forum.ansible.com/t/import-include-a-single-task-from-one-play-book-to-another-play-book/26990/2 "2018-03-14T11:32:03Z")

</div>

Hi Vino,

Yes, it is possible you have to include your child playbook to add in your parent playbook.

– include your\_playbook.yml

this will run after your parent playbook get executed.

Thanks & Regards  
Sumit Sahay

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [March 14, 2018, 2:57pm UTC](https://forum.ansible.com/t/import-include-a-single-task-from-one-play-book-to-another-play-book/26990/3 "2018-03-14T14:57:54Z")

</div>

no, you cannot pass 'run this tag' to includes.

---

<div class="post-metadata">

**Author:** ![Vino\_B](https://avatars.discourse-cdn.com/v4/letter/v/839c29/32.png) [@Vino\_B](https://forum.ansible.com/u/Vino_B)\
**Post date:** [March 15, 2018, 4:15pm UTC](https://forum.ansible.com/t/import-include-a-single-task-from-one-play-book-to-another-play-book/26990/4 "2018-03-15T16:15:46Z")

</div>

Hi All,

I was able to find the solution as this was stated in the ansible documentation

And import/include statements:

```auto
- import_tasks: foo.yml
  tags: [web,foo]

```

or:

```auto
- include_tasks: foo.yml
  tags: [web,foo]

```

All of these apply the specified tags to EACH task inside the play, included file, or role, so that these tasks can be selectively run when the playbook is invoked with the corresponding tags.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [March 15, 2018, 10:44pm UTC](https://forum.ansible.com/t/import-include-a-single-task-from-one-play-book-to-another-play-book/26990/5 "2018-03-15T22:44:54Z")

</div>

import\_X applies the tags to the imported tasks, include\_X has the  
tags applied to itself, but not to the included tasks (we plan update  
with feature to allow for this).
