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
|
# vi: set ft=ruby :
#
# In order to reduce the need of recreating all vagrant boxes everytime they
# get dirty, snapshot them and revert the snapshot of them instead.
# Two helpful scripts to do this easily can be found here:
# https://github.com/Devp00l/vagrant-helper-scripts
require 'json'
configFileName = 'vagrant.config.json'
CONFIG = File.file?(configFileName) && JSON.parse(File.read(File.join(File.dirname(__FILE__), configFileName)))
def getConfig(name, default)
down = name.downcase
up = name.upcase
CONFIG && CONFIG[down] ? CONFIG[down] : (ENV[up] ? ENV[up].to_i : default)
end
OSDS = getConfig('OSDS', 1)
MGRS = getConfig('MGRS', 1)
MONS = getConfig('MONS', 1)
DISKS = getConfig('DISKS', 2)
# Activate only for test purpose as it changes the output of each vagrant command link to get the ssh_config.
# puts "Your setup:","OSDs: #{OSDS}","MGRs: #{MGRS}","MONs: #{MONS}","Disks per OSD: #{DISKS}"
Vagrant.configure("2") do |config|
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.network "private_network", type: "dhcp"
config.vm.box = "centos/stream8"
(0..MONS - 1).each do |i|
config.vm.define "mon#{i}" do |mon|
mon.vm.hostname = "mon#{i}"
end
end
(0..MGRS - 1).each do |i|
config.vm.define "mgr#{i}" do |mgr|
mgr.vm.hostname = "mgr#{i}"
end
end
(0..OSDS - 1).each do |i|
config.vm.define "osd#{i}" do |osd|
osd.vm.hostname = "osd#{i}"
osd.vm.provider :libvirt do |libvirt|
(0..DISKS - 1).each do |d|
# In ruby value.chr makes ASCII char from value
libvirt.storage :file, :size => '20G', :device => "vd#{(98+d).chr}#{i}"
end
end
end
end
config.vm.provision "file", source: "~/.ssh/id_rsa.pub", destination: "~/.ssh/id_rsa.pub"
config.vm.provision "shell", inline: <<-SHELL
cat /home/vagrant/.ssh/id_rsa.pub >> /home/vagrant/.ssh/authorized_keys
sudo cp -r /home/vagrant/.ssh /root/.ssh
SHELL
config.vm.provision "shell", inline: <<-SHELL
sudo yum install -y yum-utils
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo rpm --import 'https://download.ceph.com/keys/release.asc'
curl -L https://shaman.ceph.com/api/repos/ceph/main/latest/centos/8/repo/ | sudo tee /etc/yum.repos.d/shaman.repo
sudo yum install -y python36 podman cephadm libseccomp-devel
SHELL
end
|