Skip to content

Commit 8261319

Browse files
committed
some more build improvements
1 parent 2829d9c commit 8261319

File tree

3 files changed

+189
-138
lines changed

3 files changed

+189
-138
lines changed

.github/workflows/vagrant-up.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
if: always()
4444

4545
- name: Run vagrant user.yml
46-
run: VAGRANT_DEFAULT_PROVIDER=virtualbox VAGRANT_LOG=debug vagrant --os=ubuntu/jammy64 --local --playbook=user.yml --headless up
46+
run: VAGRANT_DEFAULT_PROVIDER=virtualbox VAGRANT_LOG=debug ./bin/retry.sh vagrant --destroy-on-error --os=ubuntu/jammy64 --local --playbook=user.yml --headless up
4747

4848
- name: Destroy vagrant user.yml
4949
run: VAGRANT_DEFAULT_PROVIDER=virtualbox timeout -k 60 -s 9 60 vagrant destroy -f || true
@@ -63,7 +63,7 @@ jobs:
6363
if: always()
6464

6565
- name: Run vagrant common-desktop.yml
66-
run: VAGRANT_DEFAULT_PROVIDER=virtualbox VAGRANT_LOG=debug vagrant --os=ubuntu/jammy64 --local --headless up
66+
run: VAGRANT_DEFAULT_PROVIDER=virtualbox VAGRANT_LOG=debug ./bin/retry.sh vagrant --destroy-on-error --os=ubuntu/jammy64 --local --headless up
6767

6868
- name: Destroy vagrant common-desktop.yml
6969
run: VAGRANT_DEFAULT_PROVIDER=virtualbox timeout -k 60 -s 9 60 vagrant destroy -f || true
@@ -83,7 +83,7 @@ jobs:
8383
if: always()
8484

8585
- name: Run vagrant common-minimal-desktop.yml
86-
run: VAGRANT_DEFAULT_PROVIDER=virtualbox VAGRANT_LOG=debug vagrant --os=ubuntu/jammy64 --local --playbook=common-minimal-desktop.yml --headless up
86+
run: VAGRANT_DEFAULT_PROVIDER=virtualbox VAGRANT_LOG=debug ./bin/retry.sh vagrant --destroy-on-error --os=ubuntu/jammy64 --local --playbook=common-minimal-desktop.yml --headless up
8787

8888
- name: Destroy vagrant common-minimal-desktop.yml
8989
run: VAGRANT_DEFAULT_PROVIDER=virtualbox timeout -k 60 -s 9 60 vagrant destroy -f || true
@@ -103,7 +103,7 @@ jobs:
103103
if: always()
104104

105105
- name: Run vagrant user.yml
106-
run: VAGRANT_DEFAULT_PROVIDER=virtualbox VAGRANT_LOG=debug vagrant --os=bento/ubuntu-24.04 --local --playbook=user.yml --headless up
106+
run: VAGRANT_DEFAULT_PROVIDER=virtualbox VAGRANT_LOG=debug ./bin/retry.sh vagrant --destroy-on-error --os=bento/ubuntu-24.04 --local --playbook=user.yml --headless up
107107

108108
- name: Destroy vagrant user.yml
109109
run: VAGRANT_DEFAULT_PROVIDER=virtualbox timeout -k 60 -s 9 60 vagrant destroy -f || true
@@ -123,7 +123,7 @@ jobs:
123123
if: always()
124124

125125
- name: Run vagrant common-desktop.yml
126-
run: VAGRANT_DEFAULT_PROVIDER=virtualbox VAGRANT_LOG=debug vagrant --os=bento/ubuntu-24.04 --local --headless up
126+
run: VAGRANT_DEFAULT_PROVIDER=virtualbox VAGRANT_LOG=debug ./bin/retry.sh vagrant --destroy-on-error --os=bento/ubuntu-24.04 --local --headless up
127127

128128
- name: Destroy vagrant common-desktop.yml
129129
run: VAGRANT_DEFAULT_PROVIDER=virtualbox timeout -k 60 -s 9 60 vagrant destroy -f || true
@@ -143,7 +143,7 @@ jobs:
143143
if: always()
144144

145145
- name: Run vagrant common-devserver.yml
146-
run: VAGRANT_DEFAULT_PROVIDER=virtualbox VAGRANT_LOG=debug vagrant --os=bento/ubuntu-24.04 --local --playbook=common-devserver.yml --headless up
146+
run: VAGRANT_DEFAULT_PROVIDER=virtualbox VAGRANT_LOG=debug ./bin/retry.sh vagrant --destroy-on-error --os=bento/ubuntu-24.04 --local --playbook=common-devserver.yml --headless up
147147

148148
- name: Destroy vagrant common-devserver.yml
149149
run: VAGRANT_DEFAULT_PROVIDER=virtualbox timeout -k 60 -s 9 60 vagrant destroy -f || true
@@ -163,7 +163,7 @@ jobs:
163163
if: always()
164164

165165
- name: Run vagrant common-devserver.yml
166-
run: VAGRANT_DEFAULT_PROVIDER=libvirt VAGRANT_LOG=debug vagrant --os=cloud-image/ubuntu-24.04 --local --playbook=common-devserver.yml --headless up
166+
run: VAGRANT_DEFAULT_PROVIDER=libvirt VAGRANT_LOG=debug ./bin/retry.sh vagrant --destroy-on-error --os=cloud-image/ubuntu-24.04 --local --playbook=common-devserver.yml --headless up
167167

168168
- name: Destroy vagrant common-devserver.yml
169169
run: VAGRANT_DEFAULT_PROVIDER=libvirt timeout -k 60 -s 9 60 vagrant destroy -f || true

Vagrantfile

+134-131
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ opts = GetoptLong.new(
1313
# Pass arguments to actual vagrant, but they're not used here
1414
["--provider", GetoptLong::OPTIONAL_ARGUMENT],
1515
["--help", GetoptLong::OPTIONAL_ARGUMENT],
16-
["--debug", GetoptLong::OPTIONAL_ARGUMENT]
16+
["--debug", GetoptLong::OPTIONAL_ARGUMENT],
17+
["--destroy-on-error", GetoptLong::OPTIONAL_ARGUMENT]
1718
)
1819

1920
local = false
@@ -47,179 +48,181 @@ end
4748

4849

4950
Vagrant.configure("2") do |config|
50-
if architecture == "arm64"
51-
config.vagrant.plugins = "vagrant-libvirt"
52-
config.vm.box_architecture = architecture
53-
end
54-
config.vm.synced_folder ".", "/vagrant"
51+
config.vm.define "ansible-playbooks_#{Time.now.to_i}" do |node|
52+
if architecture == "arm64"
53+
node.vagrant.plugins = "vagrant-libvirt"
54+
node.vm.box_architecture = architecture
55+
end
56+
node.vm.synced_folder ".", "/vagrant"
5557

56-
# https://developer.hashicorp.com/vagrant/docs/vagrantfile/machine_settings
57-
config.vm.box = os
58-
config.vm.boot_timeout = 600
58+
# https://developer.hashicorp.com/vagrant/docs/vagrantfile/machine_settings
59+
node.vm.box = os
60+
node.vm.boot_timeout = 600
5961

60-
# Need to run `vagrant provision` explicitly for that to work
61-
config.trigger.after [:provision] do |trigger|
62-
trigger.name = "Reboot after provisioning"
63-
trigger.run = { :inline => "vagrant reload" }
64-
end
62+
# Need to run `vagrant provision` explicitly for that to work
63+
node.trigger.after [:provision] do |trigger|
64+
trigger.name = "Reboot after provisioning"
65+
trigger.run = { :inline => "vagrant reload" }
66+
end
6567

66-
# https://vagrant-libvirt.github.io/vagrant-libvirt/configuration.html
67-
# Currently libvirt is only used for arm64. However, to destroy arm machines
68-
# even if the architecture argument is not passed, we need to set all the
69-
# libvirt options anyway, in particular to make this fix work
70-
# https://github.com/vagrant-libvirt/vagrant-libvirt/pull/1329/files
71-
config.vm.provider "libvirt" do |libvirt|
72-
# Give more resources, OOMs by default
73-
libvirt.memory = 8000
74-
# Max 8 cores allowed for arm cpu
75-
libvirt.cpus = [`nproc`.to_i, 8].min
76-
libvirt.machine_type = "virt"
77-
# https://libvirt.org/formatdomain.html
78-
# In this mode, the cpu element describes the CPU that should be presented
79-
# to the guest. This is the default when no mode attribute is specified.
80-
# This mode makes it so that a persistent guest will see the same hardware
81-
# no matter what host the guest is booted on.
82-
libvirt.cpu_mode = "custom"
83-
libvirt.cpu_model = "cortex-a57"
84-
libvirt.driver = "qemu"
85-
libvirt.machine_arch = "aarch64"
86-
# Enable UEFI, refuses to work otherwise
87-
libvirt.nvram = true
88-
libvirt.loader = "/usr/share/AAVMF/AAVMF_CODE.no-secboot.fd"
89-
# Errors otherwise
90-
libvirt.inputs = []
91-
end
68+
# https://vagrant-libvirt.github.io/vagrant-libvirt/configuration.html
69+
# Currently libvirt is only used for arm64. However, to destroy arm machines
70+
# even if the architecture argument is not passed, we need to set all the
71+
# libvirt options anyway, in particular to make this fix work
72+
# https://github.com/vagrant-libvirt/vagrant-libvirt/pull/1329/files
73+
node.vm.provider "libvirt" do |libvirt|
74+
# Give more resources, OOMs by default
75+
libvirt.memory = 8000
76+
# Max 8 cores allowed for arm cpu
77+
libvirt.cpus = [`nproc`.to_i, 8].min
78+
libvirt.machine_type = "virt"
79+
# https://libvirt.org/formatdomain.html
80+
# In this mode, the cpu element describes the CPU that should be presented
81+
# to the guest. This is the default when no mode attribute is specified.
82+
# This mode makes it so that a persistent guest will see the same hardware
83+
# no matter what host the guest is booted on.
84+
libvirt.cpu_mode = "custom"
85+
libvirt.cpu_model = "cortex-a57"
86+
libvirt.driver = "qemu"
87+
libvirt.machine_arch = "aarch64"
88+
# Enable UEFI, refuses to work otherwise
89+
libvirt.nvram = true
90+
libvirt.loader = "/usr/share/AAVMF/AAVMF_CODE.no-secboot.fd"
91+
# Errors otherwise
92+
libvirt.inputs = []
93+
end
9294

93-
config.vm.provider "virtualbox" do |vb|
94-
# Give more resources, OOMs by default
95-
vb.memory = 8000
96-
vb.cpus = `nproc`.to_i
95+
node.vm.provider "virtualbox" do |vb|
96+
# Give more resources, OOMs by default
97+
vb.memory = 8000
98+
vb.cpus = `nproc`.to_i
9799

98-
# Make UI fast
99-
vb.gui = gui
100-
if gui
101-
vb.customize ["modifyvm", :id, "--vram", "128"]
102-
vb.customize ["modifyvm", :id, "--accelerate3d", "on"]
103-
end
100+
# Make UI fast
101+
vb.gui = gui
102+
if gui
103+
vb.customize ["modifyvm", :id, "--vram", "128"]
104+
vb.customize ["modifyvm", :id, "--accelerate3d", "on"]
105+
end
104106

105-
# Disable annoying warnings
106-
vb.check_guest_additions = false
107-
end
107+
# Disable annoying warnings
108+
vb.check_guest_additions = false
109+
end
108110

109-
if local
110-
config.vm.provision "shell", env: {}, inline: <<-SHELL
111-
set -uex
111+
if local
112+
node.vm.provision "shell", env: {}, inline: <<-SHELL
113+
set -uex
112114
113-
export DEBIAN_FRONTEND=noninteractive
115+
export DEBIAN_FRONTEND=noninteractive
114116
115-
systemctl disable systemd-networkd.service
117+
systemctl disable systemd-networkd.service
116118
117-
rm -f /etc/resolv.conf
118-
echo "nameserver 8.8.8.8" > /etc/resolv.conf
119+
rm -f /etc/resolv.conf
120+
echo "nameserver 8.8.8.8" > /etc/resolv.conf
119121
120-
TMPDIR=$(mktemp -d)
121-
cd "${TMPDIR}"
122+
TMPDIR=$(mktemp -d)
123+
cd "${TMPDIR}"
122124
123-
rm -rf ansible-playbooks
124-
cp -R /vagrant ansible-playbooks
125+
rm -rf ansible-playbooks
126+
cp -R /vagrant ansible-playbooks
125127
126-
cd ansible-playbooks
127-
rm -rf manual
128-
mkdir manual
128+
cd ansible-playbooks
129+
rm -rf manual
130+
mkdir manual
129131
130-
sed 's/# //g' roles/user/defaults/main.yml > manual/common.yml
132+
sed 's/# //g' roles/user/defaults/main.yml > manual/common.yml
131133
132-
chown -R vagrant .
134+
chown -R vagrant .
133135
134-
set +e
135-
for i in {1..3}; do
136-
# Run twice to make sure users are added to correct groups
137-
sudo -u vagrant ./bootstrap.sh #{playbook} LOCAL && \
136+
set +e
137+
for i in {1..3}; do
138+
# Run twice to make sure users are added to correct groups
138139
sudo -u vagrant ./bootstrap.sh #{playbook} LOCAL && \
139-
break
140-
done
140+
sudo -u vagrant ./bootstrap.sh #{playbook} LOCAL && \
141+
break
142+
done
141143
142-
if [[ $? -ne 0 ]]; then
143-
echo "Failed to provision"
144-
exit 1
145-
fi
146-
set -e
144+
if [[ $? -ne 0 ]]; then
145+
echo "Failed to provision"
146+
exit 1
147+
fi
148+
set -e
147149
148-
apt-get update
149-
apt-get upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"
150+
apt-get update
151+
apt-get upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"
150152
151-
apt-get update
152-
apt-get dist-upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"
153+
apt-get update
154+
apt-get dist-upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"
153155
154-
apt-get update
155-
apt-get upgrade -y
156+
apt-get update
157+
apt-get upgrade -y
156158
157-
apt-get autoremove -y
158-
apt purge -y '~c'
159+
apt-get autoremove -y
160+
apt purge -y '~c'
159161
160-
id -u user && cd /tmp/ && sudo -u user /home/user/.bin/init-user-env.sh || true
162+
id -u user && cd /tmp/ && sudo -u user /home/user/.bin/init-user-env.sh || true
161163
162-
reboot
163-
SHELL
164-
else
165-
config.vm.provision "shell", env: {}, inline: <<-SHELL
166-
set -uex
164+
reboot
165+
SHELL
166+
else
167+
node.vm.provision "shell", env: {}, inline: <<-SHELL
168+
set -uex
167169
168-
export DEBIAN_FRONTEND=noninteractive
170+
export DEBIAN_FRONTEND=noninteractive
169171
170-
systemctl disable systemd-networkd.service
172+
systemctl disable systemd-networkd.service
171173
172-
rm -f /etc/resolv.conf
173-
echo "nameserver 8.8.8.8" > /etc/resolv.conf
174+
rm -f /etc/resolv.conf
175+
echo "nameserver 8.8.8.8" > /etc/resolv.conf
174176
175-
TMPDIR=$(mktemp -d)
176-
cd "${TMPDIR}"
177+
TMPDIR=$(mktemp -d)
178+
cd "${TMPDIR}"
177179
178-
export DEBIAN_FRONTEND=noninteractive
180+
export DEBIAN_FRONTEND=noninteractive
179181
180-
apt-get update
182+
apt-get update
181183
182-
apt-get install -y git
184+
apt-get install -y git
183185
184-
rm -rf ansible-playbooks
185-
git clone https://github.com/fspv/ansible-playbooks.git
186+
rm -rf ansible-playbooks
187+
git clone https://github.com/fspv/ansible-playbooks.git
186188
187-
cd ansible-playbooks
188-
mkdir manual
189+
cd ansible-playbooks
190+
mkdir manual
189191
190-
sed 's/# //g' roles/user/defaults/main.yml > manual/common.yml
192+
sed 's/# //g' roles/user/defaults/main.yml > manual/common.yml
191193
192-
chown -R vagrant .
194+
chown -R vagrant .
193195
194-
set +e
195-
if [[ $? -ne 0 ]]; then
196-
# Run twice to make sure users are added to correct groups
197-
sudo -u vagrant ./bootstrap.sh #{playbook} LOCAL && \
196+
set +e
197+
if [[ $? -ne 0 ]]; then
198+
# Run twice to make sure users are added to correct groups
198199
sudo -u vagrant ./bootstrap.sh #{playbook} LOCAL && \
199-
break
200-
done
200+
sudo -u vagrant ./bootstrap.sh #{playbook} LOCAL && \
201+
break
202+
done
201203
202-
if $? -ne 0; then
203-
echo "Failed to provision"
204-
exit 1
205-
fi
206-
set -e
204+
if $? -ne 0; then
205+
echo "Failed to provision"
206+
exit 1
207+
fi
208+
set -e
207209
208-
apt-get update
209-
apt-get upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"
210+
apt-get update
211+
apt-get upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"
210212
211-
apt-get update
212-
apt-get dist-upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"
213+
apt-get update
214+
apt-get dist-upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"
213215
214-
apt-get update
215-
apt-get upgrade -y
216+
apt-get update
217+
apt-get upgrade -y
216218
217-
apt-get autoremove -y
218-
apt purge -y '~c'
219+
apt-get autoremove -y
220+
apt purge -y '~c'
219221
220-
id -u user && cd /tmp/ && sudo -u user /home/user/.bin/init-user-env.sh || true
222+
id -u user && cd /tmp/ && sudo -u user /home/user/.bin/init-user-env.sh || true
221223
222-
reboot
223-
SHELL
224+
reboot
225+
SHELL
226+
end
224227
end
225228
end

0 commit comments

Comments
 (0)