-
Notifications
You must be signed in to change notification settings - Fork 16
/
Vagrantfile
80 lines (69 loc) · 2.35 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = '2'
MONITORNO = 1
OSDNO = 3
SUBNET = '192.168.101'
ansible_provision = proc do |ansible|
ansible.playbook = 'site.yml'
ansible.groups = {
'mons' => (0..MONITORNO - 1).map { |j| "mon#{j}" },
'osds' => (0..OSDNO - 1).map { |j| "osd#{j}" },
}
ansible.extra_vars = {
fsid: '10c95f01-2dd2-4863-affa-60c4eafcd8d2',
monitor_secret: 'AQBNTxZRWId7JxAA/Ac4ToR7ZfNdOGDSToGHpA=='
}
ansible.limit = 'all'
end
def create_vmdk(name, size)
dir = Pathname.new(__FILE__).expand_path.dirname
path = File.join(dir, '.vagrant', name + '.vmdk')
`vmware-vdiskmanager -c -s #{size} -t 0 -a scsi #{path} \
2>&1 > /dev/null` unless File.exist?(path)
end
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = 'ceph/centos7'
config.ssh.pty = true
config.ssh.insert_key = false # workaround for https://github.com/mitchellh/vagrant/issues/5048
(0..MONITORNO - 1).each do |i|
config.vm.define "mon#{i}" do |mon|
mon.vm.network :private_network, ip: "#{SUBNET}.1#{i}"
mon.vm.provider :virtualbox do |vb|
vb.customize ['modifyvm', :id, '--memory', '192']
end
mon.vm.provider :vmware_fusion do |v|
v.vmx['memsize'] = '192'
end
end
end
(0..OSDNO - 1).each do |i|
config.vm.define "osd#{i}" do |osd|
osd.vm.network :private_network, ip: "#{SUBNET}.10#{i}"
osd.vm.network :private_network, ip: "#{SUBNET}.20#{i}"
osd.vm.provider :virtualbox do |vb|
(0..1).each do |d|
vb.customize ['createhd',
'--filename', "disk-#{i}-#{d}",
'--size', '11000']
vb.customize ['storageattach', :id,
'--storagectl', 'SATA',
'--port', 3 + d,
'--device', 0,
'--type', 'hdd',
'--medium', "disk-#{i}-#{d}.vdi"]
end
vb.customize ['modifyvm', :id, '--memory', '512']
end
osd.vm.provider :vmware_fusion do |v|
(0..1).each do |d|
v.vmx["scsi0:#{d + 1}.present"] = 'TRUE'
v.vmx["scsi0:#{d + 1}.fileName"] =
create_vmdk("disk-#{i}-#{d}", '11000MB')
end
v.vmx['memsize'] = '192'
end
osd.vm.provision 'ansible', &ansible_provision if i == (OSDNO - 1)
end
end
end