Hello

so Vagrantfiles are read outside to inside.

so you can setup some global settings at config. level and you can override
inside the do |lele| level


  Vagrant.configure("2") do |config|

      confi.vm.box = "debian/jessie64"

      config.vm.define "api" do |api|
        # something
      end

      config.vm.define "web" do |web|
        # something
      end

      config.vm.define "web" do |worker|
        worker.vm.box = "centos/7"
      end
    end


I usually have a global provision for shared code and then on each box some
local box/role specific setup

Example:
https://github.com/nabels-coolblue/redis-sampleapp-dotnet/blob/master/Vagrantfile

Does that help?


Alvaro

On Thu, Sep 28, 2017 at 5:18 AM, James Conant <[email protected]> wrote:

> 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
> <https://groups.google.com/d/msgid/vagrant-up/7aa4d471-8784-4eab-9c77-f65af954f2f8%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Alvaro

-- 
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/CAHqq0eyt6Oha3S7S85p%3DEBkjQOGhmjpE%2BHXgweY2Tp6DMGSO1A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to