1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
require 'yaml'
if File.file?('vagrant.yml') and ( custom = YAML.load_file('vagrant.yml') )
pgbackrest_git_url = custom['pgbackrest_git_url'] if custom.has_key?('pgbackrest_git_url')
pgbackrest_git_branch = custom['pgbackrest_git_branch'] if custom.has_key?('pgbackrest_git_branch')
end
Vagrant.configure(2) do |config|
config.vm.provider :virtualbox do |vb|
vb.memory = 4096
vb.cpus = 4
vb.name = "check_pgbackrest-docker-host"
end
config.vm.box = "bento/ubuntu-22.04"
config.ssh.insert_key = false
# mount check_pgbackrest path for development testing
config.vm.synced_folder "..", "/check_pgbackrest"
config.vm.provision "shell", inline: <<-SHELL
#-----------------------------------------------------------------------------------------------------------------------
echo 'Extend disk space' && date
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
#-----------------------------------------------------------------------------------------------------------------------
echo 'Use BE ubuntu mirrors' && date
sed -E -i 's#http://[^\s]*archive\.ubuntu\.com/ubuntu#http://be.archive.ubuntu.com/ubuntu#g' /etc/apt/sources.list
#-----------------------------------------------------------------------------------------------------------------------
echo 'Install Docker' && date
curl -fsSL https://get.docker.com | sh
usermod -aG docker vagrant
#-----------------------------------------------------------------------------------------------------------------------
echo 'Install Perl modules' && date
export DEBIAN_FRONTEND=noninteractive
apt-get install -y libyaml-libyaml-perl jq
SHELL
config.vm.provision "shell", privileged: false, inline: <<-SHELL
#-----------------------------------------------------------------------------------------------------------------------
echo 'Install Ansible' && date
export DEBIAN_FRONTEND=noninteractive
sudo -E apt-get install -y python3-pip python3-venv
python3 -m pip install --user pipx
python3 -m pipx ensurepath
python3 -m pipx install 'ansible-core<2.17' #ansible-core 2.16 is needed for RHEL8 compatibility
SHELL
# Execute CI script in Vagrant environment
config.vm.provision "exec-ci", privileged: false, type: "shell",
path: 'vagrant.sh',
env: {
"ACTIVITY" => ENV['ACTIVITY'],
"ARCH" => ENV['ARCH'],
"EXTRA" => ENV['EXTRA'],
"PGBR_BUILD" => ENV['PGBR_BUILD'],
"PGBR_REPO_TYPE" => ENV['PGBR_REPO_TYPE'],
"PROFILE" => ENV['PROFILE'],
"pgbackrest_git_url" => pgbackrest_git_url,
"pgbackrest_git_branch" => pgbackrest_git_branch
},
run: 'never'
# Clean a specific cluster in Vagrant environment
$clean_script = <<-SCRIPT
cd /vagrant
echo "PROFILE = '$PROFILE'"
source profile.d/$PROFILE.profile
source profile.d/vagrant.profile
sh run.sh -C -c "$CLPATH/$CLNAME"
SCRIPT
config.vm.provision "clean-ci", privileged: false, type: 'shell',
inline: $clean_script,
env: {
"PROFILE" => ENV['PROFILE']
},
run: 'never'
end
|