feat: add Vagrant file and provisioning scripts

This commit is contained in:
Emmanuel BENOîT 2024-12-29 18:28:07 +01:00
commit ad2a00a42c
Signed by: Emmanuel BENOîT
SSH key fingerprint: SHA256:l7PFUUF5TCDsvYeQC9OnTNz08dFY7Fvf4Hv3neIqYpg
25 changed files with 4805 additions and 0 deletions

35
scripts/00-network.sh Normal file
View file

@ -0,0 +1,35 @@
#!/bin/sh
set -e
export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true
# APT proxy configuration
if [ -z "$APT_PROXY" ]; then
rm -f /etc/apt/apt.conf.d/90proxy
sub=http:/https:
else
echo "Acquire::http::Proxy \"${APT_PROXY}\";" > /etc/apt/apt.conf.d/90proxy
sub=https:/http:
fi
sed -i "s/$sub/g" /etc/apt/sources.list `find /etc/apt/sources.list.d -name '*.list'`
# Ensure systemd-resolved is actually installed
apt-get update
apt-get install -y systemd-resolved
cat >/etc/systemd/network/eth0.network <<EOF
[Match]
Name=eth0
[Network]
LinkLocalAddressing=no
DHCP=ipv4
EOF
systemctl enable systemd-networkd.service
systemctl enable systemd-resolved.service
rm -f /etc/network/interfaces
dpkg --purge resolvconf
systemctl disable networking.service
ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

31
scripts/01-os-basics.sh Normal file
View file

@ -0,0 +1,31 @@
#!/bin/sh
set -e
export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true
# Reset grub configuration
echo "Setting install device to $( grub-mkdevicemap -m - | head -n 1 | awk '{ print $2 }' )"
echo "debconf grub-pc/install_devices string $( grub-mkdevicemap -m - | head -n 1 | awk '{ print $2 }' )" | debconf-set-selections
# Prevent "suggested" packages from being installed automatically
echo 'APT::Install-Suggests "0";' > /etc/apt/apt.conf.d/05disable-suggests
# Replace kernel
apt-get install -uy linux-image-cloud-amd64
apt-get remove -y linux-image-amd64
# Remove various useless packages
apt-get remove -y memcached postfix postfix-cdb
# Full system update
apt-get update -y
apt-get dist-upgrade -uy
apt-get clean
apt-get autoremove -y
# Install Ansible requirements
apt-get install -y python3-venv python-is-python3
# Create a directory for the provisioning playbook
[ -d /var/cache/provision ] || mkdir -p /var/cache/provision
chown -R vagrant:vagrant /var/cache/provision

15
scripts/02-provision.sh Normal file
View file

@ -0,0 +1,15 @@
#!/bin/bash
set -e
export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true
# Create the Ansible venv
if [ ! -d /var/cache/provision/ansible ]; then
python -m venv /var/cache/provision/ansible
fi
source /var/cache/provision/ansible/bin/activate
pip install --upgrade 'ansible>=10,<11' netaddr
# Run the playbook
cd /var/cache/provision/playbook
exec ansible-playbook provision.yml