# Running remote playbooks within a play

**URL:** <https://forum.ansible.com/t/running-remote-playbooks-within-a-play/14922>\
**Category:** Ansible Project\
**Created:** [April 2, 2014, 5:32pm UTC](https://forum.ansible.com/t/running-remote-playbooks-within-a-play/14922 "2014-04-02T17:32:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![herby.gillot1](https://avatars.discourse-cdn.com/v4/letter/h/8e8cbc/32.png) [@herby.gillot1](https://forum.ansible.com/u/herby.gillot1)\
**Post date:** [April 2, 2014, 5:32pm UTC](https://forum.ansible.com/t/running-remote-playbooks-within-a-play/14922/1 "2014-04-02T17:32:11Z")

</div>

Purely out of curiosity, what is the suggested course of action to run playbooks present on a remote host within a current run of a local Ansible play?

The worst case being to use the shell module to actually exec Ansible remotely with the remote playbook, are there more elegant approaches?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [April 2, 2014, 8:22pm UTC](https://forum.ansible.com/t/running-remote-playbooks-within-a-play/14922/2 "2014-04-02T20:22:44Z")

</div>

Calling Ansible with Ansible?

There is no suggested course of action, but I suspect you would do exactly that.

I’d really want to understand the _why_ though.

---

<div class="post-metadata">

**Author:** ![herby.gillot1](https://avatars.discourse-cdn.com/v4/letter/h/8e8cbc/32.png) [@herby.gillot1](https://forum.ansible.com/u/herby.gillot1)\
**Post date:** [April 3, 2014, 12:49am UTC](https://forum.ansible.com/t/running-remote-playbooks-within-a-play/14922/3 "2014-04-03T00:49:24Z")

</div>

So let’s say you have the following situation:

- You have some sizable number of hosts, with some particular software that contains its own set of playbooks.

- There may be differences in the software versions, and thus playbooks can differ between sets of these remote hosts.

- You also have inventory and playbooks outside of these hosts, in your local environment.

- You want to run both the local and remote playbooks using the same (local) inventory.

In the situation where you don’t care about local inventory or context, I guess kicking off a remote execution of Ansible using the shell module or SSH would be an option.

But if you _did_ care about the current operating context, it would be interesting if Ansible were able to start a remote “slave” runner that would then run the remote playbooks/roles using the inventory and context delivered from your current local Ansible running instance (the parent/master).

The remote runner would run the remote plays with the host/inventory\_hostname set to the remote host’s, but at least you’d be able to share context such as facts, variables and inventory and be able to run plays/roles that exist on the remote side. (Just an idea.)

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [April 3, 2014, 10:10pm UTC](https://forum.ansible.com/t/running-remote-playbooks-within-a-play/14922/4 "2014-04-03T22:10:37Z")

</div>

Yeah I’m not seeing where you need this yet.

Depends on the scale of your infrastructure, but plenty of very very large setups are not doing this – and really, if you are in that area, treating cloud like cloud and using Ansible to build images is often a great option.

---

<div class="post-metadata">

**Author:** ![Erik\_Anderson](https://avatars.discourse-cdn.com/v4/letter/e/71c47a/32.png) [@Erik\_Anderson](https://forum.ansible.com/u/Erik_Anderson)\
**Post date:** [April 4, 2014, 3:26pm UTC](https://forum.ansible.com/t/running-remote-playbooks-within-a-play/14922/5 "2014-04-04T15:26:26Z")

</div>

Just to provide another perspective, we have a use case for running remote  
playbooks, and are doing this this via the shell module.

We really have two Ansible use cases - one is using Ansible in a  
"traditional" sense for provisioning servers, building images, etc. Our  
second use case is, I guess, a bit nonstandard. That being the  
configuration of on-premise server "appliances" installed in our customer's  
datacenters. We let customers provide configuration information - this gets  
saved to a local facts file, which is then used by a local playbook to  
apply the configuration. Sometimes this playbook is executed in a  
"standalone" fashion, independent of our centralized provisioning system,  
but sometimes it is executed remotely via another centralized playbook.

-Erik
