2018-03-05 14:15:23 +01:00
|
|
|
# -*- mode: ruby -*-
|
|
|
|
# vi: set ft=ruby :
|
|
|
|
|
|
|
|
# Load ~/.VagrantFile if exist, permit local config provider
|
|
|
|
vagrantfile = File.join("#{Dir.home}", '.VagrantFile')
|
|
|
|
load File.expand_path(vagrantfile) if File.exists?(vagrantfile)
|
|
|
|
|
|
|
|
Vagrant.configure('2') do |config|
|
2020-04-18 10:40:28 +02:00
|
|
|
config.vm.synced_folder "./", "/vagrant", type: "rsync", rsync__exclude: [ '.vagrant', '.git', 'build' ]
|
2019-01-16 16:19:09 +01:00
|
|
|
config.ssh.shell="/bin/sh"
|
2018-03-05 14:15:23 +01:00
|
|
|
|
|
|
|
config.vm.provider :libvirt do |libvirt|
|
|
|
|
libvirt.storage :file, :size => '10G', :device => 'vdb'
|
|
|
|
end
|
|
|
|
|
2018-03-05 18:24:14 +01:00
|
|
|
$install = <<SCRIPT
|
|
|
|
ln -fs /vagrant/bkctld /usr/sbin/bkctld
|
2019-01-04 13:51:05 +01:00
|
|
|
ln -fs /vagrant/lib /usr/lib/bkctld
|
2018-03-05 18:24:14 +01:00
|
|
|
ln -fs /vagrant/tpl /usr/share/bkctld
|
|
|
|
ln -fs /vagrant/bash_completion /usr/share/bash-completion/completions/bkctld
|
|
|
|
ln -fs /vagrant/bkctld.conf /etc/default/bkctld
|
2019-01-08 11:26:42 +01:00
|
|
|
ln -fs /vagrant/bkctld.service /etc/systemd/system/bkctld.service && systemctl daemon-reload
|
2018-03-15 12:41:54 +01:00
|
|
|
mkdir -p /usr/lib/nagios/plugins/
|
2018-03-05 18:24:14 +01:00
|
|
|
SCRIPT
|
|
|
|
|
2018-03-05 15:29:08 +01:00
|
|
|
$deps = <<SCRIPT
|
2021-11-02 17:24:50 +01:00
|
|
|
DEBIAN_FRONTEND=noninteractive apt-get -yq install openssh-server btrfs-progs rsync lsb-base coreutils sed dash mount openssh-sftp-server libc6 bash-completion duc-nox cryptsetup bats
|
2018-03-05 15:29:08 +01:00
|
|
|
SCRIPT
|
|
|
|
|
2018-03-05 18:24:14 +01:00
|
|
|
$pre_part = <<SCRIPT
|
2022-03-22 15:33:00 +01:00
|
|
|
sed --follow-symlinks --in-place -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
|
|
|
|
sed --follow-symlinks --in-place -e 's/# fr_FR.UTF-8 UTF-8/fr_FR.UTF-8 UTF-8/' /etc/locale.gen && \
|
2020-04-03 10:23:45 +02:00
|
|
|
echo 'LANG="fr_FR.UTF-8"'>/etc/default/locale && \
|
|
|
|
dpkg-reconfigure --frontend=noninteractive locales && \
|
|
|
|
update-locale LANG=fr_FR.UTF-8
|
|
|
|
lsof | awk '/backup/ { print $2 }' | xargs --no-run-if-empty kill -9
|
2018-03-05 15:29:08 +01:00
|
|
|
grep -q /backup /proc/mounts && umount -R /backup
|
2018-03-05 18:24:14 +01:00
|
|
|
exit 0
|
|
|
|
SCRIPT
|
|
|
|
|
|
|
|
$post_part = <<SCRIPT
|
2018-03-05 15:29:08 +01:00
|
|
|
mkdir -p /backup
|
|
|
|
mount /dev/vdb /backup
|
|
|
|
SCRIPT
|
|
|
|
|
2018-03-05 18:24:14 +01:00
|
|
|
nodes = [
|
|
|
|
{ :version => "stretch", :fs => "btrfs" },
|
2020-04-11 08:54:01 +02:00
|
|
|
{ :version => "stretch", :fs => "ext4" },
|
|
|
|
{ :version => "buster", :fs => "btrfs" },
|
2021-11-02 15:22:08 +01:00
|
|
|
{ :version => "buster", :fs => "ext4" },
|
|
|
|
{ :version => "bullseye", :fs => "btrfs" },
|
|
|
|
{ :version => "bullseye", :fs => "ext4" }
|
2018-03-05 18:24:14 +01:00
|
|
|
]
|
2018-03-05 14:15:23 +01:00
|
|
|
|
2018-03-05 18:24:14 +01:00
|
|
|
nodes.each do |i|
|
|
|
|
config.vm.define "#{i[:version]}-#{i[:fs]}" do |node|
|
|
|
|
node.vm.hostname = "bkctld-#{i[:version]}-#{i[:fs]}"
|
|
|
|
node.vm.box = "debian/#{i[:version]}64"
|
|
|
|
config.vm.provision "deps", type: "shell", :inline => $deps
|
|
|
|
config.vm.provision "install", type: "shell", :inline => $install
|
|
|
|
config.vm.provision "pre_part", type: "shell", :inline => $pre_part
|
|
|
|
config.vm.provision "part", type: "shell", :inline => "mkfs.btrfs -f /dev/vdb" if "#{i[:fs]}" == "btrfs"
|
|
|
|
config.vm.provision "part", type: "shell", :inline => "mkfs.ext4 -q -F /dev/vdb" if "#{i[:fs]}" == "ext4"
|
|
|
|
config.vm.provision "post_part", type: "shell", :inline => $post_part
|
|
|
|
config.vm.provision "test", type: "shell", :inline => "bats /vagrant/test/*.bats"
|
|
|
|
end
|
2018-03-05 14:15:23 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|