diff --git a/.gitignore b/.gitignore index 8552264..d08d413 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ output_* serial-output* grub.cfg isolinux.cfg +Vagrantfile # Generated distros distros/fedora-rawhide-*.hcl diff --git a/.gitmodules b/.gitmodules index ff938f2..cc64693 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,3 +22,11 @@ path = http/centos-stream url = https://github.com/greg-hellings/centos-stream-kickstarts-mirror.git branch = main +[submodule "http/fedora/f37"] + path = http/fedora/f37 + url = https://pagure.io/fedora-kickstarts.git + branch = f37 +[submodule "http/fedora/f38"] + path = http/fedora/f38 + url = https://pagure.io/fedora-kickstarts.git + branch = f38 diff --git a/README.box.md b/README.box.md index ba9155b..2fafec7 100644 --- a/README.box.md +++ b/README.box.md @@ -5,8 +5,7 @@ * Date: ${formatdate("DD MMM YYYY", timestamp())} * Bugs: [vms](https://github.com/greg-hellings/vms/issues) -A bare-minimum installation of the guest OS. x86_64/amd64 builds are done on -[Github Actions](https://github.com/greg-hellings/vms/actions) at regular intervals. +A bare-minimum installation of the guest OS. If you encounter a bug in the box, please file an issue. If you want a newer version of your desired operating system or want to add a distribution to this @@ -17,7 +16,3 @@ works. The goal is to have the bare minimum software to be considered a basic installation of the guest OS that is still accessible with Vagrant. Straggling packages or leftover files from the build process should be considered as bugs to be filed. - -A big shoutout to Github Actions for offering a full VM experience, by default, and generous -execution times ranging up to 6 hours per task, which allows use of their platform to build -these boxes with no additional cost to the community. diff --git a/TODO.txt b/TODO.txt new file mode 100644 index 0000000..6cdb1f4 --- /dev/null +++ b/TODO.txt @@ -0,0 +1 @@ +CentOS 7 with virtualbox-iso does not auto-build. Network will not enable by default during building diff --git a/Vagrantfile b/Vagrantfile.in similarity index 94% rename from Vagrantfile rename to Vagrantfile.in index ff95b78..ee91113 100644 --- a/Vagrantfile +++ b/Vagrantfile.in @@ -6,7 +6,7 @@ # backwards compatibility). Please don't change it unless you know what # you're doing. Vagrant.configure("2") do |config| - config.vm.box = "test" + config.vm.box = "@@BOX@@" # Create a private network, which allows host-only access to the machine # using a specific IP. @@ -38,6 +38,7 @@ Vagrant.configure("2") do |config| # documentation for more information about their specific syntax and use. config.vm.provision "shell", inline: <<-SHELL set -ex - ls -l / + cat /etc/os-release + cat /etc/vagrant_box_build_time SHELL end diff --git a/ansible/playbook.yml b/ansible/playbook.yml index da3cc3f..cfe3e7f 100644 --- a/ansible/playbook.yml +++ b/ansible/playbook.yml @@ -1,11 +1,16 @@ - name: install guest additions hosts: default pre_tasks: + - name: Pause for a moment in case we need cloud-init to finish + ansible.builtin.pause: + seconds: 20 + - name: Update all the things become: true ansible.builtin.package: # noqa package-latest name: "*" state: latest + update_cache: true when: ansible_facts.pkg_mgr not in ['atomic_container'] register: _update_all retries: 3 @@ -23,12 +28,15 @@ - name: Restart the machine become: true ansible.builtin.reboot: + when: (_update_atomic is changed) or (_update_all is changed) roles: - role: devroles.system.epel - role: virtualbox when: packer_builder_type == 'virtualbox-iso' - role: vmware when: packer_builder_type == 'vmware-iso' + - role: qemu + when: packer_builder_type == 'qemu' - role: init - role: locale - role: vagrant diff --git a/ansible/roles/qemu/tasks/main.yml b/ansible/roles/qemu/tasks/main.yml new file mode 100644 index 0000000..b453398 --- /dev/null +++ b/ansible/roles/qemu/tasks/main.yml @@ -0,0 +1,6 @@ +- name: Install qemu-guest-agent + become: true + ansible.builtin.package: + name: + - qemu-guest-agent + state: present diff --git a/ansible/roles/vagrant/tasks/main.yml b/ansible/roles/vagrant/tasks/main.yml index da31430..31435c5 100644 --- a/ansible/roles/vagrant/tasks/main.yml +++ b/ansible/roles/vagrant/tasks/main.yml @@ -16,7 +16,7 @@ - name: get build time become: true ansible.builtin.copy: - content: "{{ ansible_facts.date_time.date }}" + 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 diff --git a/ansible/roles/virtualbox/vars/Fedora.yml b/ansible/roles/virtualbox/vars/Fedora.yml index b2033ae..9265a94 100644 --- a/ansible/roles/virtualbox/vars/Fedora.yml +++ b/ansible/roles/virtualbox/vars/Fedora.yml @@ -1,15 +1,5 @@ virtualbox_packages: - - kernel - - kernel-devel - - kernel-headers - - gcc - - make - - perl - - elfutils-libelf-devel - - tar - - bzip2 - - dkms -virtualbox_services: - - dkms -virtualbox_from_iso: true + - virtualbox-guest-additions +virtualbox_services: [] +virtualbox_from_iso: false virtualbox_pre_commands: [] diff --git a/distros/debian-9-x86_64.pkrvars.hcl b/attic/debian-9-x86_64.pkrvars.hcl similarity index 100% rename from distros/debian-9-x86_64.pkrvars.hcl rename to attic/debian-9-x86_64.pkrvars.hcl diff --git a/distros/fedora-35-x86_64.pkrvars.hcl b/attic/fedora-35-x86_64.pkrvars.hcl similarity index 100% rename from distros/fedora-35-x86_64.pkrvars.hcl rename to attic/fedora-35-x86_64.pkrvars.hcl diff --git a/distros/fedora-36-x86_64.pkrvars.hcl b/attic/fedora-36-x86_64.pkrvars.hcl similarity index 100% rename from distros/fedora-36-x86_64.pkrvars.hcl rename to attic/fedora-36-x86_64.pkrvars.hcl diff --git a/cellar/centos-9stream-x86_64.pkrvars.hcl.sh b/cellar/centos-9stream-x86_64.pkrvars.hcl.sh deleted file mode 100755 index 48fe1c4..0000000 --- a/cellar/centos-9stream-x86_64.pkrvars.hcl.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -# Name of the file to write out -name="${0%.sh}" - -checksums="$(mktemp)" -until curl -f -L -o "${checksums}" "http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/iso/CentOS-Stream-9-latest-x86_64-boot.iso.SHA256SUM"; do - sleep 1 -done -sha="$(cat "${checksums}" | grep SHA256 | cut -d' ' -f 4)" - -cat << EOF > "${name}" -distro = "centos" -version = "9stream" -iso = { - url = "http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/iso/CentOS-Stream-9-latest-x86_64-boot.iso" - checksum = "${sha}" -} -boot_command = [ - "", - "linux net.ifnames=0 biosdevnames=0 inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/centos/9stream-x86_64.ks console=ttyS0", - "" -] -EOF diff --git a/distros/centos-7-x86_64.pkrvars.hcl b/distros/centos-7-x86_64.pkrvars.hcl index 707f3d5..81015b1 100644 --- a/distros/centos-7-x86_64.pkrvars.hcl +++ b/distros/centos-7-x86_64.pkrvars.hcl @@ -6,6 +6,6 @@ iso = { } boot_command = [ "", - "linux net.ifnames=0 biosdevnames=0 inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/centos/7-x86_64.ks console=ttyS0", + "linux inst.ks=cdrom:/http/centos/7-x86_64.ks console=ttyS0", "" ] diff --git a/distros/centos-8stream-x86_64.pkrvars.hcl.sh b/distros/centos-8stream-x86_64.pkrvars.hcl.sh index 76ec4dc..282c2a3 100755 --- a/distros/centos-8stream-x86_64.pkrvars.hcl.sh +++ b/distros/centos-8stream-x86_64.pkrvars.hcl.sh @@ -17,8 +17,8 @@ iso = { checksum = "${sha}" } boot_command = [ - "", - "linux net.ifnames=0 biosdevnames=0 inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/centos/8stream/x86_64.ks console=ttyS0", - "" + "", + "inst.text inst.ks=cdrom:/http/centos/8stream/x86_64.ks console=ttyS0", + "" ] EOF diff --git a/distros/centos-9stream-x86_64.pkrvars.hcl.sh b/distros/centos-9stream-x86_64.pkrvars.hcl.sh new file mode 100755 index 0000000..d711016 --- /dev/null +++ b/distros/centos-9stream-x86_64.pkrvars.hcl.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +set -ex + +# Name of the file to write out +name="${0%.sh}" + +baseurl="https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/iso/CentOS-Stream-9-latest-x86_64-boot.iso" +checksums="$(mktemp)" +until curl -f -L -o "${checksums}" "${baseurl}.SHA256SUM"; do + sleep 1 +done +sha="$(cat "${checksums}" | awk '/SHA256/ {print $4}')" +rm "${checksums}" + +cat << EOF > "${name}" +distro = "centos" +version = "9stream" +iso = { + url = "${baseurl}" + checksum = "${sha}" +} +boot_command = [ + "", + "inst.text inst.ks=cdrom:/http/centos/9stream-x86_64.ks console=tty0", + "" +] +EOF diff --git a/distros/debian-10-x86_64.pkrvars.hcl b/distros/debian-10-x86_64.pkrvars.hcl index 2eedaef..f716dd1 100644 --- a/distros/debian-10-x86_64.pkrvars.hcl +++ b/distros/debian-10-x86_64.pkrvars.hcl @@ -1,8 +1,8 @@ distro = "debian" version = "10" iso = { - url = "https://cdimage.debian.org/cdimage/archive/10.11.0/amd64/iso-cd/debian-10.11.0-amd64-netinst.iso" - checksum = "133430141272d8bf96cfb10b6bfd1c945f5a59ea0efc2bcb56d1033c7f2866ea" + url = "https://cdimage.debian.org/cdimage/archive/10.13.0/amd64/iso-cd/debian-10.13.0-amd64-netinst.iso" + checksum = "75aa64071060402a594dcf1e14afd669ca0f8bf757b56d4c9c1a31b8f7c8f931" } boot_command = [ "", @@ -12,5 +12,6 @@ boot_command = [ "biosdevnames=0 ", "preseed/url=http://{{.HTTPIP}}:{{ .HTTPPort }}/debian/10-preseed.cfg ", "console=ttyS0 ", + "console=tty0 ", "" ] diff --git a/distros/debian-11-x86_64.pkrvars.hcl b/distros/debian-11-x86_64.pkrvars.hcl index 25c86db..1136a02 100644 --- a/distros/debian-11-x86_64.pkrvars.hcl +++ b/distros/debian-11-x86_64.pkrvars.hcl @@ -1,8 +1,8 @@ distro = "debian" version = "11" iso = { - url = "https://cdimage.debian.org/cdimage/archive/11.2.0/amd64/iso-cd/debian-11.2.0-amd64-netinst.iso" - checksum = "45c9feabba213bdc6d72e7469de71ea5aeff73faea6bfb109ab5bad37c3b43bd" + url = "https://cdimage.debian.org/cdimage/archive/11.7.0/amd64/iso-cd/debian-11.7.0-amd64-netinst.iso" + checksum = "eb3f96fd607e4b67e80f4fc15670feb7d9db5be50f4ca8d0bf07008cb025766b" } boot_command = [ "", diff --git a/distros/debian-12-x86_64.pkrvars.hcl b/distros/debian-12-x86_64.pkrvars.hcl new file mode 100644 index 0000000..aaf7445 --- /dev/null +++ b/distros/debian-12-x86_64.pkrvars.hcl @@ -0,0 +1,16 @@ +distro = "debian" +version = "12" +iso = { + url = "https://cdimage.debian.org/cdimage/archive/12.0.0/amd64/iso-cd/debian-12.0.0-amd64-netinst.iso" + checksum = "3b0e9718e3653435f20d8c2124de6d363a51a1fd7f911b9ca0c6db6b3d30d53e" +} +boot_command = [ + "", + "auto ", + "DEBIAN_FRONTEND=text ", + "net.ifnames=0 ", + "biosdevnames=0 ", + "preseed/url=http://{{.HTTPIP}}:{{ .HTTPPort }}/debian/12-preseed.cfg ", + "console=ttyS0 ", + "" +] diff --git a/distros/fedora-37-x86_64.pkrvars.hcl b/distros/fedora-37-x86_64.pkrvars.hcl new file mode 100644 index 0000000..204229b --- /dev/null +++ b/distros/fedora-37-x86_64.pkrvars.hcl @@ -0,0 +1,10 @@ +distro = "fedora" +version = "37" +iso = { + url = "https://download.fedoraproject.org/pub/fedora/linux/releases/37/Server/x86_64/iso/Fedora-Server-dvd-x86_64-37-1.7.iso" + checksum = "0a4de5157af47b41a07a53726cd62ffabd04d5c1a4afece5ee7c7a84c1213e4f" +} +boot_command = [ + "e ", + "net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/http/fedora/37-x86_64.ks console=tty0 console=ttyS0" +] diff --git a/distros/fedora-38-x86_64.pkrvars.hcl b/distros/fedora-38-x86_64.pkrvars.hcl new file mode 100644 index 0000000..2fb53fb --- /dev/null +++ b/distros/fedora-38-x86_64.pkrvars.hcl @@ -0,0 +1,10 @@ +distro = "fedora" +version = "38" +iso = { + url = "https://download.fedoraproject.org/pub/fedora/linux/releases/38/Server/x86_64/iso/Fedora-Server-dvd-x86_64-38-1.6.iso" + checksum = "66b52d7cb39386644cd740930b0bef0a5a2f2be569328fef6b1f9b3679fdc54d" +} +boot_command = [ + "e ", + "net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/http/fedora/38-x86_64.ks console=tty0 console=ttyS0" +] diff --git a/distros/fedora-rawhide-x86_64.pkrvars.hcl.sh b/distros/fedora-rawhide-x86_64.pkrvars.hcl.sh index ad36187..7facb44 100755 --- a/distros/fedora-rawhide-x86_64.pkrvars.hcl.sh +++ b/distros/fedora-rawhide-x86_64.pkrvars.hcl.sh @@ -35,7 +35,7 @@ iso = { } boot_command = [ "e", - "edd=off net.ifnames=0 biosdevnames=0 inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/fedora/rawhide-x86_64.ks console=ttyS0" + "net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/http/fedora/rawhide-x86_64.ks console=tty0 console=ttyS0" ] EOF diff --git a/distros/ubuntu-18.04-x86_64.pkrvars.hcl b/distros/ubuntu-18.04-x86_64.pkrvars.hcl index fca66bc..d87335a 100644 --- a/distros/ubuntu-18.04-x86_64.pkrvars.hcl +++ b/distros/ubuntu-18.04-x86_64.pkrvars.hcl @@ -1,8 +1,6 @@ distro = "ubuntu" version = "18.04" iso = { - #url = "http://releases.ubuntu.com/18.04/ubuntu-18.04.6-live-server-amd64.iso" - #checksum = "6c647b1ab4318e8c560d5748f908e108be654bad1e165f7cf4f3c1fc43995934" url = "http://cdimage.ubuntu.com/ubuntu/releases/18.04/release/ubuntu-18.04.6-server-amd64.iso" checksum = "f5cbb8104348f0097a8e513b10173a07dbc6684595e331cb06f93f385d0aecf6" } diff --git a/distros/ubuntu-20.04-x86_64.pkrvars.hcl b/distros/ubuntu-20.04-x86_64.pkrvars.hcl index 5f22b8c..3788cc4 100644 --- a/distros/ubuntu-20.04-x86_64.pkrvars.hcl +++ b/distros/ubuntu-20.04-x86_64.pkrvars.hcl @@ -1,8 +1,8 @@ distro = "ubuntu" version = "20.04" iso = { - url = "https://releases.ubuntu.com/20.04/ubuntu-20.04.4-live-server-amd64.iso" - checksum = "28ccdb56450e643bad03bb7bcf7507ce3d8d90e8bf09e38f6bd9ac298a98eaad" + url = "https://releases.ubuntu.com/20.04/ubuntu-20.04.6-live-server-amd64.iso" + checksum = "b8f31413336b9393ad5d8ef0282717b2ab19f007df2e9ed5196c13d8f9153c8b" } boot_wait = "3s" boot_command = [ @@ -10,5 +10,8 @@ boot_command = [ "console=ttyS0 ", "console=tty0 ", "fsck.mode=skip ", + "locale=en_US ", + "auto=true ", + "priority=critical ", "autoinstall ds=nocloud-net;s=http://{{.HTTPIP}}:{{.HTTPPort}}/ubuntu/20.04/" ] diff --git a/distros/ubuntu-22.04-x86_64.pkrvars.hcl b/distros/ubuntu-22.04-x86_64.pkrvars.hcl index f07ae2d..0f5e214 100644 --- a/distros/ubuntu-22.04-x86_64.pkrvars.hcl +++ b/distros/ubuntu-22.04-x86_64.pkrvars.hcl @@ -1,12 +1,15 @@ distro = "ubuntu" version = "22.04" iso = { - url = "https://releases.ubuntu.com/jammy/ubuntu-22.04-live-server-amd64.iso" - checksum = "84aeaf7823c8c61baa0ae862d0a06b03409394800000b3235854a6b38eb4856f" + url = "https://releases.ubuntu.com/jammy/ubuntu-22.04.2-live-server-amd64.iso" + checksum = "5e38b55d57d94ff029719342357325ed3bda38fa80054f9330dc789cd2d43931" } boot_command = [ "e", - "console=ttyS0 ", "fsck.mode=skip ", - "autoinstall ds=\"nocloud-net;s=http://{{.HTTPIP}}:{{.HTTPPort}}/ubuntu/22.04/\" console=ttyS0" + "net.ifnames=0 biosdevnames=0 ", + "locale=en_US ", + "auto=true ", + "priority=critical ", + "autoinstall ds=\"nocloud-net;s=http://{{.HTTPIP}}:{{.HTTPPort}}/ubuntu/22.04/\" console=tty0 ", ] diff --git a/http/centos-stream b/http/centos-stream index 9dd286b..37e7649 160000 --- a/http/centos-stream +++ b/http/centos-stream @@ -1 +1 @@ -Subproject commit 9dd286be86e7d5d031b35c31a2057b5f6c5a5984 +Subproject commit 37e76497feb717e6533f18b64cc2955199610acf diff --git a/http/centos/8stream/x86_64.ks b/http/centos/8stream/x86_64.ks index 6e6dee1..69e9a49 100644 --- a/http/centos/8stream/x86_64.ks +++ b/http/centos/8stream/x86_64.ks @@ -1,19 +1,18 @@ +%include /tmp/packer_ks/centos-stream/CentOS-8-Stream-x86_64-Vagrant.ks + url --mirrorlist=http://mirrorlist.centos.org/?release=8-stream&arch=x86_64&repo=BaseOS&infra=stock repo --name=AppStream --mirrorlist=http://mirrorlist.centos.org/?release=8-stream&arch=x86_64&repo=AppStream&infra=stock - -%include /tmp/packer_ks/centos-upstream/CentOS-8-Stream-x86_64-Vagrant.ks +network --bootproto=dhcp --activate +reboot %pre --interpreter /bin/bash --log /tmp/greg -# This gets us the upstream kickstarter files -cmdline=$(cat /proc/cmdline) -ks=$(printf "${cmdline}" | sed -E -e 's/.*inst\.ks=([^ ]*).*/\1/') -mkdir -p /tmp/packer_ks -cd /tmp/packer_ks -# 3 levels up! -wget -m -nH "$(dirname "$(dirname "$(dirname "${ks}")")")" - +set -ex # This allows us to support virtualbox +mkdir /tmp/sr1 +mount /dev/sr1 /tmp/sr1 +cp -r /tmp/sr1/http /tmp/packer_ks + if [ ! -e /dev/vda ]; then - sed -i -e 's/drives=vda/drives=sda/' -e 's/ondisk=vda/ondisk=sda/' -e 's/shutdown/reboot/' /tmp/packer_ks/centos-upstream/* + sed -i -e 's/drives=vda/drives=sda/' -e 's/ondisk=vda/ondisk=sda/' /tmp/packer_ks/centos-stream/* fi %end diff --git a/http/centos/9stream-x86_64.ks b/http/centos/9stream-x86_64.ks index 0e69856..a39ddf9 100644 --- a/http/centos/9stream-x86_64.ks +++ b/http/centos/9stream-x86_64.ks @@ -1,19 +1,17 @@ -url --mirrorlist=http://mirrorlist.centos.org/?release=9-stream&arch=x86_64&repo=BaseOS&infra=stock -repo --name=AppStream --mirrorlist=http://mirrorlist.centos.org/?release=9-stream&arch=x86_64&repo=AppStream&infra=stock - %include /tmp/packer_ks/centos-stream/CentOS-9-Stream-x86_64-Vagrant.ks -%pre --interpreter /bin/bash --log /tmp/greg -# This gets us the upstream kickstarter files -cmdline=$(cat /proc/cmdline) -ks=$(printf "${cmdline}" | sed -E -e 's/.*inst\.ks=([^ ]*).*/\1/') -mkdir -p /tmp/packer_ks -cd /tmp/packer_ks -# 3 levels up! -wget -m -nH "$(dirname "$(dirname "${ks}")")" +url --metalink=https://mirrors.centos.org/metalink?arch=x86_64&repo=centos-baseos-9-stream +repo --name=AppStream --metalink=https://mirrors.centos.org/metalink?arch=x86_64&repo=centos-appstream-9-stream +reboot +%pre --interpreter /bin/bash --log /tmp/greg +set -ex # This allows us to support virtualbox +mkdir /tmp/sr1 +mount /dev/sr1 /tmp/sr1 +cp -r /tmp/sr1/http /tmp/packer_ks + if [ ! -e /dev/vda ]; then - sed -i -e 's/drives=vda/drives=sda/' -e 's/ondisk=vda/ondisk=sda/' -e 's/shutdown/reboot/' /tmp/packer_ks/centos-stream/* + sed -i -e 's/drives=vda/drives=sda/' -e 's/ondisk=vda/ondisk=sda/' /tmp/packer_ks/centos-stream/* fi %end diff --git a/http/debian/12-preseed.cfg b/http/debian/12-preseed.cfg new file mode 100644 index 0000000..8878035 --- /dev/null +++ b/http/debian/12-preseed.cfg @@ -0,0 +1,58 @@ +d-i debian-installer/locale string en_US +d-i keyboard-configuration/xkb-keymap select us + +d-i passwd/root-password-again password vagrant +d-i passwd/root-password password vagrant +d-i passwd/user-fullname string vagrant +d-i passwd/username string vagrant +d-i passwd/user-password password vagrant +d-i passwd/user-password-again password vagrant + +d-i time/zone string UTC + +d-i partman-auto/method string regular +d-i partman-auto/expert_recipe string \ + scheme :: \ + 200 0 200 ext4 \ + $primary{ } \ + $bootable{ } \ + method{ format } \ + format{ } \ + use_filesystem{ } \ + filesystem{ ext4 } \ + mountpoint{ /boot } . \ + 200% 0 200% linux-swap \ + $primary{ } \ + method{ swap } \ + format{ } . \ + 1 0 -1 ext4 \ + $primary{ } \ + method{ format } \ + format{ } \ + use_filesystem{ } \ + filesystem{ ext4 } \ + mountpoint{ / } . +d-i partman-partitioning/confirm_write_new_label boolean true +d-i partman/choose_partition select finish +d-i partman/confirm boolean true +d-i partman/confirm_nooverwrite boolean true + +d-i apt-setup/non-free boolean true +d-i apt-setup/contrib boolean true + +tasksel tasksel/first multiselect +d-i pkgsel/include string curl openssh-server sudo python3 + +d-i grub-installer/bootdev string default + +d-i finish-install/reboot_in_progress note + +d-i preseed/early_command string \ + sed -i \ + -e "/in-target/i echo 'd() { /sbin/discover \"\$@\" | grep -v virtualbox; }' > /target/etc/discover-pkginstall.conf" \ + -e "/in-target/i echo 'discover=d' >> /target/etc/discover-pkginstall.conf" \ + /usr/lib/pre-pkgsel.d/20install-hwpackages +d-i preseed/late_command string \ + echo 'Defaults:vagrant !requiretty' > /target/etc/sudoers.d/vagrant; \ + echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /target/etc/sudoers.d/vagrant; \ + chmod 440 /target/etc/sudoers.d/vagrant diff --git a/http/fedora/37-x86_64.ks b/http/fedora/37-x86_64.ks new file mode 100644 index 0000000..2c26abe --- /dev/null +++ b/http/fedora/37-x86_64.ks @@ -0,0 +1,23 @@ +%include /tmp/packer_ks/fedora/f37/fedora-cloud-base-vagrant.ks + +text + +%packages +# There is weirdness with the /etc/resolv.conf in the target system +# that causes some of the imported systems to fail. Hopefully this +# prevents that. +-systemd-resolved +NetworkManager +%end + +%pre --interpreter /bin/bash --log /tmp/greg +set -ex +# This allows us to support virtualbox +mkdir /tmp/sr1 +mount /dev/sr1 /tmp/sr1 +cp -r /tmp/sr1/http /tmp/packer_ks + +if [ ! -e /dev/vda ]; then + ln -s /dev/sda /dev/vda +fi +%end diff --git a/http/fedora/38-x86_64.ks b/http/fedora/38-x86_64.ks new file mode 100644 index 0000000..10f8f9c --- /dev/null +++ b/http/fedora/38-x86_64.ks @@ -0,0 +1,23 @@ +%include /tmp/packer_ks/fedora/f38/fedora-cloud-base-vagrant.ks + +text + +%packages +# There is weirdness with the /etc/resolv.conf in the target system +# that causes some of the imported systems to fail. Hopefully this +# prevents that. +-systemd-resolved +NetworkManager +%end + +%pre --interpreter /bin/bash --log /tmp/greg +set -ex +# This allows us to support virtualbox +mkdir /tmp/sr1 +mount /dev/sr1 /tmp/sr1 +cp -r /tmp/sr1/http /tmp/packer_ks + +if [ ! -e /dev/vda ]; then + ln -s /dev/sda /dev/vda +fi +%end diff --git a/http/fedora/f37 b/http/fedora/f37 new file mode 160000 index 0000000..dc9e3b2 --- /dev/null +++ b/http/fedora/f37 @@ -0,0 +1 @@ +Subproject commit dc9e3b2ceab166a538c0466c126a8b1111d3fa1c diff --git a/http/fedora/f38 b/http/fedora/f38 new file mode 160000 index 0000000..69c726f --- /dev/null +++ b/http/fedora/f38 @@ -0,0 +1 @@ +Subproject commit 69c726f7536cde6acf36697f7ba112ad3107e7ac diff --git a/http/fedora/rawhide b/http/fedora/rawhide index 0d98964..fe345ff 160000 --- a/http/fedora/rawhide +++ b/http/fedora/rawhide @@ -1 +1 @@ -Subproject commit 0d98964c7318e59f4fb7a06d317f385a07034e3c +Subproject commit fe345ff84138ac15d57e518e606fda11b710340d diff --git a/http/ubuntu/20.04/user-data b/http/ubuntu/20.04/user-data index bb48502..8a11855 100644 --- a/http/ubuntu/20.04/user-data +++ b/http/ubuntu/20.04/user-data @@ -2,82 +2,19 @@ # vim: set ft=yaml: autoinstall: version: 1 - apt: - preserve_sources_list: false - primary: - - arches: [i386, amd64] - uri: http://archive.ubuntu.com/ubuntu - - arches: [default] - uri: http://ports.ubuntu.com/ubuntu-ports - geoip: false network: # Should disable networking, workaround for unattended-updates failing in install version: 2 + ethernets: + eth0: + dhcp4: yes + dhcp6: no refresh-installer: update: no keyboard: layout: us - variant: "" toggle: null - storage: - config: - - id: drive - type: disk - ptable: gpt - name: hard-drive - preserve: false - grub_device: true - wipe: superblock - - id: bios-grub - type: partition - device: drive - size: 1M - flag: bios_grub - - id: boot-partition - type: partition - device: drive - size: 1G - name: boot - - id: swap-partition - type: partition - device: drive - size: 10% - name: swap - flag: swap - - id: root-partition - type: partition - device: drive - name: root - size: -1 - - id: boot-format - type: format - fstype: ext4 - volume: boot-partition - label: boot - preserve: false - - id: swap-format - type: format - fstype: swap - volume: swap-partition - label: swap - preserve: false - - id: root-format - type: format - fstype: ext4 - volume: root-partition - label: root - preserve: false - - type: mount - id: root-mount - device: root-format - path: / - - type: mount - id: boot-mount - device: boot-format - path: /boot - - type: mount - id: swap-mount - device: swap-format - path: none + variant: '' + locale: en_US.UTF-8 identity: hostname: vagrant username: vagrant @@ -89,18 +26,17 @@ autoinstall: allow-pw: yes user-data: disable_root: false + package_update: false # These will be done by Ansible after install + package_upgrade: false late-commands: - echo 'Defaults:vagrant !requiretty' > /target/etc/sudoers.d/vagrant - echo 'vagrant ALL=(ALL) NOPASSWD:ALL' >> /target/etc/sudoers.d/vagrant - chmod 440 /target/etc/sudoers.d/vagrant # Restore network after bypassing unattended updates - - "echo -n 'network:\n version: 2\n ethernets:\n eth0:\n dhcp4: true\n dhcp-identifier: mac' > /target/etc/netplan/00-installer-config.yaml" - - netplan apply - sed -i -E -e 's/GRUB_CMDLINE_LINUX="(.*)"/GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevnames=0\1"/' /target/etc/default/grub - - mount -o bind /dev /target/dev - - mount -o bind /sys /target/sys - - mount -o bind /proc /target/proc - - chroot /target /usr/sbin/update-grub + - curtin in-target --target=/target -- update-grub + - curtin in-target --target=/target -- logger "finished late-commands" packages: + - ca-certificates - curl - sudo diff --git a/http/ubuntu/22.04/user-data b/http/ubuntu/22.04/user-data index 47dd1dc..630f310 100644 --- a/http/ubuntu/22.04/user-data +++ b/http/ubuntu/22.04/user-data @@ -4,70 +4,17 @@ autoinstall: version: 1 network: # Should disable networking, workaround for unattended-updates failing in install version: 2 + ethernets: + eth0: + dhcp4: yes + dhcp6: no refresh-installer: update: no keyboard: layout: us - storage: - config: - - id: drive - type: disk - ptable: gpt - name: hard-drive - preserve: false - grub_device: true - wipe: superblock - - id: bios-grub - type: partition - device: drive - size: 1M - flag: bios_grub - - id: boot-partition - type: partition - device: drive - size: 1G - name: boot - - id: swap-partition - type: partition - device: drive - size: 10% - name: swap - flag: swap - - id: root-partition - type: partition - device: drive - name: root - size: -1 - - id: boot-format - type: format - fstype: ext4 - volume: boot-partition - label: boot - preserve: false - - id: swap-format - type: format - fstype: swap - volume: swap-partition - label: swap - preserve: false - - id: root-format - type: format - fstype: ext4 - volume: root-partition - label: root - preserve: false - - type: mount - id: root-mount - device: root-format - path: / - - type: mount - id: boot-mount - device: boot-format - path: /boot - - type: mount - id: swap-mount - device: swap-format - path: none + toggle: null + variant: '' + locale: en_US.UTF-8 identity: hostname: vagrant username: vagrant @@ -79,18 +26,17 @@ autoinstall: allow-pw: yes user-data: disable_root: false + package_update: false + package_upgrade: false late-commands: - echo 'Defaults:vagrant !requiretty' > /target/etc/sudoers.d/vagrant - echo 'vagrant ALL=(ALL) NOPASSWD:ALL' >> /target/etc/sudoers.d/vagrant - chmod 440 /target/etc/sudoers.d/vagrant # Restore network after bypassing unattended updates - - "echo -n 'network:\n version: 2\n ethernets:\n eth0:\n dhcp4: true\n dhcp-identifier: mac' > /target/etc/netplan/00-installer-config.yaml" - - netplan apply - sed -i -E -e 's/GRUB_CMDLINE_LINUX="(.*)"/GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevnames=0\1"/' /target/etc/default/grub - - mount -o bind /dev /target/dev - - mount -o bind /sys /target/sys - - mount -o bind /proc /target/proc - - chroot /target /usr/sbin/update-grub + - curtin in-target --target=/target -- update-grub + - curtin in-target --target=/target -- logger "finished late-commands" packages: + - ca-certificates - curl - sudo diff --git a/sources/build.pkr.hcl b/sources/build.pkr.hcl index 661b47a..d03eb3f 100644 --- a/sources/build.pkr.hcl +++ b/sources/build.pkr.hcl @@ -1,3 +1,20 @@ +packer { + required_plugins { + qemu = { + source = "github.com/hashicorp/qemu" + version = "~> 1" + } + ansible = { + source = "github.com/hashicorp/ansible" + version = "~> 1" + } + vagrant = { + source = "github.com/hashicorp/vagrant" + version = "~> 1" + } + } +} + build { sources = [ "source.qemu.x86_64", @@ -10,9 +27,9 @@ build { user = local.ssh.username use_sftp = true ansible_ssh_extra_args = [ - "-o HostKeyAlgorithms=+ssh-rsa ", - "-o PubkeyAcceptedKeyTypes=+ssh-rsa ", - "-o IdentitiesOnly=yes" + #"-o", "HostKeyAlgorithms=+ssh-rsa", + #"-o", "PubkeyAcceptedKeyTypes=+ssh-rsa", + "-o", "IdentitiesOnly=yes" ] } diff --git a/sources/inputs.pkr.hcl b/sources/inputs.pkr.hcl index 903b200..29f314f 100644 --- a/sources/inputs.pkr.hcl +++ b/sources/inputs.pkr.hcl @@ -49,6 +49,16 @@ variable "build" { default = "0.1" } +variable "cd_files" { + type = list(string) + default = [] +} + +variable "cd_label" { + type = string + default = "cidata" +} + locals { name = "${var.distro}-${var.version}-${var.arch}" description = templatefile("../README.box.md", { @@ -66,5 +76,6 @@ locals { password = "vagrant" handshake_attempts = 1000 timeout = "5h45m" + private_key_file = "vagrant/insecure_key" } } diff --git a/sources/qemu.pkr.hcl b/sources/qemu.pkr.hcl index 270fe93..1082a23 100644 --- a/sources/qemu.pkr.hcl +++ b/sources/qemu.pkr.hcl @@ -15,6 +15,7 @@ source "qemu" "x86_64" { ssh_username = local.ssh.username ssh_password = local.ssh.password ssh_handshake_attempts = local.ssh.handshake_attempts + ssh_private_key_file = local.ssh.private_key_file vm_name = "packer-${local.name}" disk_size = "${local.disk_size}G" @@ -23,11 +24,15 @@ source "qemu" "x86_64" { headless = var.headless disk_cache = "writeback" format = "qcow2" + cpu_model = "host" qemuargs = [ ["-chardev", "stdio,id=char0,logfile=serial-output-qemu-${var.arch}-${var.distro}-${var.version},signal=off"], ["-serial", "chardev:char0"] ] - http_directory = "http" accelerator = var.qemu_accelerator + + http_directory = "http" + cd_files = var.cd_files + cd_label = var.cd_label } diff --git a/sources/virtualbox-iso.pkr.hcl b/sources/virtualbox-iso.pkr.hcl index dd7c11c..65061cf 100644 --- a/sources/virtualbox-iso.pkr.hcl +++ b/sources/virtualbox-iso.pkr.hcl @@ -18,13 +18,15 @@ source "virtualbox-iso" "x86_64" { cpus = local.cpus memory = local.memory headless = var.headless - guest_os_type = "${var.distro}_64" - guest_additions_url = "http://download.virtualbox.org/virtualbox/6.1.34/VBoxGuestAdditions_6.1.34.iso" - guest_additions_sha256 = "88f86fa0e6970b6a7c80d714b7a91a8c425ff8ef53a3e73fc80781191a87257b" + nic_type = "virtio" + guest_os_type = "RedHat_64" + guest_additions_url = "http://download.virtualbox.org/virtualbox/7.0.10/VBoxGuestAdditions_7.0.10.iso" + guest_additions_sha256 = "bbabd89b8fff38a257bab039a278f0c4dc4426eff6e4238c1db01edb7284186a" vboxmanage = [ ["modifyvm", "{{ .Name }}", "--uart1", "0x3F8", "4"], ["modifyvm", "{{ .Name }}", "--uartmode1", "file", "serial-output-virtualbox-${var.arch}-${var.distro}-${var.version}"] ] http_directory = "http" + cd_files = [ "http/${var.cd_files_path}" ] } diff --git a/test.sh b/test.sh deleted file mode 100755 index d30e590..0000000 --- a/test.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!env bash - -set -exo pipefail - -build="${1}" -provider=virtualbox-iso.x86_64 -#provider=qemu.x86_64 - -packer build -on-error=ask -var headless=false -var-file distros/${build}.pkrvars.hcl -except=upload -only=${provider} sources/ -vagrant box add -f --name test ${build}.box -vagrant up -vagrant ssh -c "ls -la ~/" -vagrant destroy -f diff --git a/test.xsh b/test.xsh new file mode 100755 index 0000000..1b98ce7 --- /dev/null +++ b/test.xsh @@ -0,0 +1,59 @@ +#!env xonsh +# vim: set ft=xonsh: +import argparse +import pathlib +import re +import time + + +def get_vagrant_provider(provider): + "Vagrant provider is not always the same as Packer provider" + if provider.startswith("qemu"): + return "libvirt" + elif provider.startswith("virtualbox"): + return "virtualbox" + + +def get_providers(): + "List of providers as defined in sources/" + providers: list[str] = [ + "virtualbox-iso.x86_64", + "qemu.x86_64" + ] + return providers + + +def get_builds(): + "List of builds as supported in distros/" + base = pathlib.Path(__file__) + distros = base.parent / "distros" + builds = [str(p.stem).rsplit(".", 1)[0] for p in distros.glob("**/*.pkrvars.hcl")] + return builds + +def main(): + # Equivalent of `set -e` in Bash + $RAISE_SUBPROC_ERROR = True + + # Parse user arguments + parser = argparse.ArgumentParser("Test script") + parser.add_argument("--build", "-b", required=True, choices=get_builds()) + parser.add_argument("--provider", "-p", default="virtualbox-iso.x86_64", choices=get_providers()) + parser.add_argument("--headless", action="store_true") + args = parser.parse_args() + + if args.headless: + headless = "headless=true" + else: + headless = "headless=false" + + packer build -var @(headless) -var-file distros/@(args.build).pkrvars.hcl -except=upload -only=@(args.provider) sources/ + vagrant box add --force --name @(args.build) @(args.build).box + sed -e f's/@@BOX@@/{args.build}/' Vagrantfile.in > Vagrantfile + vagrant up --provider @(get_vagrant_provider(args.provider)) --provision + vagrant ssh -c "ls -la ~/" + vagrant destroy -f + rm -r .vagrant + + +if __name__ == '__main__': + main() diff --git a/test_qemu.xsh b/test_qemu.xsh new file mode 100755 index 0000000..13ba54f --- /dev/null +++ b/test_qemu.xsh @@ -0,0 +1,16 @@ +#!/usr/bin/env xonsh +source test.xsh + +def main(): + # Equivalent of `set -e` in Bash + $RAISE_SUBPROC_ERROR = True + for distro in get_builds(): + print(f"Trying {distro}") + ./test.xsh -b @(distro) -p qemu.x86_64 --headless + rm -r serial-output-qemu* output_qemu* *.box + for x in range(10): + print("***" * 20) + + +if __name__ == '__main__': + main() diff --git a/vagrant/x86_64.rb b/vagrant/x86_64.rb index d215f5a..4189b5f 100644 --- a/vagrant/x86_64.rb +++ b/vagrant/x86_64.rb @@ -5,9 +5,11 @@ Vagrant.configure('2') do |c| v.driver = 'kvm' v.connect_via_ssh = false v.username = 'root' + v.memory = 2048 end c.vm.provider :virtualbox do |v| v.gui = false + v.memory = 2048 end c.vm.provider :vmware_fusion do |v| v.gui = false