]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/cephadm/Vagrantfile
import 15.2.5
[ceph.git] / ceph / src / pybind / mgr / cephadm / Vagrantfile
CommitLineData
11fdf7f2 1# vi: set ft=ruby :
f6b5b4d7
TL
2#
3# In order to reduce the need of recreating all vagrant boxes everytime they
4# get dirty, snaptshot them and revert the snapshot of them instead.
5# Two helpful scripts to do this easily can be found here:
6# https://github.com/Devp00l/vagrant-helper-scripts
11fdf7f2 7
f6b5b4d7
TL
8require 'json'
9configFileName = 'vagrant.config.json'
10CONFIG = File.file?(configFileName) && JSON.parse(File.read(File.join(File.dirname(__FILE__), configFileName)))
11
12def getConfig(name, default)
13 down = name.downcase
14 up = name.upcase
15 CONFIG && CONFIG[down] ? CONFIG[down] : (ENV[up] ? ENV[up].to_i : default)
16end
17
18OSDS = getConfig('OSDS', 1)
19MGRS = getConfig('MGRS', 1)
20MONS = getConfig('MONS', 1)
21DISKS = getConfig('DISKS', 2)
22
23# Activate only for test purpose as it changes the output of each vagrant command link to get the ssh_config.
24# puts "Your setup:","OSDs: #{OSDS}","MGRs: #{MGRS}","MONs: #{MONS}","Disks per OSD: #{DISKS}"
11fdf7f2
TL
25
26Vagrant.configure("2") do |config|
27 config.vm.synced_folder ".", "/vagrant", disabled: true
28 config.vm.network "private_network", type: "dhcp"
f6b5b4d7 29 config.vm.box = "centos/8"
11fdf7f2 30
f6b5b4d7 31 (0..MONS - 1).each do |i|
11fdf7f2
TL
32 config.vm.define "mon#{i}" do |mon|
33 mon.vm.hostname = "mon#{i}"
34 end
f6b5b4d7
TL
35 end
36 (0..MGRS - 1).each do |i|
11fdf7f2
TL
37 config.vm.define "mgr#{i}" do |mgr|
38 mgr.vm.hostname = "mgr#{i}"
39 end
f6b5b4d7
TL
40 end
41 (0..OSDS - 1).each do |i|
11fdf7f2
TL
42 config.vm.define "osd#{i}" do |osd|
43 osd.vm.hostname = "osd#{i}"
44 osd.vm.provider :libvirt do |libvirt|
f6b5b4d7
TL
45 (0..DISKS - 1).each do |d|
46 # In ruby value.chr makes ASCII char from value
47 libvirt.storage :file, :size => '20G', :device => "vd#{(98+d).chr}#{i}"
48 end
11fdf7f2
TL
49 end
50 end
51 end
52
9f95a23c
TL
53 config.vm.provision "file", source: "~/.ssh/id_rsa.pub", destination: "~/.ssh/id_rsa.pub"
54 config.vm.provision "shell", inline: <<-SHELL
55 cat /home/vagrant/.ssh/id_rsa.pub >> /home/vagrant/.ssh/authorized_keys
56 sudo cp -r /home/vagrant/.ssh /root/.ssh
57 SHELL
11fdf7f2
TL
58
59 config.vm.provision "shell", inline: <<-SHELL
60 sudo yum install -y yum-utils
f6b5b4d7 61 sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
11fdf7f2 62 sudo rpm --import 'https://download.ceph.com/keys/release.asc'
f6b5b4d7 63 curl -L https://shaman.ceph.com/api/repos/ceph/octopus/latest/centos/8/repo/ | sudo tee /etc/yum.repos.d/shaman.repo
9f95a23c 64 sudo yum install -y python36 podman ceph
11fdf7f2
TL
65 SHELL
66end