]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/cephadm/Vagrantfile
be1992a23ec989561dc5a99f24d77a5da7d69dc8
[ceph.git] / ceph / src / pybind / mgr / cephadm / Vagrantfile
1 # vi: set ft=ruby :
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
7
8 require 'json'
9 configFileName = 'vagrant.config.json'
10 CONFIG = File.file?(configFileName) && JSON.parse(File.read(File.join(File.dirname(__FILE__), configFileName)))
11
12 def getConfig(name, default)
13 down = name.downcase
14 up = name.upcase
15 CONFIG && CONFIG[down] ? CONFIG[down] : (ENV[up] ? ENV[up].to_i : default)
16 end
17
18 OSDS = getConfig('OSDS', 1)
19 MGRS = getConfig('MGRS', 1)
20 MONS = getConfig('MONS', 1)
21 DISKS = 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}"
25
26 Vagrant.configure("2") do |config|
27 config.vm.synced_folder ".", "/vagrant", disabled: true
28 config.vm.network "private_network", type: "dhcp"
29 config.vm.box = "centos/8"
30
31 (0..MONS - 1).each do |i|
32 config.vm.define "mon#{i}" do |mon|
33 mon.vm.hostname = "mon#{i}"
34 end
35 end
36 (0..MGRS - 1).each do |i|
37 config.vm.define "mgr#{i}" do |mgr|
38 mgr.vm.hostname = "mgr#{i}"
39 end
40 end
41 (0..OSDS - 1).each do |i|
42 config.vm.define "osd#{i}" do |osd|
43 osd.vm.hostname = "osd#{i}"
44 osd.vm.provider :libvirt do |libvirt|
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
49 end
50 end
51 end
52
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
58
59 config.vm.provision "shell", inline: <<-SHELL
60 sudo yum install -y yum-utils
61 sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
62 sudo rpm --import 'https://download.ceph.com/keys/release.asc'
63 curl -L https://shaman.ceph.com/api/repos/ceph/octopus/latest/centos/8/repo/ | sudo tee /etc/yum.repos.d/shaman.repo
64 sudo yum install -y python36 podman ceph
65 SHELL
66 end