In other words, to merge two Vagrant files?
Vagrant Multi-Machine functionality seems pretty cool, however one thing
that bothers me (or is isn't immediately apparent) is that there doesn't
seem to be a good way to share configuration options between a "parent"
Vagrantfile and "children" Vagrantfiles. Is there a way to effectively and
maintainably share configuration options between the parent and it's
children? An example might make this more clear.
Let's assume I've got a platform which is comprised of 3 apps/services:
API, Web, and Worker.
Let's presume a directory structure of the following:
/some_platform
/api
# app code...
Vagrantfile
/web
# app code...
Vagrantfile
/worker
# app code...
Vagrantfile
Vagrantfile
Let's say `/some_platform/api/Vagrantfile` looks like:
Vagrant.configure("2") do |config|
config.vm.box = "debian/jessie64"
end
Presumably the web and worker Vagrantfiles look similar.
Now, using the wonders of Multi-Machine I rely on Vagrant coordinate these
VMs, and `/some_platform/Vagrantfile` looks like:
Vagrant.configure("2") do |config|
config.vm.define "web" do |api|
api.vm.box = "debian/jessie64"
end
config.vm.define "web" do |web|
web.vm.box = "debian/jessie64"
end
config.vm.define "web" do |worker|
worker.vm.box = "debian/jessie64"
end
end
I realize this example is contrived, but it's easy to see how once you get
more and more complex config declarations, it's annoying and hazardous to
have that config duplicated in two places.
You might be wondering "Why does each project have it's own Vagrantfile?"
Doing so provides a single source of truth for how the server that app runs
on should be setup. I realize there are provisioners you can use (and I
will use them), but you still have to declare a few other things outside of
that and I want to keep that DRY so that I can either bring up a cluster of
apps via Multi-Machine, or I can work on a single app and change it's
VM/server setup.
What I'd really love is a way to merge other Vagrantfiles into a "parent"
file.
Is that possible? Or am I crazy for trying? Any clever ideas on how to
achieve this? I've mucked about with some yaml files and POROs to skate
around this issue, but none of the hacks feel very satisfying.
Best,
James
--
This mailing list is governed under the HashiCorp Community Guidelines -
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of
those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups
"Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vagrant-up/7aa4d471-8784-4eab-9c77-f65af954f2f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.