forked from openattic/openattic-vagrant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
281 lines (233 loc) · 10.2 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
raise Vagrant::Errors::VagrantError.new,
"'settings.yml' file not found.\n\n" \
"Please define your 'settings.yml'. " \
"See 'settings.sample.yml' for an example." unless File.exist?("settings.yml")
settings = YAML.load_file('settings.yml')
openattic_repo = settings.has_key?('openattic_repo') ?
settings['openattic_repo'] : "~/openattic"
deepsea_repo = settings.has_key?('deepsea_repo') ?
settings['deepsea_repo'] : "~/DeepSea"
num_volumes = settings.has_key?('vm_num_volumes') ?
settings['vm_num_volumes'] : 2
volume_size = settings.has_key?('vm_volume_size') ?
settings['vm_volume_size'] : '8G'
nfs_auto_export = settings.has_key?('nfs_auto_export') ?
settings['nfs_auto_export'] : true
Vagrant.configure("2") do |config|
config.vm.box = "opensuse/openSUSE-42.1-x86_64"
config.vm.provider "libvirt" do |lv|
if settings.has_key?('libvirt_host') then
lv.host = settings['libvirt_host']
end
if settings.has_key?('libvirt_user') then
lv.username = settings['libvirt_user']
end
if settings.has_key?('libvirt_use_ssl') then
lv.connect_via_ssh = true
end
lv.memory = settings.has_key?('vm_memory') ? settings['vm_memory'] : 4096
lv.cpus = settings.has_key?('vm_cpus') ? settings['vm_cpus'] : 2
if settings.has_key?('vm_storage_pool') then
lv.storage_pool_name = settings['vm_storage_pool']
end
end
config.vm.provider :virtualbox do |vb|
vb.memory = settings.has_key?('vm_memory') ? settings['vm_memory'] : 4096
vb.cpus = settings.has_key?('vm_cpus') ? settings['vm_cpus'] : 2
end
config.vm.define :salt do |salt|
salt.vm.hostname = "salt"
salt.vm.network :private_network, ip: "192.168.100.200"
salt.vm.provision "file", source: "keys/id_rsa",
destination:".ssh/id_rsa"
salt.vm.provision "file", source: "keys/id_rsa.pub",
destination:".ssh/id_rsa.pub"
salt.vm.provision "file", source: "bin",
destination:"."
salt.vm.synced_folder openattic_repo, '/home/vagrant/openattic', type: 'nfs',
:nfs_export => nfs_auto_export,
:mount_options => ['nolock,vers=3,udp,noatime,actimeo=1'],
:linux__nfs_options => ['rw','no_subtree_check','all_squash','insecure']
salt.vm.synced_folder deepsea_repo, '/home/vagrant/DeepSea', type: 'nfs',
:nfs_export => nfs_auto_export,
:mount_options => ['nolock,vers=3,udp,noatime,actimeo=1'],
:linux__nfs_options => ['rw','no_subtree_check','all_squash','insecure']
config.vm.synced_folder ".", "/vagrant", disabled: true
salt.vm.provision "shell", inline: <<-SHELL
SuSEfirewall2 off
echo "192.168.100.200 salt" >> /etc/hosts
echo "192.168.100.201 node1" >> /etc/hosts
echo "192.168.100.202 node2" >> /etc/hosts
echo "192.168.100.203 node3" >> /etc/hosts
cat /home/vagrant/.ssh/id_rsa.pub >> /home/vagrant/.ssh/authorized_keys
mkdir /root/.ssh
chmod 600 /home/vagrant/.ssh/id_rsa
cp /home/vagrant/.ssh/id_rsa* /root/.ssh/
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
chmod 755 -R bin/
zypper ar http://download.opensuse.org/repositories/filesystems:/ceph:/jewel/openSUSE_Leap_42.1/filesystems:ceph:jewel.repo
zypper ar http://download.opensuse.org/repositories/home:/swiftgist/openSUSE_Leap_42.1/home:swiftgist.repo
zypper --gpg-auto-import-keys ref
zypper ar https://yum.dockerproject.org/repo/main/opensuse/13.2/ docker-main
zypper --no-gpg-checks ref
zypper -n --no-gpg-checks install docker-engine
zypper rr docker-main
systemctl enable docker
systemctl restart docker
zypper -n install ntp
systemctl enable ntpd
git clone https://github.com/openattic/openattic-docker.git
cd openattic-docker
git checkout wip-deepsea
cd openattic-dev/opensuse_leap_42.2
docker build -t openattic-dev .
SHELL
end
config.vm.define :node1 do |node|
node.vm.hostname = "node1"
node.vm.network :private_network, ip: "192.168.100.201"
node.vm.provision "file", source: "keys/id_rsa",
destination:".ssh/id_rsa"
node.vm.provision "file", source: "keys/id_rsa.pub",
destination:".ssh/id_rsa.pub"
node.vm.provider "libvirt" do |lv|
(1..num_volumes).each do |d|
lv.storage :file, size: volume_size, type: 'raw'
end
end
node.vm.provider :virtualbox do |vb|
for i in 1..num_volumes do
file_to_disk = "./disks/#{node.vm.hostname}-disk#{i}.vmdk"
unless File.exist?(file_to_disk)
vb.customize ['createmedium', 'disk', '--filename', file_to_disk,
'--size', volume_size]
vb.customize ['storageattach', :id,
'--storagectl', 'SATA Controller',
'--port', i, '--device', 0,
'--type', 'hdd', '--medium', file_to_disk]
end
end
end
node.vm.provision "shell", inline: <<-SHELL
SuSEfirewall2 off
echo "192.168.100.200 salt" >> /etc/hosts
echo "192.168.100.201 node1" >> /etc/hosts
echo "192.168.100.202 node2" >> /etc/hosts
echo "192.168.100.203 node3" >> /etc/hosts
cat /home/vagrant/.ssh/id_rsa.pub >> /home/vagrant/.ssh/authorized_keys
mkdir /root/.ssh
chmod 600 /home/vagrant/.ssh/id_rsa
cp /home/vagrant/.ssh/id_rsa* /root/.ssh/
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
zypper ar http://download.opensuse.org/repositories/filesystems:/ceph:/jewel/openSUSE_Leap_42.1/filesystems:ceph:jewel.repo
zypper ar http://download.opensuse.org/repositories/home:/swiftgist/openSUSE_Leap_42.1/home:swiftgist.repo
zypper --gpg-auto-import-keys ref
zypper -n up
zypper -n install ntp
zypper -n install salt-minion
systemctl enable salt-minion
(sleep 10; reboot) &
SHELL
end
config.vm.define :node2 do |node|
node.vm.hostname = "node2"
node.vm.network :private_network, ip: "192.168.100.202"
node.vm.provision "file", source: "keys/id_rsa",
destination:".ssh/id_rsa"
node.vm.provision "file", source: "keys/id_rsa.pub",
destination:".ssh/id_rsa.pub"
node.vm.provider "libvirt" do |lv|
(1..num_volumes).each do |d|
lv.storage :file, size: volume_size, type: 'raw'
end
end
node.vm.provider :virtualbox do |vb|
for i in 1..num_volumes do
file_to_disk = "./disks/#{node.vm.hostname}-disk#{i}.vmdk"
unless File.exist?(file_to_disk)
vb.customize ['createmedium', 'disk', '--filename', file_to_disk,
'--size', volume_size]
vb.customize ['storageattach', :id,
'--storagectl', 'SATA Controller',
'--port', i, '--device', 0,
'--type', 'hdd', '--medium', file_to_disk]
end
end
end
node.vm.provision "shell", inline: <<-SHELL
SuSEfirewall2 off
echo "192.168.100.200 salt" >> /etc/hosts
echo "192.168.100.201 node1" >> /etc/hosts
echo "192.168.100.202 node2" >> /etc/hosts
echo "192.168.100.203 node3" >> /etc/hosts
cat /home/vagrant/.ssh/id_rsa.pub >> /home/vagrant/.ssh/authorized_keys
mkdir /root/.ssh
chmod 600 /home/vagrant/.ssh/id_rsa
cp /home/vagrant/.ssh/id_rsa* /root/.ssh/
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
ssh-keyscan -H salt >> ~/.ssh/known_hosts
ssh-keyscan -H node1 >> ~/.ssh/known_hosts
ssh-keyscan -H node3 >> ~/.ssh/known_hosts
zypper ar http://download.opensuse.org/repositories/filesystems:/ceph:/jewel/openSUSE_Leap_42.1/filesystems:ceph:jewel.repo
zypper ar http://download.opensuse.org/repositories/home:/swiftgist/openSUSE_Leap_42.1/home:swiftgist.repo
zypper --gpg-auto-import-keys ref
zypper -n up
zypper -n install ntp
zypper -n install salt-minion
systemctl enable salt-minion
(sleep 10; reboot) &
SHELL
end
config.vm.define :node3 do |node|
node.vm.hostname = "node3"
node.vm.network :private_network, ip: "192.168.100.203"
node.vm.provision "file", source: "keys/id_rsa",
destination:".ssh/id_rsa"
node.vm.provision "file", source: "keys/id_rsa.pub",
destination:".ssh/id_rsa.pub"
node.vm.provider "libvirt" do |lv|
(1..num_volumes).each do |d|
lv.storage :file, size: volume_size, type: 'raw'
end
end
node.vm.provider :virtualbox do |vb|
for i in 1..num_volumes do
file_to_disk = "./disks/#{node.vm.hostname}-disk#{i}.vmdk"
unless File.exist?(file_to_disk)
vb.customize ['createmedium', 'disk', '--filename', file_to_disk,
'--size', volume_size]
vb.customize ['storageattach', :id,
'--storagectl', 'SATA Controller',
'--port', i, '--device', 0,
'--type', 'hdd', '--medium', file_to_disk]
end
end
end
node.vm.provision "shell", inline: <<-SHELL
SuSEfirewall2 off
echo "192.168.100.200 salt" >> /etc/hosts
echo "192.168.100.201 node1" >> /etc/hosts
echo "192.168.100.202 node2" >> /etc/hosts
echo "192.168.100.203 node3" >> /etc/hosts
cat /home/vagrant/.ssh/id_rsa.pub >> /home/vagrant/.ssh/authorized_keys
mkdir /root/.ssh
chmod 600 /home/vagrant/.ssh/id_rsa
cp /home/vagrant/.ssh/id_rsa* /root/.ssh/
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
ssh-keyscan -H salt >> ~/.ssh/known_hosts
ssh-keyscan -H node1 >> ~/.ssh/known_hosts
ssh-keyscan -H node2 >> ~/.ssh/known_hosts
zypper ar http://download.opensuse.org/repositories/filesystems:/ceph:/jewel/openSUSE_Leap_42.1/filesystems:ceph:jewel.repo
zypper ar http://download.opensuse.org/repositories/home:/swiftgist/openSUSE_Leap_42.1/home:swiftgist.repo
zypper --gpg-auto-import-keys ref
zypper -n up
zypper -n install ntp
zypper -n install salt-minion
systemctl enable salt-minion
(sleep 10; reboot) &
SHELL
end
end