2014-03-04 02:08:51 +08:00
|
|
|
# -*- mode: ruby -*-
|
|
|
|
# vi: set ft=ruby :
|
|
|
|
|
2015-02-24 07:07:15 +08:00
|
|
|
require 'yaml'
|
2023-06-07 23:10:52 +08:00
|
|
|
require 'resolv'
|
2014-11-05 23:40:36 +08:00
|
|
|
VAGRANTFILE_API_VERSION = '2'
|
2014-03-04 02:08:51 +08:00
|
|
|
|
2021-08-10 22:11:37 +08:00
|
|
|
if File.file?(File.join(File.dirname(__FILE__), 'vagrant_variables.yml')) then
|
|
|
|
vagrant_variables_file = 'vagrant_variables.yml'
|
|
|
|
else
|
|
|
|
vagrant_variables_file = 'vagrant_variables.yml.sample'
|
|
|
|
end
|
|
|
|
|
|
|
|
config_file=File.expand_path(File.join(File.dirname(__FILE__), vagrant_variables_file))
|
2019-10-02 16:14:52 +08:00
|
|
|
|
2015-02-24 07:07:15 +08:00
|
|
|
settings=YAML.load_file(config_file)
|
|
|
|
|
2017-03-28 18:00:32 +08:00
|
|
|
LABEL_PREFIX = settings['label_prefix'] ? settings['label_prefix'] + "-" : ""
|
|
|
|
NMONS = settings['mon_vms']
|
|
|
|
NOSDS = settings['osd_vms']
|
|
|
|
NMDSS = settings['mds_vms']
|
|
|
|
NRGWS = settings['rgw_vms']
|
|
|
|
NRBD_MIRRORS = settings['rbd_mirror_vms']
|
|
|
|
CLIENTS = settings['client_vms']
|
2017-03-16 17:17:08 +08:00
|
|
|
MGRS = settings['mgr_vms']
|
2017-03-28 18:00:32 +08:00
|
|
|
PUBLIC_SUBNET = settings['public_subnet']
|
|
|
|
CLUSTER_SUBNET = settings['cluster_subnet']
|
2018-12-14 17:45:04 +08:00
|
|
|
BOX = ENV['CEPH_ANSIBLE_VAGRANT_BOX'] || settings['vagrant_box']
|
2019-01-30 21:16:19 +08:00
|
|
|
CLIENT_BOX = ENV['CEPH_ANSIBLE_VAGRANT_BOX'] || settings['client_vagrant_box'] || BOX
|
|
|
|
BOX_URL = ENV['CEPH_ANSIBLE_VAGRANT_BOX_URL'] || settings['vagrant_box_url']
|
2017-03-28 18:00:32 +08:00
|
|
|
SYNC_DIR = settings['vagrant_sync_dir']
|
|
|
|
MEMORY = settings['memory']
|
|
|
|
ETH = settings['eth']
|
|
|
|
DOCKER = settings['docker']
|
|
|
|
USER = settings['ssh_username']
|
|
|
|
DEBUG = settings['debug']
|
2014-05-11 09:52:26 +08:00
|
|
|
|
2016-09-20 05:40:27 +08:00
|
|
|
ASSIGN_STATIC_IP = !(BOX == 'openstack' or BOX == 'linode')
|
2016-11-15 02:25:26 +08:00
|
|
|
DISABLE_SYNCED_FOLDER = settings.fetch('vagrant_disable_synced_folder', false)
|
2016-09-20 05:40:27 +08:00
|
|
|
|
2023-06-07 23:10:52 +08:00
|
|
|
"#{PUBLIC_SUBNET}" =~ Resolv::IPv6::Regex ? IPV6 = true : IPV6 = false
|
|
|
|
|
2019-10-02 16:14:52 +08:00
|
|
|
$last_ip_pub_digit = 9
|
|
|
|
$last_ip_cluster_digit = 9
|
2016-11-19 00:44:09 +08:00
|
|
|
|
2014-11-05 23:40:36 +08:00
|
|
|
ansible_provision = proc do |ansible|
|
2016-02-08 05:30:32 +08:00
|
|
|
if DOCKER then
|
2020-03-31 20:08:30 +08:00
|
|
|
ansible.playbook = 'site-container.yml'
|
2016-01-26 03:28:10 +08:00
|
|
|
if settings['skip_tags']
|
|
|
|
ansible.skip_tags = settings['skip_tags']
|
|
|
|
end
|
2016-02-08 05:30:32 +08:00
|
|
|
else
|
|
|
|
ansible.playbook = 'site.yml'
|
|
|
|
end
|
|
|
|
|
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 = {
|
2017-08-05 02:18:11 +08:00
|
|
|
'mons' => (0..NMONS - 1).map { |j| "#{LABEL_PREFIX}mon#{j}" },
|
|
|
|
'osds' => (0..NOSDS - 1).map { |j| "#{LABEL_PREFIX}osd#{j}" },
|
|
|
|
'mdss' => (0..NMDSS - 1).map { |j| "#{LABEL_PREFIX}mds#{j}" },
|
|
|
|
'rgws' => (0..NRGWS - 1).map { |j| "#{LABEL_PREFIX}rgw#{j}" },
|
|
|
|
'rbd_mirrors' => (0..NRBD_MIRRORS - 1).map { |j| "#{LABEL_PREFIX}rbd_mirror#{j}" },
|
|
|
|
'clients' => (0..CLIENTS - 1).map { |j| "#{LABEL_PREFIX}client#{j}" },
|
2019-05-23 22:21:08 +08:00
|
|
|
'mgrs' => (0..MGRS - 1).map { |j| "#{LABEL_PREFIX}mgr#{j}" },
|
2014-05-11 09:52:26 +08:00
|
|
|
}
|
|
|
|
|
2023-06-07 23:10:52 +08:00
|
|
|
if IPV6 then
|
|
|
|
ansible.extra_vars = {
|
|
|
|
cluster_network: "#{CLUSTER_SUBNET}/64",
|
|
|
|
journal_size: 100,
|
|
|
|
public_network: "#{PUBLIC_SUBNET}/64",
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ansible.extra_vars = {
|
|
|
|
cluster_network: "#{CLUSTER_SUBNET}.0/24",
|
|
|
|
journal_size: 100,
|
|
|
|
public_network: "#{PUBLIC_SUBNET}.0/24",
|
|
|
|
}
|
|
|
|
end
|
2016-04-29 22:07:10 +08:00
|
|
|
|
2014-11-14 22:03:50 +08:00
|
|
|
# In a production deployment, these should be secret
|
2016-02-08 05:30:32 +08:00
|
|
|
if DOCKER then
|
2016-09-20 05:40:27 +08:00
|
|
|
ansible.extra_vars = ansible.extra_vars.merge({
|
2017-04-13 01:57:33 +08:00
|
|
|
containerized_deployment: 'true',
|
2023-06-07 23:10:52 +08:00
|
|
|
ceph_mon_docker_subnet: ansible.extra_vars[:public_network],
|
2016-12-09 15:14:18 +08:00
|
|
|
devices: settings['disks'],
|
2017-08-07 17:23:32 +08:00
|
|
|
radosgw_interface: ETH,
|
2016-08-23 23:24:40 +08:00
|
|
|
generate_fsid: 'true',
|
2016-09-20 05:40:27 +08:00
|
|
|
})
|
2016-02-08 05:30:32 +08:00
|
|
|
else
|
2016-09-20 05:40:27 +08:00
|
|
|
ansible.extra_vars = ansible.extra_vars.merge({
|
|
|
|
devices: settings['disks'],
|
2017-08-07 17:23:32 +08:00
|
|
|
radosgw_interface: ETH,
|
2016-09-20 05:40:27 +08:00
|
|
|
os_tuning_params: settings['os_tuning_params'],
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
if BOX == 'linode' then
|
|
|
|
ansible.sudo = true
|
2017-08-07 17:23:32 +08:00
|
|
|
# Use radosgw_address_block instead of radosgw_interface:
|
|
|
|
ansible.extra_vars.delete(:radosgw_interface)
|
2016-09-20 05:40:27 +08:00
|
|
|
ansible.extra_vars = ansible.extra_vars.merge({
|
2016-10-07 14:04:53 +08:00
|
|
|
cluster_network: "#{CLUSTER_SUBNET}.0/16",
|
2016-09-20 05:40:27 +08:00
|
|
|
devices: ['/dev/sdc'], # hardcode leftover disk
|
2016-10-07 14:04:53 +08:00
|
|
|
monitor_address_block: "#{PUBLIC_SUBNET}.0/16",
|
2017-08-07 17:23:32 +08:00
|
|
|
radosgw_address_block: "#{PUBLIC_SUBNET}.0/16",
|
2016-10-07 14:04:53 +08:00
|
|
|
public_network: "#{PUBLIC_SUBNET}.0/16",
|
2016-09-20 05:40:27 +08:00
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
if DEBUG then
|
2017-03-28 18:00:32 +08:00
|
|
|
ansible.verbose = '-vvvv'
|
2016-02-08 05:30:32 +08:00
|
|
|
end
|
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
|
2016-06-21 03:07:37 +08:00
|
|
|
config.vm.box_url = BOX_URL
|
2015-01-06 23:23:43 +08:00
|
|
|
config.ssh.insert_key = false # workaround for https://github.com/mitchellh/vagrant/issues/5048
|
2016-09-20 05:40:27 +08:00
|
|
|
config.ssh.private_key_path = settings['ssh_private_key_path']
|
|
|
|
config.ssh.username = USER
|
2014-05-11 09:52:26 +08:00
|
|
|
|
2017-05-24 02:55:29 +08:00
|
|
|
# When using libvirt, avoid errors like:
|
|
|
|
# "host doesn't support requested feature: CPUID.01H:EDX.ds [bit 21]"
|
|
|
|
config.vm.provider :libvirt do |lv|
|
|
|
|
lv.cpu_mode = 'host-passthrough'
|
2022-09-24 14:38:31 +08:00
|
|
|
lv.disk_driver :cache => 'unsafe'
|
2017-10-09 17:56:46 +08:00
|
|
|
lv.graphics_type = 'none'
|
2019-01-30 21:16:19 +08:00
|
|
|
lv.cpus = 2
|
2017-05-24 02:55:29 +08:00
|
|
|
end
|
|
|
|
|
2016-11-15 02:25:26 +08:00
|
|
|
# Faster bootup. Disables mounting the sync folder for libvirt and virtualbox
|
|
|
|
if DISABLE_SYNCED_FOLDER
|
|
|
|
config.vm.provider :virtualbox do |v,override|
|
|
|
|
override.vm.synced_folder '.', SYNC_DIR, disabled: true
|
|
|
|
end
|
|
|
|
config.vm.provider :libvirt do |v,override|
|
|
|
|
override.vm.synced_folder '.', SYNC_DIR, disabled: true
|
|
|
|
end
|
2015-12-03 06:59:52 +08:00
|
|
|
end
|
|
|
|
|
2016-01-26 03:28:10 +08:00
|
|
|
if BOX == 'openstack'
|
|
|
|
# OpenStack VMs
|
|
|
|
config.vm.provider :openstack do |os|
|
|
|
|
config.vm.synced_folder ".", "/home/#{USER}/vagrant", disabled: true
|
|
|
|
config.ssh.pty = true
|
|
|
|
os.openstack_auth_url = settings['os_openstack_auth_url']
|
|
|
|
os.username = settings['os_username']
|
|
|
|
os.password = settings['os_password']
|
|
|
|
os.tenant_name = settings['os_tenant_name']
|
|
|
|
os.region = settings['os_region']
|
|
|
|
os.flavor = settings['os_flavor']
|
|
|
|
os.image = settings['os_image']
|
|
|
|
os.keypair_name = settings['os_keypair_name']
|
|
|
|
os.security_groups = ['default']
|
2016-10-08 04:06:42 +08:00
|
|
|
|
2018-09-21 03:02:14 +08:00
|
|
|
if settings['os_networks'] then
|
2016-10-08 04:06:42 +08:00
|
|
|
os.networks = settings['os_networks']
|
|
|
|
end
|
|
|
|
|
2018-09-21 03:02:14 +08:00
|
|
|
if settings['os_floating_ip_pool'] then
|
2016-10-08 04:06:42 +08:00
|
|
|
os.floating_ip_pool = settings['os_floating_ip_pool']
|
|
|
|
end
|
|
|
|
|
2016-01-26 03:28:10 +08:00
|
|
|
config.vm.provision "shell", inline: "true", upload_path: "/home/#{USER}/vagrant-shell"
|
|
|
|
end
|
2016-09-20 05:40:27 +08:00
|
|
|
elsif BOX == 'linode'
|
|
|
|
config.vm.provider :linode do |provider, override|
|
|
|
|
provider.token = ENV['LINODE_API_KEY']
|
|
|
|
provider.distribution = settings['cloud_distribution'] # 'Ubuntu 16.04 LTS'
|
|
|
|
provider.datacenter = settings['cloud_datacenter']
|
|
|
|
provider.plan = MEMORY.to_s
|
|
|
|
provider.private_networking = true
|
|
|
|
# root install generally takes <1GB
|
|
|
|
provider.xvda_size = 4*1024
|
|
|
|
# add some swap as the Linode distros require it
|
|
|
|
provider.swap_size = 128
|
|
|
|
end
|
2016-01-26 03:28:10 +08:00
|
|
|
end
|
|
|
|
|
2019-10-02 16:14:52 +08:00
|
|
|
(0..NMONS - 1).each do |i|
|
|
|
|
config.vm.define "#{LABEL_PREFIX}mon#{i}" do |mon|
|
|
|
|
mon.vm.hostname = "#{LABEL_PREFIX}mon#{i}"
|
2023-06-07 23:10:52 +08:00
|
|
|
if ASSIGN_STATIC_IP && !IPV6
|
|
|
|
mon.vm.network :private_network,
|
|
|
|
:ip => "#{PUBLIC_SUBNET}.#{$last_ip_pub_digit+=1}"
|
2019-10-02 16:14:52 +08:00
|
|
|
end
|
2023-06-07 23:10:52 +08:00
|
|
|
|
2019-10-02 16:14:52 +08:00
|
|
|
# Virtualbox
|
2023-06-07 23:10:52 +08:00
|
|
|
mon.vm.provider :virtualbox do |vb,override|
|
2019-10-02 16:14:52 +08:00
|
|
|
vb.customize ['modifyvm', :id, '--memory', "#{MEMORY}"]
|
|
|
|
end
|
|
|
|
|
|
|
|
# VMware
|
|
|
|
mon.vm.provider :vmware_fusion do |v|
|
|
|
|
v.vmx['memsize'] = "#{MEMORY}"
|
|
|
|
end
|
|
|
|
|
|
|
|
# Libvirt
|
2023-06-07 23:10:52 +08:00
|
|
|
mon.vm.provider :libvirt do |lv,override|
|
2019-10-02 16:14:52 +08:00
|
|
|
lv.memory = MEMORY
|
|
|
|
lv.random_hostname = true
|
2023-06-07 23:10:52 +08:00
|
|
|
if IPV6 then
|
|
|
|
override.vm.network :private_network,
|
|
|
|
:libvirt__ipv6_address => "#{PUBLIC_SUBNET}",
|
|
|
|
:libvirt__ipv6_prefix => "64",
|
|
|
|
:libvirt__dhcp_enabled => false,
|
|
|
|
:libvirt__forward_mode => "veryisolated",
|
|
|
|
:libvirt__network_name => "ipv6-public-network",
|
|
|
|
:ip => "#{PUBLIC_SUBNET}#{$last_ip_pub_digit+=1}",
|
|
|
|
:netmask => "64"
|
|
|
|
end
|
2019-10-02 16:14:52 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
# Parallels
|
|
|
|
mon.vm.provider "parallels" do |prl|
|
|
|
|
prl.name = "ceph-mon#{i}"
|
|
|
|
prl.memory = "#{MEMORY}"
|
|
|
|
end
|
|
|
|
|
|
|
|
mon.vm.provider :linode do |provider|
|
|
|
|
provider.label = mon.vm.hostname
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-03-16 17:17:08 +08:00
|
|
|
(0..MGRS - 1).each do |i|
|
|
|
|
config.vm.define "#{LABEL_PREFIX}mgr#{i}" do |mgr|
|
2017-08-31 06:07:28 +08:00
|
|
|
mgr.vm.hostname = "#{LABEL_PREFIX}mgr#{i}"
|
2023-06-07 23:10:52 +08:00
|
|
|
if ASSIGN_STATIC_IP && !IPV6
|
|
|
|
mgr.vm.network :private_network,
|
|
|
|
:ip => "#{PUBLIC_SUBNET}.#{$last_ip_pub_digit+=1}"
|
2017-03-16 17:17:08 +08:00
|
|
|
end
|
|
|
|
# Virtualbox
|
|
|
|
mgr.vm.provider :virtualbox do |vb|
|
|
|
|
vb.customize ['modifyvm', :id, '--memory', "#{MEMORY}"]
|
|
|
|
end
|
|
|
|
|
|
|
|
# VMware
|
|
|
|
mgr.vm.provider :vmware_fusion do |v|
|
|
|
|
v.vmx['memsize'] = "#{MEMORY}"
|
|
|
|
end
|
|
|
|
|
|
|
|
# Libvirt
|
2023-06-07 23:10:52 +08:00
|
|
|
mgr.vm.provider :libvirt do |lv,override|
|
2017-03-16 17:17:08 +08:00
|
|
|
lv.memory = MEMORY
|
|
|
|
lv.random_hostname = true
|
2023-06-07 23:10:52 +08:00
|
|
|
if IPV6 then
|
|
|
|
override.vm.network :private_network,
|
|
|
|
:libvirt__ipv6_address => "#{PUBLIC_SUBNET}",
|
|
|
|
:libvirt__ipv6_prefix => "64",
|
|
|
|
:libvirt__dhcp_enabled => false,
|
|
|
|
:libvirt__forward_mode => "veryisolated",
|
|
|
|
:libvirt__network_name => "ipv6-public-network",
|
|
|
|
:ip => "#{PUBLIC_SUBNET}#{$last_ip_pub_digit+=1}",
|
|
|
|
:netmask => "64"
|
|
|
|
end
|
2017-03-16 17:17:08 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
# Parallels
|
|
|
|
mgr.vm.provider "parallels" do |prl|
|
|
|
|
prl.name = "ceph-mgr#{i}"
|
|
|
|
prl.memory = "#{MEMORY}"
|
|
|
|
end
|
|
|
|
|
|
|
|
mgr.vm.provider :linode do |provider|
|
|
|
|
provider.label = mgr.vm.hostname
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-11-20 04:27:56 +08:00
|
|
|
(0..CLIENTS - 1).each do |i|
|
2016-09-20 05:40:27 +08:00
|
|
|
config.vm.define "#{LABEL_PREFIX}client#{i}" do |client|
|
2017-07-17 23:11:32 +08:00
|
|
|
client.vm.box = CLIENT_BOX
|
2017-08-31 06:07:28 +08:00
|
|
|
client.vm.hostname = "#{LABEL_PREFIX}client#{i}"
|
2023-06-07 23:10:52 +08:00
|
|
|
if ASSIGN_STATIC_IP && !IPV6
|
|
|
|
client.vm.network :private_network,
|
|
|
|
:ip => "#{PUBLIC_SUBNET}.#{$last_ip_pub_digit+=1}"
|
2016-01-26 03:28:10 +08:00
|
|
|
end
|
2015-12-03 06:59:52 +08:00
|
|
|
# Virtualbox
|
2014-11-20 04:27:56 +08:00
|
|
|
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
|
2015-12-03 06:59:52 +08:00
|
|
|
|
|
|
|
# VMware
|
2014-11-20 04:27:56 +08:00
|
|
|
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
|
2015-12-03 06:59:52 +08:00
|
|
|
|
|
|
|
# Libvirt
|
2023-06-07 23:10:52 +08:00
|
|
|
client.vm.provider :libvirt do |lv,override|
|
2015-12-03 06:59:52 +08:00
|
|
|
lv.memory = MEMORY
|
2016-11-18 05:25:06 +08:00
|
|
|
lv.random_hostname = true
|
2023-06-07 23:10:52 +08:00
|
|
|
if IPV6 then
|
|
|
|
override.vm.network :private_network,
|
|
|
|
:libvirt__ipv6_address => "#{PUBLIC_SUBNET}",
|
|
|
|
:libvirt__ipv6_prefix => "64",
|
|
|
|
:libvirt__dhcp_enabled => false,
|
|
|
|
:libvirt__forward_mode => "veryisolated",
|
|
|
|
:libvirt__network_name => "ipv6-public-network",
|
|
|
|
:ip => "#{PUBLIC_SUBNET}#{$last_ip_pub_digit+=1}",
|
|
|
|
:netmask => "64"
|
|
|
|
end
|
2015-12-03 06:59:52 +08:00
|
|
|
end
|
2016-02-18 19:58:33 +08:00
|
|
|
|
|
|
|
# Parallels
|
|
|
|
client.vm.provider "parallels" do |prl|
|
|
|
|
prl.name = "ceph-client#{i}"
|
|
|
|
prl.memory = "#{MEMORY}"
|
|
|
|
end
|
2016-09-20 05:40:27 +08:00
|
|
|
|
|
|
|
client.vm.provider :linode do |provider|
|
|
|
|
provider.label = client.vm.hostname
|
|
|
|
end
|
2014-11-20 04:27:56 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-11-06 19:15:25 +08:00
|
|
|
(0..NRGWS - 1).each do |i|
|
2016-09-20 05:40:27 +08:00
|
|
|
config.vm.define "#{LABEL_PREFIX}rgw#{i}" do |rgw|
|
2017-08-31 06:07:28 +08:00
|
|
|
rgw.vm.hostname = "#{LABEL_PREFIX}rgw#{i}"
|
2023-06-07 23:10:52 +08:00
|
|
|
if ASSIGN_STATIC_IP && !IPV6
|
|
|
|
rgw.vm.network :private_network,
|
|
|
|
:ip => "#{PUBLIC_SUBNET}.#{$last_ip_pub_digit+=1}"
|
2016-01-26 03:28:10 +08:00
|
|
|
end
|
2015-12-03 06:59:52 +08:00
|
|
|
|
|
|
|
# Virtualbox
|
2014-11-10 20:33:21 +08:00
|
|
|
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
|
2015-12-03 06:59:52 +08:00
|
|
|
|
|
|
|
# VMware
|
2014-11-10 20:33:21 +08:00
|
|
|
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
|
2015-12-03 06:59:52 +08:00
|
|
|
|
|
|
|
# Libvirt
|
2023-06-07 23:10:52 +08:00
|
|
|
rgw.vm.provider :libvirt do |lv,override|
|
2015-12-03 06:59:52 +08:00
|
|
|
lv.memory = MEMORY
|
2016-11-18 05:25:06 +08:00
|
|
|
lv.random_hostname = true
|
2023-06-07 23:10:52 +08:00
|
|
|
if IPV6 then
|
|
|
|
override.vm.network :private_network,
|
|
|
|
:libvirt__ipv6_address => "#{PUBLIC_SUBNET}",
|
|
|
|
:libvirt__ipv6_prefix => "64",
|
|
|
|
:libvirt__dhcp_enabled => false,
|
|
|
|
:libvirt__forward_mode => "veryisolated",
|
|
|
|
:libvirt__network_name => "ipv6-public-network",
|
|
|
|
:ip => "#{PUBLIC_SUBNET}#{$last_ip_pub_digit+=1}",
|
|
|
|
:netmask => "64"
|
|
|
|
end
|
2015-12-03 06:59:52 +08:00
|
|
|
end
|
2016-02-18 19:58:33 +08:00
|
|
|
|
|
|
|
# Parallels
|
|
|
|
rgw.vm.provider "parallels" do |prl|
|
|
|
|
prl.name = "ceph-rgw#{i}"
|
|
|
|
prl.memory = "#{MEMORY}"
|
|
|
|
end
|
2016-09-20 05:40:27 +08:00
|
|
|
|
|
|
|
rgw.vm.provider :linode do |provider|
|
|
|
|
provider.label = rgw.vm.hostname
|
|
|
|
end
|
2014-11-10 20:33:21 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
(0..NMDSS - 1).each do |i|
|
2016-09-20 05:40:27 +08:00
|
|
|
config.vm.define "#{LABEL_PREFIX}mds#{i}" do |mds|
|
2017-08-31 06:07:28 +08:00
|
|
|
mds.vm.hostname = "#{LABEL_PREFIX}mds#{i}"
|
2023-06-07 23:10:52 +08:00
|
|
|
if ASSIGN_STATIC_IP && !IPV6
|
|
|
|
mds.vm.network :private_network,
|
|
|
|
:ip => "#{PUBLIC_SUBNET}.#{$last_ip_pub_digit+=1}"
|
2016-01-26 03:28:10 +08:00
|
|
|
end
|
2015-12-03 06:59:52 +08:00
|
|
|
# Virtualbox
|
|
|
|
mds.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
|
2015-12-03 06:59:52 +08:00
|
|
|
|
|
|
|
# VMware
|
|
|
|
mds.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
|
2015-12-03 06:59:52 +08:00
|
|
|
|
|
|
|
# Libvirt
|
2023-06-07 23:10:52 +08:00
|
|
|
mds.vm.provider :libvirt do |lv,override|
|
2015-12-03 06:59:52 +08:00
|
|
|
lv.memory = MEMORY
|
2016-11-18 05:25:06 +08:00
|
|
|
lv.random_hostname = true
|
2023-06-07 23:10:52 +08:00
|
|
|
if IPV6 then
|
|
|
|
override.vm.network :private_network,
|
|
|
|
:libvirt__ipv6_address => "#{PUBLIC_SUBNET}",
|
|
|
|
:libvirt__ipv6_prefix => "64",
|
|
|
|
:libvirt__dhcp_enabled => false,
|
|
|
|
:libvirt__forward_mode => "veryisolated",
|
|
|
|
:libvirt__network_name => "ipv6-public-network",
|
|
|
|
:ip => "#{PUBLIC_SUBNET}#{$last_ip_pub_digit+=1}",
|
|
|
|
:netmask => "64"
|
|
|
|
end
|
2015-12-03 06:59:52 +08:00
|
|
|
end
|
2016-02-18 19:58:33 +08:00
|
|
|
# Parallels
|
|
|
|
mds.vm.provider "parallels" do |prl|
|
|
|
|
prl.name = "ceph-mds#{i}"
|
|
|
|
prl.memory = "#{MEMORY}"
|
|
|
|
end
|
2016-09-20 05:40:27 +08:00
|
|
|
|
|
|
|
mds.vm.provider :linode do |provider|
|
|
|
|
provider.label = mds.vm.hostname
|
|
|
|
end
|
2014-08-16 17:03:16 +08:00
|
|
|
end
|
2014-03-06 20:54:37 +08:00
|
|
|
end
|
|
|
|
|
2016-07-12 18:15:22 +08:00
|
|
|
(0..NRBD_MIRRORS - 1).each do |i|
|
2017-09-08 15:51:03 +08:00
|
|
|
config.vm.define "#{LABEL_PREFIX}rbd-mirror#{i}" do |rbd_mirror|
|
2017-08-31 06:07:28 +08:00
|
|
|
rbd_mirror.vm.hostname = "#{LABEL_PREFIX}rbd-mirror#{i}"
|
2023-06-07 23:10:52 +08:00
|
|
|
if ASSIGN_STATIC_IP && !IPV6
|
|
|
|
rbd_mirror.vm.network :private_network,
|
|
|
|
:ip => "#{PUBLIC_SUBNET}.#{$last_ip_pub_digit+=1}"
|
2016-07-12 18:15:22 +08:00
|
|
|
end
|
|
|
|
# Virtualbox
|
|
|
|
rbd_mirror.vm.provider :virtualbox do |vb|
|
|
|
|
vb.customize ['modifyvm', :id, '--memory', "#{MEMORY}"]
|
|
|
|
end
|
|
|
|
|
|
|
|
# VMware
|
|
|
|
rbd_mirror.vm.provider :vmware_fusion do |v|
|
|
|
|
v.vmx['memsize'] = "#{MEMORY}"
|
|
|
|
end
|
|
|
|
|
|
|
|
# Libvirt
|
2023-06-07 23:10:52 +08:00
|
|
|
rbd_mirror.vm.provider :libvirt do |lv,override|
|
2016-07-12 18:15:22 +08:00
|
|
|
lv.memory = MEMORY
|
2016-11-18 05:25:06 +08:00
|
|
|
lv.random_hostname = true
|
2023-06-07 23:10:52 +08:00
|
|
|
if IPV6 then
|
|
|
|
override.vm.network :private_network,
|
|
|
|
:libvirt__ipv6_address => "#{PUBLIC_SUBNET}",
|
|
|
|
:libvirt__ipv6_prefix => "64",
|
|
|
|
:libvirt__dhcp_enabled => false,
|
|
|
|
:libvirt__forward_mode => "veryisolated",
|
|
|
|
:libvirt__network_name => "ipv6-public-network",
|
|
|
|
:ip => "#{PUBLIC_SUBNET}#{$last_ip_pub_digit+=1}",
|
|
|
|
:netmask => "64"
|
|
|
|
end
|
2016-07-12 18:15:22 +08:00
|
|
|
end
|
|
|
|
# Parallels
|
|
|
|
rbd_mirror.vm.provider "parallels" do |prl|
|
|
|
|
prl.name = "ceph-rbd-mirror#{i}"
|
|
|
|
prl.memory = "#{MEMORY}"
|
|
|
|
end
|
2016-09-20 05:40:27 +08:00
|
|
|
|
|
|
|
rbd_mirror.vm.provider :linode do |provider|
|
|
|
|
provider.label = rbd_mirror.vm.hostname
|
|
|
|
end
|
2016-07-12 18:15:22 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-11-05 23:40:36 +08:00
|
|
|
(0..NOSDS - 1).each do |i|
|
2016-09-20 05:40:27 +08:00
|
|
|
config.vm.define "#{LABEL_PREFIX}osd#{i}" do |osd|
|
2017-08-31 06:07:28 +08:00
|
|
|
osd.vm.hostname = "#{LABEL_PREFIX}osd#{i}"
|
2023-06-07 23:10:52 +08:00
|
|
|
if ASSIGN_STATIC_IP && !IPV6
|
|
|
|
osd.vm.network :private_network,
|
|
|
|
:ip => "#{PUBLIC_SUBNET}.#{$last_ip_pub_digit+=1}"
|
|
|
|
osd.vm.network :private_network,
|
|
|
|
:ip => "#{CLUSTER_SUBNET}.#{$last_ip_cluster_digit+=1}"
|
2016-01-26 03:28:10 +08:00
|
|
|
end
|
2015-12-03 06:59:52 +08:00
|
|
|
# Virtualbox
|
2014-08-16 17:03:16 +08:00
|
|
|
osd.vm.provider :virtualbox do |vb|
|
2016-10-10 11:55:53 +08:00
|
|
|
# Create our own controller for consistency and to remove VM dependency
|
2017-12-09 01:09:50 +08:00
|
|
|
unless File.exist?("disk-#{i}-0.vdi")
|
2018-03-08 00:26:24 +08:00
|
|
|
# Adding OSD Controller;
|
2017-12-09 01:09:50 +08:00
|
|
|
# once the first disk is there assuming we don't need to do this
|
|
|
|
vb.customize ['storagectl', :id,
|
|
|
|
'--name', 'OSD Controller',
|
|
|
|
'--add', 'scsi']
|
|
|
|
end
|
2018-03-08 00:26:24 +08:00
|
|
|
|
2019-01-11 03:06:17 +08:00
|
|
|
(0..2).each do |d|
|
2022-12-06 16:18:03 +08:00
|
|
|
unless File.exist?("disk-#{i}-#{d}.vdi")
|
2014-11-10 20:33:21 +08:00
|
|
|
vb.customize ['createhd',
|
|
|
|
'--filename', "disk-#{i}-#{d}",
|
2022-12-06 16:18:03 +08:00
|
|
|
'--size', '11000']
|
|
|
|
end
|
2014-11-10 20:33:21 +08:00
|
|
|
vb.customize ['storageattach', :id,
|
2016-10-10 11:55:53 +08:00
|
|
|
'--storagectl', 'OSD Controller',
|
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
|
2015-12-03 06:59:52 +08:00
|
|
|
|
|
|
|
# VMware
|
2014-08-16 17:03:16 +08:00
|
|
|
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
|
|
|
|
2015-12-03 06:59:52 +08:00
|
|
|
# Libvirt
|
2016-11-17 03:01:22 +08:00
|
|
|
driverletters = ('a'..'z').to_a
|
2023-06-07 23:10:52 +08:00
|
|
|
osd.vm.provider :libvirt do |lv,override|
|
2016-11-17 03:01:22 +08:00
|
|
|
# always make /dev/sd{a/b/c} so that CI can ensure that
|
|
|
|
# virtualbox and libvirt will have the same devices to use for OSDs
|
|
|
|
(0..2).each do |d|
|
2018-10-10 23:24:30 +08:00
|
|
|
lv.storage :file, :device => "hd#{driverletters[d]}", :size => '50G', :bus => "ide"
|
2015-12-03 06:59:52 +08:00
|
|
|
end
|
|
|
|
lv.memory = MEMORY
|
2016-11-18 05:25:06 +08:00
|
|
|
lv.random_hostname = true
|
2023-06-07 23:10:52 +08:00
|
|
|
if IPV6 then
|
|
|
|
override.vm.network :private_network,
|
|
|
|
:libvirt__ipv6_address => "#{PUBLIC_SUBNET}",
|
|
|
|
:libvirt__ipv6_prefix => "64",
|
|
|
|
:libvirt__dhcp_enabled => false,
|
|
|
|
:libvirt__forward_mode => "veryisolated",
|
|
|
|
:libvirt__network_name => "ipv6-public-network",
|
|
|
|
:netmask => "64"
|
|
|
|
override.vm.network :private_network,
|
|
|
|
:libvirt__ipv6_address => "#{CLUSTER_SUBNET}",
|
|
|
|
:libvirt__ipv6_prefix => "64",
|
|
|
|
:libvirt__dhcp_enabled => false,
|
|
|
|
:libvirt__forward_mode => "veryisolated",
|
|
|
|
:libvirt__network_name => "ipv6-cluster-network",
|
|
|
|
:netmask => "64"
|
|
|
|
end
|
2015-12-03 06:59:52 +08:00
|
|
|
end
|
|
|
|
|
2016-02-18 19:58:33 +08:00
|
|
|
# Parallels
|
|
|
|
osd.vm.provider "parallels" do |prl|
|
|
|
|
prl.name = "ceph-osd#{i}"
|
|
|
|
prl.memory = "#{MEMORY}"
|
|
|
|
(0..1).each do |d|
|
2016-01-26 03:28:10 +08:00
|
|
|
prl.customize ["set", :id,
|
|
|
|
"--device-add",
|
|
|
|
"hdd",
|
|
|
|
"--iface",
|
2016-02-18 19:58:33 +08:00
|
|
|
"sata"]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-09-20 05:40:27 +08:00
|
|
|
osd.vm.provider :linode do |provider|
|
|
|
|
provider.label = osd.vm.hostname
|
|
|
|
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
|