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?
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.
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.)
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.
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