Bulding a Testing Sandbox.

5 views
Skip to first unread message

Mitchell Sullivan

unread,
Feb 22, 2018, 4:09:25 AM2/22/18
to Vagrant
Hi Vagrant Team.

I'm an Australian IT Professional who has just started a new role in Europe. I come from a wintel IT Infrastructure background, however for my new role I need to get up to speed with Linux Really quick.
Is it possible to use Vagrant to build Mutliple VMs on my laptop, in an isloated 'sandbox' setup to test linux server topology. I want to built 3 simple linux servers and test intergrating FreeIPA with FreeRadius.

I've just built a Vagrant VM based on the getting started guide. I will keep trying things out, but any tips or feedback to help me on my way would be greatly appreciated. 

Thanks
Mitch.

Alvaro Miranda Aguilera

unread,
Feb 22, 2018, 6:16:49 AM2/22/18
to vagra...@googlegroups.com
Hello

Yes its possible.

Following the format, I am an Chlean IT Proffesional also in Europe!


Vagrant does have a sense of default box, its called default

you can override that and setup a name on it, this is the building block to have a multi setup setup.


let say you start with this


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

    config.vm.box = "hashicorp/precise64"

end


It will create a vm named default inside vagrant, you can check with vagrant status


Vagrantfile is ruby, so if you learn bit of ruby will help a lot

basically the do |config| put us inside the block, so you can create nested objects



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

    config.vm.box = "hashicorp/precise64"

    config.vm.define "box1"

end


Vagrant status here will say:


Current machine states:

box1                      not created (virtualbox)


So what we have here is, anything at config. level will apply to all the boxes and we have a way to define boxes.


Putting to work we can have:


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

  config.vm.define vm_name = "web" do |node|

    node.vm.box = "hashicorp/precise64"

    node.vm.hostname = vm_name

  end

end



you can repeat


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

  config.vm.define vm_name = "web" do |node|

    node.vm.box = "hashicorp/precise64"

    node.vm.hostname = vm_name

  end

  config.vm.define vm_name = "db" do |node|

    node.vm.box = "hashicorp/precise64"

    node.vm.hostname = vm_name

  end

end




you can add a loop to one


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

  prefix="node"

  #node box

  (1..4).each do |i|

    vm_name = "#{prefix}#{i}"

    config.vm.define vm_name do |node|

      node.vm.box = "hashicorp/precise64"

      node.vm.hostname = vm_name

    end

  end

end



Key point here, do |node| create a new block, and inside here whatever we do will apply to that box only

If you want setup cpu/ram for all the boxes, you put it at config. level

if you want to setup just 1 vm hostname to <this> then you do it in a node. level

make sense?


if you want to add provisioning, at config. level will apply to all the boxes

at node. level will apply to that particular box

let me know if this helps to get you started



Thanks
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 vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/1fbe6486-0577-4f4a-857e-3d0a5d3e59e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Yves Guerin

unread,
Feb 22, 2018, 9:00:51 AM2/22/18
to Vagrant
Dear,

Read the doc and as usual: Google.com is your best friend
Reply all
Reply to author
Forward
0 new messages