]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/scripts/vagrant/Vagrantfile_vhost_vm
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / scripts / vagrant / Vagrantfile_vhost_vm
1 # -*- mode: ruby -*-
2 # vi: set ft=ruby :
3
4 Vagrant.configure(2) do |config|
5
6 # Pick the right distro and bootstrap, default is ubuntu1604
7 distro = ( ENV['SPDK_VAGRANT_DISTRO'] || "ubuntu16")
8 case distro
9 when "ubuntu16"
10 # See: https://app.vagrantup.com/puppetlabs/boxes/ubuntu-16.04-64-nocm
11 config.vm.box = "puppetlabs/ubuntu-16.04-64-nocm"
12 config.vm.box_version = "1.0.0"
13 when "ubuntu18"
14 # See: https://app.vagrantup.com/bento/boxes/ubuntu-18.04
15 config.vm.box = "bento/ubuntu-18.04"
16 config.vm.box_version = "201808.24.0"
17 when "fedora31"
18 # See: https://app.vagrantup.com/generic/boxes/fedora31
19 config.vm.box = "generic/fedora31"
20 config.vm.box_version = "2.0.6"
21 else
22 "Invalid argument #{distro}"
23 abort("Invalid argument!")
24 end
25 config.vm.box_check_update = false
26
27 # vagrant-cachier caches apt/yum etc to speed subsequent
28 # vagrant up
29 # to enable, run
30 # vagrant plugin install vagrant-cachier
31 #
32 if Vagrant.has_plugin?("vagrant-cachier")
33 config.cache.scope = :box
34 end
35
36 # use http proxy if avaiable
37 if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf")
38 config.proxy.http = ENV['http_proxy']
39 config.proxy.https = ENV['https_proxy']
40 config.proxy.no_proxy = "localhost,127.0.0.1"
41 end
42
43 vmcpu=(ENV['SPDK_VAGRANT_VMCPU'] || 2)
44 vmram=(ENV['SPDK_VAGRANT_VMRAM'] || 4096)
45 ssh_key_dir=(ENV['SPDK_VAGRANT_SSH_KEY'])
46 spdk_dir=(ENV['SPDK_DIR'] || "none")
47 install_deps=(ENV['INSTALL_DEPS'] || "false")
48
49 config.ssh.forward_agent = true
50 config.ssh.forward_x11 = true
51
52 # Change root passwd and allow root SSH
53 config.vm.provision "shell", inline: 'echo -e "root\nroot" | sudo passwd root'
54 config.vm.provision "shell", inline: 'sudo sh -c "echo \"PermitRootLogin yes\" >> /etc/ssh/sshd_config"'
55
56 # Use previously generated SSH keys for setting up a key pair
57 $ssh_key_gen_script = <<-SCRIPT
58 sudo mkdir -p /root/.ssh
59 cat /vagrant/ssh_keys/spdk_vhost_id_rsa.pub > /root/.ssh/authorized_keys
60 sudo chmod 644 /root/.ssh/authorized_keys
61 SCRIPT
62 config.vm.provision "shell", inline: $ssh_key_gen_script
63
64 # Install needed deps
65 $apt_script = <<-SCRIPT
66 sudo apt -y update
67 sudo DEBIAN_FRONTEND=noninteractive apt -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
68 sudo apt -y install -y fio sg3-utils bc
69 SCRIPT
70
71 $dnf_script = <<-SCRIPT
72 sudo dnf -y update
73 sudo dnf -y install fio sg3_utils bc
74 SCRIPT
75
76 $install_script = case distro
77 when "ubuntu16" then $apt_script
78 when "ubuntu18" then $apt_script
79 when "fedora31" then $dnf_script
80 else abort("#{distro} distribution is not supported yet")
81 end
82
83 config.vm.provision "shell", inline: $install_script
84
85 # Modify GRUB options
86 # console=ttyS0 earlyprintk=ttyS0 - reroute output to serial dev, so that QEMU can write output to file
87 # scsi_mod.use_blk_mq=1 - for multiqueue use
88 # net.ifnames=0 biosdevname=0 - do not rename NICs on boot. That way we ensure that addded NIC is always eth0.
89 # Reason for these options is that NIC can have different udev name during provisioning with Vagrant
90 # and then some other name while running SPDK tests which use Qemu without any hypervisor like vbox or libvirt
91 # so no corresponding configuration for this NIC name will be present in /etc.
92 config.vm.provision "shell", inline: 'sudo sed -ir s#GRUB_CMDLINE_LINUX=#GRUB_CMDLINE_LINUX=\"console=ttyS0\ earlyprintk=ttyS0\ scsi_mod.use_blk_mq=1\ net.ifnames=0\ biosdevname=0\"#g /etc/default/grub'
93 config.vm.provision "shell", inline: 'sudo sed -ir s#\"\"#\ #g /etc/default/grub'
94
95 update_grub_command = case distro
96 when "ubuntu16" then 'sudo update-grub'
97 when "ubuntu18" then 'sudo update-grub'
98 when "fedora31" then 'sudo grub2-mkconfig -o /boot/grub2/grub.cfg ; sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg'
99 else abort("#{distro} distribution is not supported yet")
100 end
101 config.vm.provision "shell", inline: update_grub_command
102
103 if distro.include? "ubuntu"
104 # TODO: Next 2 lines break any future ssh communication via "vagrant ssh"
105 # I'd be good to check NIC names in ifconfig and then sed them in /etc/network/interfaces to eht0, eht1, and so on
106 config.vm.provision "shell", inline: 'sudo sh -c "echo \"auto eth0\" >> /etc/network/interfaces"'
107 config.vm.provision "shell", inline: 'sudo sh -c "echo \"iface eth0 inet dhcp\" >> /etc/network/interfaces"'
108 end
109
110 if distro.include? "ubuntu18"
111 # This is to avoid annoying "Start job is running for wait for network to be configured" 2 minute timeout
112 # in case of not-so-perfect NIC and virtual network configuration for the VM
113 config.vm.provision "shell", inline: 'systemctl disable systemd-networkd-wait-online.service'
114 config.vm.provision "shell", inline: 'systemctl mask systemd-networkd-wait-online.service'
115 end
116
117 config.vm.provider "virtualbox" do |vb|
118 vb.customize ["modifyvm", :id, "--ioapic", "on"]
119 vb.memory = "#{vmram}"
120 vb.cpus = "#{vmcpu}"
121
122 #support for the SSE4.x instruction is required in some versions of VB.
123 vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.1", "1"]
124 vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.2", "1"]
125 end
126
127 if spdk_dir != "none"
128 config.vm.synced_folder "#{spdk_dir}", "/home/vagrant/spdk_repo/spdk", type: "rsync", rsync__auto: false
129 if install_deps.include? "true"
130 config.vm.provision "shell", inline: 'sudo /home/vagrant/spdk_repo/spdk/scripts/pkgdep.sh --all'
131 end
132 end
133
134 # Copy in the user's tools if they exists
135 if File.directory?(File.expand_path("~/vagrant_tools"))
136 config.vm.synced_folder "~/vagrant_tools", "/home/vagrant/tools", type: "rsync", rsync__auto: false
137 end
138 end