2015-12-29 20:57:10 +02:00
|
|
|
Vagrant.configure(2) do |config|
|
|
|
|
config.vm.provider :virtualbox do |vb|
|
2017-10-22 19:11:03 +02:00
|
|
|
vb.memory = 4096
|
2015-12-29 20:57:10 +02:00
|
|
|
vb.cpus = 8
|
|
|
|
end
|
|
|
|
|
2018-06-06 21:52:28 +02:00
|
|
|
config.vm.box = "ubuntu/bionic64"
|
2018-07-21 23:02:42 +02:00
|
|
|
config.vm.box_version = "20180719.0.0"
|
2017-06-09 23:51:41 +02:00
|
|
|
|
2019-12-18 04:56:02 +02:00
|
|
|
# Increase disk size if the vagrant-disksize plugin is available
|
|
|
|
# To install the plugin: vagrant plugin install vagrant-disksize
|
2019-12-18 04:47:19 +02:00
|
|
|
if Vagrant.has_plugin?('vagrant-disksize')
|
|
|
|
config.disksize.size = '64GB'
|
|
|
|
end
|
2015-12-29 20:57:10 +02:00
|
|
|
|
|
|
|
config.vm.provider :virtualbox do |vb|
|
2016-10-03 15:15:29 +02:00
|
|
|
vb.name = "pgbackrest-test"
|
2015-12-29 20:57:10 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
# Provision the VM
|
|
|
|
config.vm.provision "shell", inline: <<-SHELL
|
2017-04-10 18:31:30 +02:00
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2016-10-03 15:15:29 +02:00
|
|
|
echo 'Build Begin' && date
|
|
|
|
|
2016-09-08 23:29:26 +02:00
|
|
|
# Suppress "dpkg-reconfigure: unable to re-open stdin: No file or directory" warning
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
|
2017-03-15 04:05:17 +02:00
|
|
|
# Assign a host name
|
|
|
|
sed -i 's/^127\.0\.0\.1\t.*/127\.0\.0\.1\tlocalhost pgbackrest-test/' /etc/hosts
|
|
|
|
hostnamectl set-hostname pgbackrest-test
|
|
|
|
|
2017-04-10 18:31:30 +02:00
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2016-10-03 15:15:29 +02:00
|
|
|
echo 'Update Apt' && date
|
2016-05-26 20:03:32 +02:00
|
|
|
apt-get update
|
2016-10-03 15:15:29 +02:00
|
|
|
|
2017-04-10 18:31:30 +02:00
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
echo 'Synchronize Date' && date
|
2017-03-15 04:05:17 +02:00
|
|
|
apt-get install -y ntpdate
|
|
|
|
ntpdate pool.ntp.org
|
|
|
|
|
2017-07-26 19:40:09 +02:00
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
echo 'Use Google DNS' && date
|
|
|
|
echo 'supersede domain-name-servers 8.8.8.8;' >> /etc/dhcp/dhclient.conf
|
|
|
|
/etc/init.d/networking restart
|
|
|
|
|
2019-10-08 21:27:17 +02:00
|
|
|
# Set time sync settings so builds don't fail with clock skew errors. If a build does fail with "clock skew detected",
|
|
|
|
# rerun the following at the command line.
|
2017-11-02 14:14:13 +02:00
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2018-04-19 00:47:43 +02:00
|
|
|
echo 'Time Sync Settings' && date
|
2018-05-18 17:57:32 +02:00
|
|
|
sudo /etc/init.d/virtualbox-guest-utils stop
|
2018-06-26 22:56:05 +02:00
|
|
|
sudo /usr/sbin/VBoxService --timesync-set-on-restore --timesync-interval 5000 --timesync-set-threshold 1
|
2017-11-02 14:14:13 +02:00
|
|
|
|
2019-10-08 18:06:30 +02:00
|
|
|
# Create /tmp/pgbackrest and give ownership to root so we know unit tests are not writing there
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
echo 'Create /tmp/pgbackrest owned by root' && date
|
|
|
|
sudo mkdir -p /tmp/pgbackrest
|
|
|
|
sudo chown root:root /tmp/pgbackrest
|
|
|
|
sudo chmod 700 /tmp/pgbackrest
|
|
|
|
|
2018-11-02 14:37:27 +02:00
|
|
|
# Mount tmpfs at /home/vagrant/test for faster testing
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
echo 'Mount tmpfs' && date
|
|
|
|
sudo -u vagrant mkdir -p -m 770 /home/vagrant/test
|
|
|
|
echo 'tmpfs /home/vagrant/test tmpfs size=2560M 0 1' >> /etc/fstab
|
|
|
|
mount -a
|
|
|
|
|
2017-04-10 18:31:30 +02:00
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
echo 'Install Perl Modules' && date
|
2019-07-05 22:55:17 +02:00
|
|
|
apt-get install -y libdbd-pg-perl libxml-checker-perl libyaml-libyaml-perl
|
2017-04-10 18:31:30 +02:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
echo 'Install Build Tools' && date
|
2019-10-12 17:24:21 +02:00
|
|
|
apt-get install -y devscripts build-essential lintian git cloc txt2man debhelper libssl-dev zlib1g-dev libperl-dev \
|
2020-03-14 18:48:08 +02:00
|
|
|
libxml2-dev liblz4-dev liblz4-tool libpq-dev valgrind lcov autoconf-archive
|
2019-10-12 17:24:21 +02:00
|
|
|
|
2017-04-10 18:31:30 +02:00
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2016-10-03 15:15:29 +02:00
|
|
|
echo 'Install Docker' && date
|
2018-12-03 19:41:53 +02:00
|
|
|
curl -fsSL https://get.docker.com | sh
|
2018-02-04 01:27:38 +02:00
|
|
|
sudo usermod -aG docker vagrant
|
2016-05-26 20:03:32 +02:00
|
|
|
|
2017-04-10 18:31:30 +02:00
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
echo 'Install Dev Utilities' && date
|
2016-06-12 15:00:16 +02:00
|
|
|
apt-get install -y vim htop
|
|
|
|
|
2020-03-16 23:27:01 +02:00
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
echo '/tmp/pgbackrest owned by root so tests do not use it' && date
|
|
|
|
mkdir -p 700 /tmp/pgbackrest
|
|
|
|
|
2020-03-22 00:45:58 +02:00
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
echo 'create link to repo in old location to make the transition less painful' && date
|
|
|
|
ln -s /home/vagrant/pgbackrest /backrest
|
|
|
|
|
2017-04-10 18:31:30 +02:00
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2019-10-08 18:06:30 +02:00
|
|
|
# echo 'Install TeX Live' && date
|
|
|
|
# Not installed by default since latex is only needed for releases and PDF development/testing
|
|
|
|
# apt-get install -y --no-install-recommends texlive-latex-base texlive-latex-extra texlive-fonts-recommended
|
|
|
|
# apt-get install -y texlive-font-utils
|
2016-06-12 15:00:16 +02:00
|
|
|
|
2017-04-10 18:31:30 +02:00
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2016-10-03 15:15:29 +02:00
|
|
|
echo 'Build VM Images' && date
|
2018-02-04 01:27:38 +02:00
|
|
|
sudo su - vagrant -c '/backrest/test/test.pl --vm-build'
|
2016-10-03 15:15:29 +02:00
|
|
|
|
2017-04-10 18:31:30 +02:00
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2016-10-03 15:15:29 +02:00
|
|
|
echo 'Build End' && date
|
2019-03-15 20:18:56 +02:00
|
|
|
|
|
|
|
# Useful commands
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
# Force remove all containers:
|
|
|
|
# docker rm -f $(docker ps -a -q)
|
2019-04-24 19:23:32 +02:00
|
|
|
# Force remove all images:
|
|
|
|
# docker rmi -f $(docker images -q)
|
2015-12-29 20:57:10 +02:00
|
|
|
SHELL
|
|
|
|
|
|
|
|
# Don't share the default vagrant folder
|
|
|
|
config.vm.synced_folder ".", "/vagrant", disabled: true
|
|
|
|
|
2020-03-22 00:45:58 +02:00
|
|
|
# Mount pgbackrest path for testing
|
|
|
|
config.vm.synced_folder "..", "/home/vagrant/pgbackrest"
|
2015-12-29 20:57:10 +02:00
|
|
|
end
|