Files
vagrant/Vagrantfile
T
2019-01-23 23:29:57 +08:00

59 lines
1.6 KiB
Ruby

Vagrant.configure(2) do |config|
# enable env plugin
config.env.enable
# base box
config.vm.box = "centos/7"
# add synced host folder with guest folder
config.vm.synced_folder ".", "/vagrant", type: "virtualbox"
# ssh configuration
config.ssh.insert_key = false
config.ssh.private_key_path = [ENV['PRIVATE_KEY_PATH'], "~/.vagrant.d/insecure_private_key"]
machines = {
'izyim' => {
:ip => '10.0.0.20',
:provision => './scripts/izyim.sh',
:cores => '2',
:memory => '1024',
:guest_port => '22',
:host_port => '2201'
},
'exchange' => {
:ip => '10.0.0.21',
:provision => './scripts/exchange.sh',
:cores => '2',
:memory => '1024',
:guest_port => '22',
:host_port => '2202'
}
}
machines.each do |hostname, attrs|
config.vm.define hostname do |machine|
# set up the hostname
machine.vm.hostname = hostname
# set up private network
machine.vm.network "private_network", ip: attrs[:ip]
# enable port forwarding
machine.vm.network :forwarded_port, host_ip: '127.0.0.1', id: 'ssh', guest: attrs[:guest_port], host: attrs[:host_port], protocol: 'tcp'
# provision scripts
machine.vm.provision "file", source: ENV['PUBLIC_KEY_PATH'], destination: '~/.ssh/authorized_keys'
machine.vm.provision :shell do |provision|
provision.path = attrs[:provision]
end
# virtualbox specific settings
machine.vm.provider "virtualbox" do |v|
v.memory = attrs[:memory]
v.cpus = attrs[:cores]
end
end
end
end