2014-03-04 02:08:51 +08:00
|
|
|
# -*- mode: ruby -*-
|
|
|
|
# vi: set ft=ruby :
|
|
|
|
|
2015-02-24 07:07:15 +08:00
|
|
|
require 'yaml'
|
2014-11-05 23:40:36 +08:00
|
|
|
VAGRANTFILE_API_VERSION = '2'
|
2014-03-04 02:08:51 +08:00
|
|
|
|
2015-02-24 07:07:15 +08:00
|
|
|
config_file=File.expand_path(File.join(File.dirname(__FILE__), 'vagrant_variables.yml'))
|
|
|
|
settings=YAML.load_file(config_file)
|
|
|
|
|
2015-07-02 17:08:59 +08:00
|
|
|
NMONS = settings['mon_vms']
|
|
|
|
NOSDS = settings['osd_vms']
|
|
|
|
NMDSS = settings['mds_vms']
|
|
|
|
NRGWS = settings['rgw_vms']
|
|
|
|
CLIENTS = settings['client_vms']
|
|
|
|
SUBNET = settings['subnet']
|
|
|
|
BOX = settings['vagrant_box']
|
2015-04-28 01:01:02 +08:00
|
|
|
MEMORY = settings['memory']
|
2015-08-27 17:24:53 +08:00
|
|
|
STORAGECTL = settings['vagrant_storagectl']
|
2015-11-06 04:39:03 +08:00
|
|
|
ETH = settings['eth']
|
2014-05-11 09:52:26 +08:00
|
|
|
|
2014-11-05 23:40:36 +08:00
|
|
|
ansible_provision = proc do |ansible|
|
|
|
|
ansible.playbook = 'site.yml'
|
2014-05-11 09:52:26 +08:00
|
|
|
# Note: Can't do ranges like mon[0-2] in groups because
|
|
|
|
# these aren't supported by Vagrant, see
|
|
|
|
# https://github.com/mitchellh/vagrant/issues/3539
|
|
|
|
ansible.groups = {
|
2015-07-02 17:08:59 +08:00
|
|
|
'mons' => (0..NMONS - 1).map { |j| "mon#{j}" },
|
|
|
|
'restapis' => (0..NMONS - 1).map { |j| "mon#{j}" },
|
|
|
|
'osds' => (0..NOSDS - 1).map { |j| "osd#{j}" },
|
|
|
|
'mdss' => (0..NMDSS - 1).map { |j| "mds#{j}" },
|
|
|
|
'rgws' => (0..NRGWS - 1).map { |j| "rgw#{j}" },
|
|
|
|
'clients' => (0..CLIENTS - 1).map { |j| "client#{j}" }
|
2014-05-11 09:52:26 +08:00
|
|
|
}
|
|
|
|
|
2014-11-14 22:03:50 +08:00
|
|
|
# In a production deployment, these should be secret
|
2015-07-02 17:08:59 +08:00
|
|
|
ansible.extra_vars = {
|
2015-07-04 00:38:30 +08:00
|
|
|
ceph_stable: 'true',
|
|
|
|
journal_collocation: 'true',
|
2015-07-02 17:08:59 +08:00
|
|
|
fsid: '4a158d27-f750-41d5-9e7f-26ce4c9d2d45',
|
|
|
|
monitor_secret: 'AQAWqilTCDh7CBAAawXt6kyTgLFCxSvJhTEmuw==',
|
|
|
|
journal_size: 100,
|
2015-11-06 04:39:03 +08:00
|
|
|
monitor_interface: ETH,
|
2015-07-02 17:08:59 +08:00
|
|
|
cluster_network: "#{SUBNET}.0/24",
|
|
|
|
public_network: "#{SUBNET}.0/24",
|
2015-07-04 02:18:41 +08:00
|
|
|
devices: "[ '/dev/sdb', '/dev/sdc' ]",
|
2015-07-02 17:08:59 +08:00
|
|
|
}
|
2014-05-11 09:52:26 +08:00
|
|
|
ansible.limit = 'all'
|
|
|
|
end
|
|
|
|
|
2014-08-16 17:03:16 +08:00
|
|
|
def create_vmdk(name, size)
|
|
|
|
dir = Pathname.new(__FILE__).expand_path.dirname
|
|
|
|
path = File.join(dir, '.vagrant', name + '.vmdk')
|
2014-11-10 20:33:21 +08:00
|
|
|
`vmware-vdiskmanager -c -s #{size} -t 0 -a scsi #{path} \
|
|
|
|
2>&1 > /dev/null` unless File.exist?(path)
|
2014-08-16 17:03:16 +08:00
|
|
|
end
|
2014-03-04 02:08:51 +08:00
|
|
|
|
2014-08-16 17:03:16 +08:00
|
|
|
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
2015-03-30 17:45:22 +08:00
|
|
|
config.vm.box = BOX
|
2015-01-06 23:23:43 +08:00
|
|
|
config.ssh.insert_key = false # workaround for https://github.com/mitchellh/vagrant/issues/5048
|
2014-05-11 09:52:26 +08:00
|
|
|
|
2014-11-20 04:27:56 +08:00
|
|
|
(0..CLIENTS - 1).each do |i|
|
|
|
|
config.vm.define "client#{i}" do |client|
|
|
|
|
client.vm.hostname = "ceph-client#{i}"
|
|
|
|
client.vm.network :private_network, ip: "#{SUBNET}.4#{i}"
|
|
|
|
client.vm.provider :virtualbox do |vb|
|
2015-04-28 01:01:02 +08:00
|
|
|
vb.customize ['modifyvm', :id, '--memory', "#{MEMORY}"]
|
2014-11-20 04:27:56 +08:00
|
|
|
end
|
|
|
|
client.vm.provider :vmware_fusion do |v|
|
2015-04-28 01:01:02 +08:00
|
|
|
v.vmx['memsize'] = "#{MEMORY}"
|
2014-11-20 04:27:56 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-11-06 19:15:25 +08:00
|
|
|
(0..NRGWS - 1).each do |i|
|
2014-11-10 20:33:21 +08:00
|
|
|
config.vm.define "rgw#{i}" do |rgw|
|
|
|
|
rgw.vm.hostname = "ceph-rgw#{i}"
|
|
|
|
rgw.vm.network :private_network, ip: "#{SUBNET}.4#{i}"
|
|
|
|
rgw.vm.provider :virtualbox do |vb|
|
2015-04-28 01:01:02 +08:00
|
|
|
vb.customize ['modifyvm', :id, '--memory', "#{MEMORY}"]
|
2014-11-10 20:33:21 +08:00
|
|
|
end
|
|
|
|
rgw.vm.provider :vmware_fusion do |v|
|
2015-04-28 01:01:02 +08:00
|
|
|
v.vmx['memsize'] = "#{MEMORY}"
|
2014-11-10 20:33:21 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
(0..NMDSS - 1).each do |i|
|
|
|
|
config.vm.define "mds#{i}" do |rgw|
|
|
|
|
rgw.vm.hostname = "ceph-mds#{i}"
|
|
|
|
rgw.vm.network :private_network, ip: "#{SUBNET}.7#{i}"
|
2014-11-06 19:15:25 +08:00
|
|
|
rgw.vm.provider :virtualbox do |vb|
|
2015-04-28 01:01:02 +08:00
|
|
|
vb.customize ['modifyvm', :id, '--memory', "#{MEMORY}"]
|
2014-11-06 19:15:25 +08:00
|
|
|
end
|
|
|
|
rgw.vm.provider :vmware_fusion do |v|
|
2015-04-28 01:01:02 +08:00
|
|
|
v.vmx['memsize'] = "#{MEMORY}"
|
2014-11-06 19:15:25 +08:00
|
|
|
end
|
2014-08-16 17:03:16 +08:00
|
|
|
end
|
2014-03-06 20:54:37 +08:00
|
|
|
end
|
|
|
|
|
2014-11-05 23:40:36 +08:00
|
|
|
(0..NMONS - 1).each do |i|
|
2014-03-04 02:08:51 +08:00
|
|
|
config.vm.define "mon#{i}" do |mon|
|
|
|
|
mon.vm.hostname = "ceph-mon#{i}"
|
2014-11-10 20:33:21 +08:00
|
|
|
mon.vm.network :private_network, ip: "#{SUBNET}.1#{i}"
|
2014-03-14 17:47:06 +08:00
|
|
|
mon.vm.provider :virtualbox do |vb|
|
2015-04-28 01:01:02 +08:00
|
|
|
vb.customize ['modifyvm', :id, '--memory', "#{MEMORY}"]
|
2014-03-14 17:47:06 +08:00
|
|
|
end
|
2014-08-16 17:03:16 +08:00
|
|
|
mon.vm.provider :vmware_fusion do |v|
|
2015-04-28 01:01:02 +08:00
|
|
|
v.vmx['memsize'] = "#{MEMORY}"
|
2014-08-16 17:03:16 +08:00
|
|
|
end
|
2014-03-04 02:08:51 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-11-05 23:40:36 +08:00
|
|
|
(0..NOSDS - 1).each do |i|
|
2014-03-04 02:08:51 +08:00
|
|
|
config.vm.define "osd#{i}" do |osd|
|
|
|
|
osd.vm.hostname = "ceph-osd#{i}"
|
2014-11-10 20:33:21 +08:00
|
|
|
osd.vm.network :private_network, ip: "#{SUBNET}.10#{i}"
|
|
|
|
osd.vm.network :private_network, ip: "#{SUBNET}.20#{i}"
|
2014-08-16 17:03:16 +08:00
|
|
|
osd.vm.provider :virtualbox do |vb|
|
2014-09-03 06:08:06 +08:00
|
|
|
(0..1).each do |d|
|
2014-11-10 20:33:21 +08:00
|
|
|
vb.customize ['createhd',
|
|
|
|
'--filename', "disk-#{i}-#{d}",
|
|
|
|
'--size', '11000']
|
2015-01-20 01:20:01 +08:00
|
|
|
# Controller names are dependent on the VM being built.
|
|
|
|
# It is set when the base box is made in our case ubuntu/trusty64.
|
|
|
|
# Be careful while changing the box.
|
2014-11-10 20:33:21 +08:00
|
|
|
vb.customize ['storageattach', :id,
|
2015-08-27 17:24:53 +08:00
|
|
|
'--storagectl', STORAGECTL,
|
2014-11-10 20:33:21 +08:00
|
|
|
'--port', 3 + d,
|
|
|
|
'--device', 0,
|
|
|
|
'--type', 'hdd',
|
|
|
|
'--medium', "disk-#{i}-#{d}.vdi"]
|
2014-03-04 02:08:51 +08:00
|
|
|
end
|
2015-04-28 01:01:02 +08:00
|
|
|
vb.customize ['modifyvm', :id, '--memory', "#{MEMORY}"]
|
2014-08-16 17:03:16 +08:00
|
|
|
end
|
|
|
|
osd.vm.provider :vmware_fusion do |v|
|
2014-09-03 06:08:06 +08:00
|
|
|
(0..1).each do |d|
|
2014-11-05 23:40:36 +08:00
|
|
|
v.vmx["scsi0:#{d + 1}.present"] = 'TRUE'
|
2014-11-10 20:33:21 +08:00
|
|
|
v.vmx["scsi0:#{d + 1}.fileName"] =
|
|
|
|
create_vmdk("disk-#{i}-#{d}", '11000MB')
|
2014-08-16 17:03:16 +08:00
|
|
|
end
|
2015-04-28 01:01:02 +08:00
|
|
|
v.vmx['memsize'] = "#{MEMORY}"
|
2014-03-04 02:08:51 +08:00
|
|
|
end
|
2014-05-11 09:52:26 +08:00
|
|
|
|
|
|
|
# Run the provisioner after the last machine comes up
|
2014-11-05 23:40:36 +08:00
|
|
|
osd.vm.provision 'ansible', &ansible_provision if i == (NOSDS - 1)
|
2014-03-04 02:08:51 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|