# import\_playbook for a different host

**URL:** <https://forum.ansible.com/t/import-playbook-for-a-different-host/31730>\
**Category:** Ansible Project\
**Created:** [November 27, 2019, 3:14am UTC](https://forum.ansible.com/t/import-playbook-for-a-different-host/31730 "2019-11-27T03:14:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael3](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@Michael3](https://forum.ansible.com/u/Michael3)\
**Post date:** [November 27, 2019, 3:14am UTC](https://forum.ansible.com/t/import-playbook-for-a-different-host/31730/1 "2019-11-27T03:14:55Z")

</div>

Let’s say i have host groups defined in my inventory file as follows:

[group1]  
serverA

[group2]  
serverB

and i have a playbook called existing.yml that has hosts variable defined for host in group1:

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [November 27, 2019, 8:06am UTC](https://forum.ansible.com/t/import-playbook-for-a-different-host/31730/2 "2019-11-27T08:06:46Z")

</div>

> Let's say i have host groups defined in my inventory file as follows:
> 
> [group1]  
> serverA
> 
> [group2]  
> serverB
> 
> and i have a playbook called existing.yml that has hosts variable defined for host in group1:
> 
> ---  
> - hosts: group1  
> tags: install
> 
> tasks:  
> - module ...
> 
> Can i include existing.yml in another play but for a different host? I have tried something like this:
> 
> ---  
> - import\_playbook: existing.yml  
> hosts: group2
> 
> but this fails. What is the best way to call an existing playbook for a different host than the host defined inside the  
> called play?

Hello Michael,

it is always useful to explain the background of your task in order to get better answers.

You could use multiple plays in your playbook:

- hosts: group1  
&nbsp;&nbsp;tasks:

- hosts: group2  
&nbsp;&nbsp;tasks:

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Sunil\_Amperayani](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@Sunil\_Amperayani](https://forum.ansible.com/u/Sunil_Amperayani)\
**Post date:** [December 4, 2019, 1:27am UTC](https://forum.ansible.com/t/import-playbook-for-a-different-host/31730/3 "2019-12-04T01:27:16Z")

</div>

Please provide more info and include your errors so that we can get idea to debug more on this
