diff --git a/ansible/playbook.yml b/ansible/playbook.yml index f8509fb..52e2a23 100644 --- a/ansible/playbook.yml +++ b/ansible/playbook.yml @@ -12,20 +12,7 @@ - name: Help with debugging ansible.builtin.debug: msg: "Detected distro: {{ ansible_facts['distribution'] }}" - - - name: get build time - become: true - ansible.builtin.copy: - content: "{{ ansible_facts.date_time.date }} {{ ansible_facts.date_time.hour }}:{{ ansible_facts.date_time.minute }}" - dest: /etc/vagrant_box_build_time - owner: root - group: root - mode: 0644 roles: - - role: latest - when: - - ansible_facts.distribution not in no_touchy - - role: devroles.system.epel - role: virtualbox @@ -41,18 +28,6 @@ when: - packer_builder_type == 'qemu' - - role: init - when: - - ansible_facts.distribution not in no_touchy - - - role: locale - when: - - ansible_facts.distribution not in no_touchy - - - role: vagrant - when: - - ansible_facts.distribution not in no_touchy - - role: cleanup when: - ansible_facts.distribution not in no_touchy diff --git a/distros/archlinux/rolling/finalize.sh b/distros/archlinux/rolling/finalize.sh new file mode 100644 index 0000000..59d1850 --- /dev/null +++ b/distros/archlinux/rolling/finalize.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -ex + +pacman -Syyu --noconfirm + +echo << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf +UseDNS no +PubkeyAcceptedKeyTypes +ssh-rsa +EOF + +# Clear the pacman cache +pacman -Sc --noconfirm diff --git a/distros/archlinux/rolling/http/in-chroot.sh b/distros/archlinux/rolling/http/in-chroot.sh index 3b97759..23d5e11 100644 --- a/distros/archlinux/rolling/http/in-chroot.sh +++ b/distros/archlinux/rolling/http/in-chroot.sh @@ -33,13 +33,6 @@ grub-mkconfig -o /boot/grub/grub.cfg # Create and configure the vagrant user groupadd vagrant -useradd vagrant -g vagrant -G wheel -d /home/vagrant +useradd vagrant -g vagrant -G wheel -m +[ -d /home/vagrant ] || exit 1 echo "vagrant:vagrant" | chpasswd - -# Configure vagrant user's SSH key -mkdir -m 0700 -p ~vagrant/.ssh -cat > ~vagrant/.ssh/authorized_keys << EOKEYS -ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key -EOKEYS -chmod 600 ~vagrant/.ssh/authorized_keys -chown -R vagrant:vagrant ~vagrant/ diff --git a/distros/archlinux/rolling/http/install.sh b/distros/archlinux/rolling/http/install.sh index 83c9d24..edaf383 100644 --- a/distros/archlinux/rolling/http/install.sh +++ b/distros/archlinux/rolling/http/install.sh @@ -24,9 +24,10 @@ sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk ${disk} # default start # default to full disk p # print, for debugging - r # return to normal mode w # write the partition table and exit EOF + +sleep 10 # Let me at least read it! #t # set partition type #1 # on partition 1 #4 # BIOS boot diff --git a/distros/archlinux/rolling/qemu.sh b/distros/archlinux/rolling/qemu.sh new file mode 100644 index 0000000..581dfab --- /dev/null +++ b/distros/archlinux/rolling/qemu.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ex + +pacman -Sy --noconfirm qemu-guest-agent +systemctl start qemu-guest-agent +systemctl enable qemu-guest-agent diff --git a/distros/archlinux/rolling/virtualbox.sh b/distros/archlinux/rolling/virtualbox.sh new file mode 100644 index 0000000..725e11e --- /dev/null +++ b/distros/archlinux/rolling/virtualbox.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ex + +pacman -Sy --noconfirm virtualbox-guest-utils-nox +systemctl start vboxservice +systemctl enable vboxservice diff --git a/distros/archlinux/rolling/vmware.sh b/distros/archlinux/rolling/vmware.sh new file mode 100644 index 0000000..244bd92 --- /dev/null +++ b/distros/archlinux/rolling/vmware.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -ex + +pacman -Sy --noconfirm open-vm-tools diff --git a/distros/centos-stream/8/disc/ks.cfg b/distros/centos-stream/8/disc/ks.cfg index 283b7b8..e8198dd 100644 --- a/distros/centos-stream/8/disc/ks.cfg +++ b/distros/centos-stream/8/disc/ks.cfg @@ -90,18 +90,16 @@ ex -s /etc/ssh/sshd_config <>/etc/sysconfig/sshd < /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf +PubkeyAcceptedKeyTypes +ssh-rsa +EOF + # Decrease connection time by preventing reverse DNS lookups # (see https://lists.centos.org/pipermail/centos-devel/2016-July/014981.html # and man sshd for more information) OPTIONS="-u0" EOF -# Default insecure vagrant key -mkdir -m 0700 -p /home/vagrant/.ssh -echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key" >> /home/vagrant/.ssh/authorized_keys -chmod 600 /home/vagrant/.ssh/authorized_keys -chown -R vagrant:vagrant /home/vagrant/.ssh - # Fix for issue #76, regular users can gain admin privileges via su ex -s /etc/pam.d/su <<'EOF' # allow vagrant to use su, but prevent others from becoming root or vagrant @@ -152,4 +150,3 @@ rm -rf /etc/ssh/ssh_host_* hostnamectl set-hostname localhost.localdomain rm -rf /etc/udev/rules.d/70-* %end - diff --git a/distros/centos-stream/8/finalize.sh b/distros/centos-stream/8/finalize.sh new file mode 100644 index 0000000..c30e5a8 --- /dev/null +++ b/distros/centos-stream/8/finalize.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ex + +dnf -y update + +dnf clean all diff --git a/distros/centos-stream/8/qemu.sh b/distros/centos-stream/8/qemu.sh new file mode 100644 index 0000000..569dc7c --- /dev/null +++ b/distros/centos-stream/8/qemu.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ex + +dnf install -y qemu-guest-agent +systemctl start qemu-guest-agent +systemctl enable qemu-guest-agent diff --git a/distros/centos-stream/8/virtualbox.sh b/distros/centos-stream/8/virtualbox.sh new file mode 100644 index 0000000..5ec88ec --- /dev/null +++ b/distros/centos-stream/8/virtualbox.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -ex + +packages="bzip2 dkms kernel-devel kernel-headers make perl gcc" +dnf install -y ${packages} # Intentionally not quoted +mount -t auto /home/vagrant/VBoxGuestAdditions.iso /mnt +/mnt/VBoxLinuxAdditions.run install 2>&1 | tee /root/vbox_addon_install.log +dnf uninstall -y ${packages} # Also intentionally not quoted +umount /mnt +rm /home/vagrant/VBoxGuestAdditions.iso diff --git a/distros/centos-stream/8/vmware.sh b/distros/centos-stream/8/vmware.sh new file mode 100644 index 0000000..058afc2 --- /dev/null +++ b/distros/centos-stream/8/vmware.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -ex + +dnf install -y open-vm-tools diff --git a/distros/centos-stream/8/x86_64.pkrvars.hcl b/distros/centos-stream/8/x86_64.pkrvars.hcl index b07da49..0048dbf 100644 --- a/distros/centos-stream/8/x86_64.pkrvars.hcl +++ b/distros/centos-stream/8/x86_64.pkrvars.hcl @@ -1,5 +1,5 @@ -distro = "centos" -version = "8stream" +distro = "centos-stream" +version = "8" iso = { url = "http://mirror.centos.org/centos/8-stream/isos/x86_64/CentOS-Stream-8-x86_64-latest-boot.iso" checksum = "029ead89f720becd5ee2a8cf9935aad12fda7494d61674710174b4674b357530" diff --git a/distros/centos-stream/8/x86_64.pkrvars.hcl.sh b/distros/centos-stream/8/x86_64.pkrvars.hcl.sh index 6f64cbe..7bb1511 100755 --- a/distros/centos-stream/8/x86_64.pkrvars.hcl.sh +++ b/distros/centos-stream/8/x86_64.pkrvars.hcl.sh @@ -12,8 +12,8 @@ done sha="$(cat "${checksums}" | grep latest-boot | grep SHA256 | cut -d' ' -f 4)" cat << HERPDERP > "${name}" -distro = "centos" -version = "8stream" +distro = "centos-stream" +version = "8" iso = { url = "http://mirror.centos.org/centos/8-stream/isos/x86_64/CentOS-Stream-8-x86_64-latest-boot.iso" checksum = "${sha}" diff --git a/distros/centos-stream/9/disc/ks.cfg b/distros/centos-stream/9/disc/ks.cfg index 28fa5aa..b021edf 100644 --- a/distros/centos-stream/9/disc/ks.cfg +++ b/distros/centos-stream/9/disc/ks.cfg @@ -99,18 +99,16 @@ ex -s /etc/ssh/sshd_config <>/etc/sysconfig/sshd < /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf +PubkeyAcceptedKeyTypes +ssh-rsa +EOF + # Decrease connection time by preventing reverse DNS lookups # (see https://lists.centos.org/pipermail/centos-devel/2016-July/014981.html # and man sshd for more information) OPTIONS="-u0" EOF -# Default insecure vagrant key -mkdir -m 0700 -p /home/vagrant/.ssh -echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key" >> /home/vagrant/.ssh/authorized_keys -chmod 600 /home/vagrant/.ssh/authorized_keys -chown -R vagrant:vagrant /home/vagrant/.ssh - # Fix for issue #76, regular users can gain admin privileges via su ex -s /etc/pam.d/su <<'EOF' # allow vagrant to use su, but prevent others from becoming root or vagrant @@ -161,4 +159,3 @@ rm -rf /etc/ssh/ssh_host_* hostnamectl set-hostname localhost.localdomain rm -rf /etc/udev/rules.d/70-* %end - diff --git a/distros/centos-stream/9/finalize.sh b/distros/centos-stream/9/finalize.sh new file mode 100644 index 0000000..c30e5a8 --- /dev/null +++ b/distros/centos-stream/9/finalize.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ex + +dnf -y update + +dnf clean all diff --git a/distros/centos-stream/9/qemu.sh b/distros/centos-stream/9/qemu.sh new file mode 100644 index 0000000..569dc7c --- /dev/null +++ b/distros/centos-stream/9/qemu.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ex + +dnf install -y qemu-guest-agent +systemctl start qemu-guest-agent +systemctl enable qemu-guest-agent diff --git a/distros/centos-stream/9/virtualbox.sh b/distros/centos-stream/9/virtualbox.sh new file mode 100644 index 0000000..5ec88ec --- /dev/null +++ b/distros/centos-stream/9/virtualbox.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -ex + +packages="bzip2 dkms kernel-devel kernel-headers make perl gcc" +dnf install -y ${packages} # Intentionally not quoted +mount -t auto /home/vagrant/VBoxGuestAdditions.iso /mnt +/mnt/VBoxLinuxAdditions.run install 2>&1 | tee /root/vbox_addon_install.log +dnf uninstall -y ${packages} # Also intentionally not quoted +umount /mnt +rm /home/vagrant/VBoxGuestAdditions.iso diff --git a/distros/centos-stream/9/vmware.sh b/distros/centos-stream/9/vmware.sh new file mode 100644 index 0000000..058afc2 --- /dev/null +++ b/distros/centos-stream/9/vmware.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -ex + +dnf install -y open-vm-tools diff --git a/distros/centos-stream/9/x86_64.pkrvars.hcl b/distros/centos-stream/9/x86_64.pkrvars.hcl index 4bbe45c..7ebec47 100644 --- a/distros/centos-stream/9/x86_64.pkrvars.hcl +++ b/distros/centos-stream/9/x86_64.pkrvars.hcl @@ -1,5 +1,5 @@ -distro = "centos" -version = "9stream" +distro = "centos-stream" +version = "9" iso = { url = "https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/iso/CentOS-Stream-9-latest-x86_64-boot.iso" checksum = "be2104d6deac0bf5e52e7262511b7acd3cab0dff96ddef1f2604b2de892e060d" diff --git a/distros/centos-stream/9/x86_64.pkrvars.hcl.sh b/distros/centos-stream/9/x86_64.pkrvars.hcl.sh index b285821..e6400f0 100755 --- a/distros/centos-stream/9/x86_64.pkrvars.hcl.sh +++ b/distros/centos-stream/9/x86_64.pkrvars.hcl.sh @@ -14,8 +14,8 @@ sha="$(cat "${checksums}" | awk '/SHA256/ {print $4}')" rm "${checksums}" cat << HERPDERP > "${name}" -distro = "centos" -version = "9stream" +distro = "centos-stream" +version = "9" iso = { url = "${baseurl}" checksum = "${sha}" diff --git a/distros/centos/7/disc/ks.cfg b/distros/centos/7/disc/ks.cfg index afa2211..75a4e15 100644 --- a/distros/centos/7/disc/ks.cfg +++ b/distros/centos/7/disc/ks.cfg @@ -50,5 +50,8 @@ BOOTPROTO="dhcp" ONBOOT="yes" TYPE="Ethernet" EOF + +sed -i -E -e 's/^.*UseDNS.*$/UseDNS no/' +echo "PubkeyAcceptedKeyTypes +ssh-rsa" >> /etc/ssh/sshd_config %end diff --git a/distros/centos/7/finalize.sh b/distros/centos/7/finalize.sh new file mode 100644 index 0000000..6ee0321 --- /dev/null +++ b/distros/centos/7/finalize.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -ex + +yum -y update + +yum remove make perl gcc kernel-devel kernel-headers bzip2 + +yum clean all diff --git a/distros/centos/7/qemu.sh b/distros/centos/7/qemu.sh new file mode 100644 index 0000000..4082dc8 --- /dev/null +++ b/distros/centos/7/qemu.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ex + +yum install -y qemu-guest-agent +systemctl start qemu-guest-agent +systemctl enable qemu-guest-agent diff --git a/distros/centos/7/virtualbox.sh b/distros/centos/7/virtualbox.sh new file mode 100644 index 0000000..2b5983f --- /dev/null +++ b/distros/centos/7/virtualbox.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -ex + +packages="bzip2 dkms kernel-devel kernel-headers make perl gcc" +yum install -y ${packages} # Intentionally not quoted +mount -t auto /home/vagrant/VBoxGuestAdditions.iso /mnt +/mnt/VBoxLinuxAdditions.run install 2>&1 | tee /root/vbox_addon_install.log +yum uninstall -y ${packages} # Also intentionally not quoted +umount /mnt +rm /home/vagrant/VBoxGuestAdditions.iso diff --git a/distros/centos/7/vmware.sh b/distros/centos/7/vmware.sh new file mode 100644 index 0000000..e61504f --- /dev/null +++ b/distros/centos/7/vmware.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -ex + +yum install -y open-vm-tools diff --git a/distros/debian/10/finalize.sh b/distros/debian/10/finalize.sh new file mode 100644 index 0000000..52930fb --- /dev/null +++ b/distros/debian/10/finalize.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +set -ex + +apt update +apt upgrade -y + +# Configure sshd to be faster +echo << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf +UseDNS no +PubkeyAcceptedKeyTypes +ssh-rsa +EOF + +# Clean up after ourselves +apt-get clean diff --git a/distros/debian/10/qemu.sh b/distros/debian/10/qemu.sh new file mode 100644 index 0000000..4ef2dee --- /dev/null +++ b/distros/debian/10/qemu.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ex + +apt install -y qemu-guest-agent +systemctl start qemu-guest-agent +systemctl enable qemu-guest-agent diff --git a/distros/debian/10/virtualbox.sh b/distros/debian/10/virtualbox.sh new file mode 100644 index 0000000..c7ca72d --- /dev/null +++ b/distros/debian/10/virtualbox.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -ex + +packages="bzip2 dkms build-essential linux-headers-$(uname -r)" +apt install -y ${packages} # Intentionally not quoted +mount -t auto /home/vagrant/VBoxGuestAdditions.iso /mnt +/mnt/VBoxLinuxAdditions.run install 2>&1 | tee /root/vbox_addon_install.log +apt remove -y ${packages} # Also intentionally not quoted +umount /mnt +rm /home/vagrant/VBoxGuestAdditions.iso diff --git a/distros/debian/10/vmware.sh b/distros/debian/10/vmware.sh new file mode 100644 index 0000000..9560300 --- /dev/null +++ b/distros/debian/10/vmware.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -ex + +apt install -y open-vm-tools diff --git a/distros/debian/11/finalize.sh b/distros/debian/11/finalize.sh new file mode 100644 index 0000000..52930fb --- /dev/null +++ b/distros/debian/11/finalize.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +set -ex + +apt update +apt upgrade -y + +# Configure sshd to be faster +echo << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf +UseDNS no +PubkeyAcceptedKeyTypes +ssh-rsa +EOF + +# Clean up after ourselves +apt-get clean diff --git a/distros/debian/11/qemu.sh b/distros/debian/11/qemu.sh new file mode 100644 index 0000000..4ef2dee --- /dev/null +++ b/distros/debian/11/qemu.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ex + +apt install -y qemu-guest-agent +systemctl start qemu-guest-agent +systemctl enable qemu-guest-agent diff --git a/distros/debian/11/virtualbox.sh b/distros/debian/11/virtualbox.sh new file mode 100644 index 0000000..c7ca72d --- /dev/null +++ b/distros/debian/11/virtualbox.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -ex + +packages="bzip2 dkms build-essential linux-headers-$(uname -r)" +apt install -y ${packages} # Intentionally not quoted +mount -t auto /home/vagrant/VBoxGuestAdditions.iso /mnt +/mnt/VBoxLinuxAdditions.run install 2>&1 | tee /root/vbox_addon_install.log +apt remove -y ${packages} # Also intentionally not quoted +umount /mnt +rm /home/vagrant/VBoxGuestAdditions.iso diff --git a/distros/debian/11/vmware.sh b/distros/debian/11/vmware.sh new file mode 100644 index 0000000..9560300 --- /dev/null +++ b/distros/debian/11/vmware.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -ex + +apt install -y open-vm-tools diff --git a/distros/debian/12/finalize.sh b/distros/debian/12/finalize.sh new file mode 100644 index 0000000..52930fb --- /dev/null +++ b/distros/debian/12/finalize.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +set -ex + +apt update +apt upgrade -y + +# Configure sshd to be faster +echo << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf +UseDNS no +PubkeyAcceptedKeyTypes +ssh-rsa +EOF + +# Clean up after ourselves +apt-get clean diff --git a/distros/debian/12/qemu.sh b/distros/debian/12/qemu.sh new file mode 100644 index 0000000..4ef2dee --- /dev/null +++ b/distros/debian/12/qemu.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ex + +apt install -y qemu-guest-agent +systemctl start qemu-guest-agent +systemctl enable qemu-guest-agent diff --git a/distros/debian/12/virtualbox.sh b/distros/debian/12/virtualbox.sh new file mode 100644 index 0000000..c7ca72d --- /dev/null +++ b/distros/debian/12/virtualbox.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -ex + +packages="bzip2 dkms build-essential linux-headers-$(uname -r)" +apt install -y ${packages} # Intentionally not quoted +mount -t auto /home/vagrant/VBoxGuestAdditions.iso /mnt +/mnt/VBoxLinuxAdditions.run install 2>&1 | tee /root/vbox_addon_install.log +apt remove -y ${packages} # Also intentionally not quoted +umount /mnt +rm /home/vagrant/VBoxGuestAdditions.iso diff --git a/distros/debian/12/vmware.sh b/distros/debian/12/vmware.sh new file mode 100644 index 0000000..9560300 --- /dev/null +++ b/distros/debian/12/vmware.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -ex + +apt install -y open-vm-tools diff --git a/distros/debian/9/finalize.sh b/distros/debian/9/finalize.sh new file mode 100644 index 0000000..52930fb --- /dev/null +++ b/distros/debian/9/finalize.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +set -ex + +apt update +apt upgrade -y + +# Configure sshd to be faster +echo << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf +UseDNS no +PubkeyAcceptedKeyTypes +ssh-rsa +EOF + +# Clean up after ourselves +apt-get clean diff --git a/distros/debian/9/qemu.sh b/distros/debian/9/qemu.sh new file mode 100644 index 0000000..4ef2dee --- /dev/null +++ b/distros/debian/9/qemu.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ex + +apt install -y qemu-guest-agent +systemctl start qemu-guest-agent +systemctl enable qemu-guest-agent diff --git a/distros/debian/9/virtualbox.sh b/distros/debian/9/virtualbox.sh new file mode 100644 index 0000000..c7ca72d --- /dev/null +++ b/distros/debian/9/virtualbox.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -ex + +packages="bzip2 dkms build-essential linux-headers-$(uname -r)" +apt install -y ${packages} # Intentionally not quoted +mount -t auto /home/vagrant/VBoxGuestAdditions.iso /mnt +/mnt/VBoxLinuxAdditions.run install 2>&1 | tee /root/vbox_addon_install.log +apt remove -y ${packages} # Also intentionally not quoted +umount /mnt +rm /home/vagrant/VBoxGuestAdditions.iso diff --git a/distros/debian/9/vmware.sh b/distros/debian/9/vmware.sh new file mode 100644 index 0000000..9560300 --- /dev/null +++ b/distros/debian/9/vmware.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -ex + +apt install -y open-vm-tools diff --git a/distros/fedora/37/finalize.sh b/distros/fedora/37/finalize.sh new file mode 100644 index 0000000..c30e5a8 --- /dev/null +++ b/distros/fedora/37/finalize.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ex + +dnf -y update + +dnf clean all diff --git a/distros/fedora/37/qemu.sh b/distros/fedora/37/qemu.sh new file mode 100644 index 0000000..569dc7c --- /dev/null +++ b/distros/fedora/37/qemu.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ex + +dnf install -y qemu-guest-agent +systemctl start qemu-guest-agent +systemctl enable qemu-guest-agent diff --git a/distros/fedora/37/virtualbox.sh b/distros/fedora/37/virtualbox.sh new file mode 100644 index 0000000..209dab5 --- /dev/null +++ b/distros/fedora/37/virtualbox.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ex + +dnf install -y virtualbox-guest-additions +systemctl start vboxservice +systemctl enable vboxservice diff --git a/distros/fedora/37/vmware.sh b/distros/fedora/37/vmware.sh new file mode 100644 index 0000000..058afc2 --- /dev/null +++ b/distros/fedora/37/vmware.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -ex + +dnf install -y open-vm-tools diff --git a/distros/fedora/37/x86_64.ks b/distros/fedora/37/x86_64.ks index 7630fe1..e0467fc 100644 --- a/distros/fedora/37/x86_64.ks +++ b/distros/fedora/37/x86_64.ks @@ -156,12 +156,7 @@ truncate -s 0 /etc/machine-id sed -i 's,Defaults\\s*requiretty,Defaults !requiretty,' /etc/sudoers echo 'vagrant ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/vagrant-nopasswd sed -i 's/.*UseDNS.*/UseDNS no/' /etc/ssh/sshd_config -mkdir -m 0700 -p ~vagrant/.ssh -cat > ~vagrant/.ssh/authorized_keys << EOKEYS -ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key -EOKEYS -chmod 600 ~vagrant/.ssh/authorized_keys -chown -R vagrant:vagrant ~vagrant/.ssh/ +#'k cat > /etc/ssh/sshd_config.d/10-vagrant-insecure-rsa-key.conf < /etc/ssh/sshd_config.d/10-vagrant-insecure-rsa-key.conf < /etc/sudoers.d/vagrant-nopasswd sed -i 's/.*UseDNS.*/UseDNS no/' /etc/ssh/sshd_config -mkdir -m 0700 -p ~vagrant/.ssh -cat > ~vagrant/.ssh/authorized_keys << EOKEYS -ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key -EOKEYS -chmod 600 ~vagrant/.ssh/authorized_keys -chown -R vagrant:vagrant ~vagrant/.ssh/ +#' cat > /etc/ssh/sshd_config.d/10-vagrant-insecure-rsa-key.conf < /etc/ssh/sshd_config.d/10-vagrant-insecure-rsa-key.conf < /etc/sudoers.d/vagrant-nopasswd sed -i 's/.*UseDNS.*/UseDNS no/' /etc/ssh/sshd_config -mkdir -m 0700 -p ~vagrant/.ssh -cat > ~vagrant/.ssh/authorized_keys << EOKEYS -ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key -EOKEYS -chmod 600 ~vagrant/.ssh/authorized_keys -chown -R vagrant:vagrant ~vagrant/.ssh/ +#' cat > /etc/ssh/sshd_config.d/10-vagrant-insecure-rsa-key.conf < /etc/ssh/sshd_config.d/10-vagrant-insecure-rsa-key.conf < /etc/nixos/guest-agent.nix +{...}: +{ + services.qemuGuest.enable = true; +} +EOF +chown vagrant:vagrant /etc/nixos/guest-agent.nix +nixos-rebuild switch diff --git a/distros/nixos/23.05/virtualbox.sh b/distros/nixos/23.05/virtualbox.sh new file mode 100644 index 0000000..ab3eddd --- /dev/null +++ b/distros/nixos/23.05/virtualbox.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -ex + +sed -i -e 's,#PROVIDER_PLACEHOLDER,guest-agent.nix,' /etc/nixos/configuration.nix +cat << EOF > /etc/nixos/guest-agent.nix +{...}: +{ + virtualisation.virtualbox.guest = { + enable = true; + x11 = false; + }; +} +EOF +chown vagrant:vagrant /etc/nixos/guest-agent.nix +nixos-rebuild switch diff --git a/distros/nixos/23.05/vmware.sh b/distros/nixos/23.05/vmware.sh new file mode 100644 index 0000000..3b16ddf --- /dev/null +++ b/distros/nixos/23.05/vmware.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -ex + +sed -i -e 's,#PROVIDER_PLACEHOLDER,guest-agent.nix,' /etc/nixos/configuration.nix +cat << EOF > /etc/nixos/guest-agent.nix +{...}: +{ + virtualisation.vmware.guest = { + enable = true; + headless = false; + }; +} +EOF +chown vagrant:vagrant /etc/nixos/guest-agent.nix +nixos-rebuild switch diff --git a/distros/ubuntu/18.04/finalize.sh b/distros/ubuntu/18.04/finalize.sh new file mode 100644 index 0000000..54ee48f --- /dev/null +++ b/distros/ubuntu/18.04/finalize.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -ex + +apt remove cloud-init -y + +apt update +apt upgrade -y + +# Do some magic with init +sed -i -E -e 's,^(ACTIVE_CONSOLES="/dev/tty).*",\11,' /etc/default/console-setup + +echo << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf +UseDNS no +PubkeyAcceptedKeyTypes +ssh-rsa +EOF + +# Clean up after ourselves +apt-get clean diff --git a/distros/ubuntu/18.04/qemu.sh b/distros/ubuntu/18.04/qemu.sh new file mode 100644 index 0000000..4ef2dee --- /dev/null +++ b/distros/ubuntu/18.04/qemu.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ex + +apt install -y qemu-guest-agent +systemctl start qemu-guest-agent +systemctl enable qemu-guest-agent diff --git a/distros/ubuntu/18.04/virtualbox.sh b/distros/ubuntu/18.04/virtualbox.sh new file mode 100644 index 0000000..4bbaf0a --- /dev/null +++ b/distros/ubuntu/18.04/virtualbox.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ex + +apt install -y virtualbox-guest-dkms +systemctl start vboxservice +systemctl enable vboxservice diff --git a/distros/ubuntu/18.04/vmware.sh b/distros/ubuntu/18.04/vmware.sh new file mode 100644 index 0000000..9560300 --- /dev/null +++ b/distros/ubuntu/18.04/vmware.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -ex + +apt install -y open-vm-tools diff --git a/distros/ubuntu/20.04/finalize.sh b/distros/ubuntu/20.04/finalize.sh new file mode 100644 index 0000000..35c89ad --- /dev/null +++ b/distros/ubuntu/20.04/finalize.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -ex + +apt remove cloud-init -y + +apt update +apt upgrade -y + +# Do some magic with init +sed -i -E -e 's,^(ACTIVE_CONSOLES="/dev/tty).*",\11,' /etc/default/console-setup + +# Make sshd faster +echo << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf +UseDNS no +PubkeyAcceptedKeyTypes +ssh-rsa +EOF + +# Clean up after ourselves +apt-get clean diff --git a/distros/ubuntu/20.04/qemu.sh b/distros/ubuntu/20.04/qemu.sh new file mode 100644 index 0000000..4ef2dee --- /dev/null +++ b/distros/ubuntu/20.04/qemu.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ex + +apt install -y qemu-guest-agent +systemctl start qemu-guest-agent +systemctl enable qemu-guest-agent diff --git a/distros/ubuntu/20.04/virtualbox.sh b/distros/ubuntu/20.04/virtualbox.sh new file mode 100644 index 0000000..4bbaf0a --- /dev/null +++ b/distros/ubuntu/20.04/virtualbox.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ex + +apt install -y virtualbox-guest-dkms +systemctl start vboxservice +systemctl enable vboxservice diff --git a/distros/ubuntu/20.04/vmware.sh b/distros/ubuntu/20.04/vmware.sh new file mode 100644 index 0000000..9560300 --- /dev/null +++ b/distros/ubuntu/20.04/vmware.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -ex + +apt install -y open-vm-tools diff --git a/distros/ubuntu/22.04/finalize.sh b/distros/ubuntu/22.04/finalize.sh new file mode 100644 index 0000000..35c89ad --- /dev/null +++ b/distros/ubuntu/22.04/finalize.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -ex + +apt remove cloud-init -y + +apt update +apt upgrade -y + +# Do some magic with init +sed -i -E -e 's,^(ACTIVE_CONSOLES="/dev/tty).*",\11,' /etc/default/console-setup + +# Make sshd faster +echo << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf +UseDNS no +PubkeyAcceptedKeyTypes +ssh-rsa +EOF + +# Clean up after ourselves +apt-get clean diff --git a/distros/ubuntu/22.04/qemu.sh b/distros/ubuntu/22.04/qemu.sh new file mode 100644 index 0000000..4ef2dee --- /dev/null +++ b/distros/ubuntu/22.04/qemu.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ex + +apt install -y qemu-guest-agent +systemctl start qemu-guest-agent +systemctl enable qemu-guest-agent diff --git a/distros/ubuntu/22.04/virtualbox.sh b/distros/ubuntu/22.04/virtualbox.sh new file mode 100644 index 0000000..e438c81 --- /dev/null +++ b/distros/ubuntu/22.04/virtualbox.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ex + +apt install -y virtualbox-guest-utils +systemctl start vboxservice +systemctl enable vboxservice diff --git a/distros/ubuntu/22.04/vmware.sh b/distros/ubuntu/22.04/vmware.sh new file mode 100644 index 0000000..9560300 --- /dev/null +++ b/distros/ubuntu/22.04/vmware.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -ex + +apt install -y open-vm-tools diff --git a/scripts/vagrant.sh b/scripts/vagrant.sh new file mode 100644 index 0000000..669b159 --- /dev/null +++ b/scripts/vagrant.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set -ex + +# Configure vagrant user's SSH key +mkdir -m 0700 -p ~vagrant/.ssh +curl -L -o ~vagrant/.ssh/authorized_keys "https://raw.githubusercontent.com/hashicorp/vagrant/master/keys/vagrant.pub" +chmod 600 ~vagrant/.ssh/authorized_keys +chown -R vagrant:vagrant ~vagrant/ + +# Set the build time +date -Iseconds > /etc/vagrant_box_build_time diff --git a/sources/build.pkr.hcl b/sources/build.pkr.hcl index 773d195..ee6ada3 100644 --- a/sources/build.pkr.hcl +++ b/sources/build.pkr.hcl @@ -26,20 +26,29 @@ build { "source.vmware-iso.x86_64" ] - provisioner "ansible" { - playbook_file = "ansible/playbook.yml" - galaxy_file = "ansible/requirements.yml" - user = local.ssh.username - use_sftp = true - ansible_ssh_extra_args = [ - #"-o", "HostKeyAlgorithms=+ssh-rsa", - #"-o", "PubkeyAcceptedKeyTypes=+ssh-rsa", - "-o", "IdentitiesOnly=yes" - ] + # If anything needs specific support for one of the distros + provisioner "shell" { + execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'" + only = ["qemu.x86_64"] + script = "distros/${var.distro}/${var.version}/qemu.sh" + } + provisioner "shell" { + execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'" + only = ["virtualbox-iso.x86_64"] + script = "distros/${var.distro}/${var.version}/virtualbox.sh" + } + provisioner "shell" { + execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'" + only = ["vmware-iso.x86_64"] + script = "distros/${var.distro}/${var.version}/vmware.sh" } + # Generic wrapping up the provisioner before packaging provisioner "shell" { + execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'" scripts = [ + "scripts/vagrant.sh", + "distros/${var.distro}/${var.version}/finalize.sh", "scripts/minimize.sh" ] } diff --git a/sources/qemu.pkr.hcl b/sources/qemu.pkr.hcl index 796efdf..532efb3 100644 --- a/sources/qemu.pkr.hcl +++ b/sources/qemu.pkr.hcl @@ -28,7 +28,11 @@ source "qemu" "x86_64" { qemuargs = [ #["-chardev", "stdio,id=char0,logfile=serial-output-qemu-${var.arch}-${var.distro}-${var.version},signal=off"], - #["-serial", "chardev:char0"] + #["-serial", "chardev:char0"], + ["-chardev", "socket,host=localhost,port=9876,server=on,wait=off,id=qga0"], + ["-device", "virtio-serial"], + ["-device", "virtserialport,chardev=qga0,name=org.qemu.guest_agent.0"], + ["-qmp", "tcp:localhost:4444,server,wait=off"], ] accelerator = var.qemu_accelerator diff --git a/test.xsh b/test.xsh index 2867f98..be6f029 100755 --- a/test.xsh +++ b/test.xsh @@ -59,7 +59,7 @@ def main(): sed -e f's#@@BOX@@#file:///home/greg/src/vms/vms/{box}#' -e f's/@@BOX_NAME@@/{p.name}/' Vagrantfile.in > Vagrantfile vagrant box add @(box) --name @(p.name) if str(p.parent.name) in ["virtualbox", "libvirt", "vmware"]: - vagrant up --provider vmware_fusion + vagrant up --provider @(p.parent.name) else: print(f"Now whatcha wanna go and do that for? {box}") continue diff --git a/vagrant/x86_64.rb b/vagrant/x86_64.rb index b68d3ef..2bdde38 100644 --- a/vagrant/x86_64.rb +++ b/vagrant/x86_64.rb @@ -6,6 +6,8 @@ Vagrant.configure('2') do |c| v.connect_via_ssh = false #v.username = 'root' v.memory = 2048 + # QEmu Guest Agent channel + v.qemu_use_agent = true end c.vm.provider :virtualbox do |v| v.gui = false