-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
37 lines (36 loc) · 1.44 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/xenial64"
N = 5
D = 3
(1..N).each do |machine_id|
config.vm.define "machine#{machine_id}" do |machine|
machine.vm.hostname = "machine#{machine_id}"
machine.vm.network "private_network", ip: "192.168.77.#{1+machine_id}", netmask: "255.255.255.0"
config.vm.provider "virtualbox" do |v|
v.memory = 2048
end
(0..D-1).each do |d|
machine.vm.provider :virtualbox do |vb|
unless File.exist?("disk-#{machine_id}-#{d}.vdi")
vb.customize [ "createmedium", "--filename", "disk-#{machine_id}-#{d}.vdi", "--size", 1024*1024 ]
end
vb.customize [ "storageattach", :id, "--storagectl", "SCSI", "--port", 2+d, "--device", 0, "--type", "hdd", "--medium", "disk-#{machine_id}-#{d}.vdi" ]
end
end
# Only execute the Ansible provisioner,
# when all the machines are up and ready.
if machine_id == N
machine.vm.provision :ansible do |ansible|
# Disable default limit to connect to all the machines
ansible.limit = "all"
ansible.playbook = "provisioning/playbook.yaml"
ansible.groups = {
"orchestrated" => ["machine1", "machine2", "machine3", "machine4", "machine5"]
}
end
end
end
end
end