The need is to spawn 3 vagrant box. Provided I have installed vagrant on my system.
Goto the directory where Vagrantfile located.
Create and Update servers.yaml
---
- name: box1
hostname: box1
box: hashicorp/precise32
- name: box2
hostname: box2
box: hashicorp/precise32
- name: box3
hostname: box3
box: hashicorp/precise32
Update/Modify Vagrantfile accordingly
require 'yaml'
servers = YAML.load_file('servers.yaml')
Vagrant.configure(2) do | config |
..
..
servers.each do |servers|
config vm.define servers["name"] do |srv|
srv.vm.box = servers["box"]
srv.vm.hostname=servers["hostname"]
srv.vm.network = "public_network"
end
end
...
$ vagrant up ==> It will spawn three instances
$ vagrant halt ===> gracefull shutdown
Goto the directory where Vagrantfile located.
Create and Update servers.yaml
---
- name: box1
hostname: box1
box: hashicorp/precise32
- name: box2
hostname: box2
box: hashicorp/precise32
- name: box3
hostname: box3
box: hashicorp/precise32
Update/Modify Vagrantfile accordingly
require 'yaml'
servers = YAML.load_file('servers.yaml')
Vagrant.configure(2) do | config |
..
..
servers.each do |servers|
config vm.define servers["name"] do |srv|
srv.vm.box = servers["box"]
srv.vm.hostname=servers["hostname"]
srv.vm.network = "public_network"
end
end
...
$ vagrant up ==> It will spawn three instances
$ vagrant halt ===> gracefull shutdown