-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
129 lines (120 loc) · 5.04 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Define the list of machines
slurm_cluster = {
:head => {
:hostname => "head",
:ipaddress => "192.168.56.10",
:port => "2222",
:box => "bento/rockylinux-8",
:memory => "2048",
:cpus => "4",
:gui => false,
:setup_script => "PostVagrantScript.sh"
},
:compute => {
:hostname => "compute",
:ipaddress => "192.168.56.11",
:port => "2223",
:box => "bento/rockylinux-8",
:memory => "2048",
:cpus => "4",
:gui => false
},
:database => {
:hostname => "database",
:ipaddress => "192.168.56.12",
:port => "2224",
:box => "bento/rockylinux-8",
:memory => "1024",
:cpus => "1",
:gui => false
},
:extra => {
:hostname => "extra",
:ipaddress => "192.168.56.13",
:port => "2225",
:box => "bento/rockylinux-8",
:memory => "1024",
:cpus => "1",
:gui => false,
:disk_size => "4GB"
}
}
# VAGRANT CONFIGURATION
Vagrant.configure("2") do |global_config|
slurm_cluster.each_pair do |name, options|
global_config.vm.define name do |config|
# VM configurations
config.ssh.insert_key = false
config.ssh.forward_agent = true
config.vm.synced_folder '.', '/vagrant'
config.ssh.keys_only=true
# Define port forwarding for the "server3" machine
if name == :head
config.vm.hostname = options[:hostname]
config.vm.network :private_network, ip: options[:ipaddress]
config.vm.usable_port_range = 8000..9000
config.vm.box = options[:box]
config.vm.network "forwarded_port", guest: 22, host: options[:port], auto_correct: true
# VM specifications
config.vm.provider :virtualbox do |v|
v.name = options[:hostname]
v.customize ["modifyvm", :id, "--memory", options[:memory]]
v.cpus = options[:cpus]
v.gui = options[:gui]
end
# VM Provision Script
config.vm.provision "shell", privileged: true, path: options[:setup_script]
end
# Define port forwarding for the "server3" machine
if name == :compute
config.vm.hostname = options[:hostname]
config.vm.network :private_network, ip: options[:ipaddress]
config.vm.usable_port_range = 8000..9000
config.vm.box = options[:box]
config.vm.network "forwarded_port", guest: 22, host: options[:port], auto_correct: true
# VM specifications
config.vm.provider :virtualbox do |v|
v.name = options[:hostname]
v.customize ["modifyvm", :id, "--memory", options[:memory]]
v.cpus = options[:cpus]
v.gui = options[:gui]
end
end
# Define port forwarding for the "server3" machine
if name == :database
config.vm.hostname = options[:hostname]
config.vm.network :private_network, ip: options[:ipaddress]
config.vm.usable_port_range = 8000..9000
config.vm.box = options[:box]
config.vm.network "forwarded_port", guest: 22, host: options[:port], auto_correct: true
# VM specifications
config.vm.provider :virtualbox do |v|
v.name = options[:hostname]
v.customize ["modifyvm", :id, "--memory", options[:memory]]
v.cpus = options[:cpus]
v.gui = options[:gui]
end
end
# Define port forwarding for the "server3" machine
if name == :extra
config.vm.hostname = options[:hostname]
config.vm.network :private_network, ip: options[:ipaddress]
config.vm.usable_port_range = 8000..9000
config.vm.box = options[:box]
config.vm.network "forwarded_port", guest: 22, host: options[:port], auto_correct: true
# VM specifications
config.vm.provider :virtualbox do |v|
v.name = options[:hostname]
v.customize ["modifyvm", :id, "--memory", options[:memory]]
v.cpus = options[:cpus]
v.gui = options[:gui]
# v.linked_clone = true
v.check_guest_additions = false
end
(0..2).each do |i|
config.vm.disk :disk, size: options[:disk_size], name: "disk-#{i}"
end
end
end
end
end