diff --git a/del_boxes.xsh b/del_boxes.xsh index 8e0c1e6..da91686 100755 --- a/del_boxes.xsh +++ b/del_boxes.xsh @@ -2,4 +2,5 @@ virsh -q vol-list default | awk '{print $1}' | xargs -r -L 1 virsh vol-delete --pool default sudo virsh -q vol-list default | awk '{print $1}' | sudo xargs -r -L 1 virsh vol-delete --pool default -vagrant box list | awk '{print $1}' | xargs -r -L 1 vagrant box remove +vagrant box list | awk '{print $1}' | sort -u | xargs -l vagrant box remove --provider virtualbox +vagrant box list | awk '{print $1}' | sort -u | xargs -l vagrant box remove --provider libvirt diff --git a/distros/centos-stream/8/build.xsh b/distros/centos-stream/8/build.xsh deleted file mode 100755 index c4058ed..0000000 --- a/distros/centos-stream/8/build.xsh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env xonsh -$RAISE_SUBPROC_ERROR = True -from pathlib import Path -import sys -self = Path(__file__).absolute() -base = self.parent.parent.parent.parent -source @(base / "test.xsh") - - -opts = get_parser(sys.argv[1:]) - -cd @(str(base)) -for provider in opts["providers"]: - packer build -var=@(opts["headless"]) -var-file=@(self.parent / "x86_64.pkrvars.hcl") @(opts["upload"]) -only=@(provider) @(base / "sources") diff --git a/distros/centos-stream/8/disc/ks.cfg b/distros/centos-stream/8/disc/ks.cfg new file mode 100644 index 0000000..283b7b8 --- /dev/null +++ b/distros/centos-stream/8/disc/ks.cfg @@ -0,0 +1,155 @@ +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 +network --bootproto=dhcp --activate +reboot + +text +keyboard --vckeymap us +lang en_US +skipx +rootpw --plaintext vagrant +firewall --disabled +timezone --utc UTC +services --enabled=vmtoolsd +# The biosdevname and ifnames options ensure we get "eth0" as our interface +# even in environments like virtualbox that emulate a real NW card +bootloader --timeout=1 --append="no_timer_check console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 elevator=noop" +zerombr +clearpart --all +part / --fstype=xfs --asprimary --size=1024 --grow + +user --name=vagrant --plaintext --password=vagrant + +%packages --instLangs=en +bash-completion +man-pages +bzip2 +rsync +nfs-utils +cifs-utils +chrony +yum-utils +hyperv-daemons +open-vm-tools +# Vagrant boxes aren't normally visible, no need for Plymouth +-plymouth +# Microcode updates cannot work in a VM +-microcode_ctl +# Firmware packages are not needed in a VM +-iwl100-firmware +-iwl1000-firmware +-iwl105-firmware +-iwl135-firmware +-iwl2000-firmware +-iwl2030-firmware +-iwl3160-firmware +-iwl3945-firmware +-iwl4965-firmware +-iwl5000-firmware +-iwl5150-firmware +-iwl6000-firmware +-iwl6000g2a-firmware +-iwl6050-firmware +-iwl7260-firmware +# Don't build rescue initramfs +-dracut-config-rescue +%end + +# kdump needs to reserve 160MB + 2bits/4kB RAM, and automatic allocation only +# works on systems with at least 2GB RAM (which excludes most Vagrant boxes) +# CBS doesn't support %addon yet https://bugs.centos.org/view.php?id=12169 +%addon com_redhat_kdump --disable +%end + +%post +# configure swap to a file +fallocate -l 2G /swapfile +chmod 600 /swapfile +mkswap /swapfile +echo "/swapfile none swap defaults 0 0" >> /etc/fstab + +# sudo +echo "%vagrant ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/vagrant +chmod 0440 /etc/sudoers.d/vagrant + +# Fix for https://github.com/CentOS/sig-cloud-instance-build/issues/38 +cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF +DEVICE="eth0" +BOOTPROTO="dhcp" +ONBOOT="yes" +TYPE="Ethernet" +PERSISTENT_DHCLIENT="yes" +EOF + +# sshd: disable password authentication and DNS checks +ex -s /etc/ssh/sshd_config <>/etc/sysconfig/sshd <> /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 +/^account\s\+sufficient\s\+pam_succeed_if.so uid = 0 use_uid quiet$/ +:append +account [success=1 default=ignore] \\ + pam_succeed_if.so user = vagrant use_uid quiet +account required pam_succeed_if.so user notin root:vagrant +. +:update +:quit +EOF + +# systemd should generate a new machine id during the first boot, to +# avoid having multiple Vagrant instances with the same id in the local +# network. /etc/machine-id should be empty, but it must exist to prevent +# boot errors (e.g. systemd-journald failing to start). +:>/etc/machine-id + +echo 'vag' > /etc/yum/vars/infra + +# Blacklist the floppy module to avoid probing timeouts +echo blacklist floppy > /etc/modprobe.d/nofloppy.conf +chcon -u system_u -r object_r -t modules_conf_t /etc/modprobe.d/nofloppy.conf + +# Customize the initramfs +pushd /etc/dracut.conf.d +# Enable VMware PVSCSI support for VMware Fusion guests. +echo 'add_drivers+=" vmw_pvscsi "' > vmware-fusion-drivers.conf +echo 'add_drivers+=" hv_netvsc hv_storvsc hv_utils hv_vmbus hid-hyperv "' > hyperv-drivers.conf +# There's no floppy controller, but probing for it generates timeouts +echo 'omit_drivers+=" floppy "' > nofloppy.conf +popd +# Fix the SELinux context of the new files +restorecon -f - <" ] -cd_files = { - "ks.cfg" = <> /etc/fstab - -# sudo -echo "%vagrant ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/vagrant -chmod 0440 /etc/sudoers.d/vagrant - -# Fix for https://github.com/CentOS/sig-cloud-instance-build/issues/38 -cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF -DEVICE="eth0" -BOOTPROTO="dhcp" -ONBOOT="yes" -TYPE="Ethernet" -PERSISTENT_DHCLIENT="yes" -EOF - -# sshd: disable password authentication and DNS checks -ex -s /etc/ssh/sshd_config <>/etc/sysconfig/sshd <> /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 -/^account\s\+sufficient\s\+pam_succeed_if.so uid = 0 use_uid quiet$/ -:append -account [success=1 default=ignore] \\ - pam_succeed_if.so user = vagrant use_uid quiet -account required pam_succeed_if.so user notin root:vagrant -. -:update -:quit -EOF - -# systemd should generate a new machine id during the first boot, to -# avoid having multiple Vagrant instances with the same id in the local -# network. /etc/machine-id should be empty, but it must exist to prevent -# boot errors (e.g. systemd-journald failing to start). -:>/etc/machine-id - -echo 'vag' > /etc/yum/vars/infra - -# Blacklist the floppy module to avoid probing timeouts -echo blacklist floppy > /etc/modprobe.d/nofloppy.conf -chcon -u system_u -r object_r -t modules_conf_t /etc/modprobe.d/nofloppy.conf - -# Customize the initramfs -pushd /etc/dracut.conf.d -# Enable VMware PVSCSI support for VMware Fusion guests. -echo 'add_drivers+=" vmw_pvscsi "' > vmware-fusion-drivers.conf -echo 'add_drivers+=" hv_netvsc hv_storvsc hv_utils hv_vmbus hid-hyperv "' > hyperv-drivers.conf -# There's no floppy controller, but probing for it generates timeouts -echo 'omit_drivers+=" floppy "' > nofloppy.conf -popd -# Fix the SELinux context of the new files -restorecon -f - <" ] -cd_files = { - "ks.cfg" = <> /etc/fstab - -# sudo -echo "%vagrant ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/vagrant -chmod 0440 /etc/sudoers.d/vagrant - -# Fix for https://github.com/CentOS/sig-cloud-instance-build/issues/38 -cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF -DEVICE="eth0" -BOOTPROTO="dhcp" -ONBOOT="yes" -TYPE="Ethernet" -PERSISTENT_DHCLIENT="yes" -EOF - -# sshd: disable password authentication and DNS checks -ex -s /etc/ssh/sshd_config <>/etc/sysconfig/sshd <> /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 -/^account\s\+sufficient\s\+pam_succeed_if.so uid = 0 use_uid quiet\$/ -:append -account [success=1 default=ignore] \\ - pam_succeed_if.so user = vagrant use_uid quiet -account required pam_succeed_if.so user notin root:vagrant -. -:update -:quit -EOF - -# systemd should generate a new machine id during the first boot, to -# avoid having multiple Vagrant instances with the same id in the local -# network. /etc/machine-id should be empty, but it must exist to prevent -# boot errors (e.g. systemd-journald failing to start). -:>/etc/machine-id - -echo 'vag' > /etc/yum/vars/infra - -# Blacklist the floppy module to avoid probing timeouts -echo blacklist floppy > /etc/modprobe.d/nofloppy.conf -chcon -u system_u -r object_r -t modules_conf_t /etc/modprobe.d/nofloppy.conf - -# Customize the initramfs -pushd /etc/dracut.conf.d -# Enable VMware PVSCSI support for VMware Fusion guests. -echo 'add_drivers+=" vmw_pvscsi "' > vmware-fusion-drivers.conf -echo 'add_drivers+=" hv_netvsc hv_storvsc hv_utils hv_vmbus hid-hyperv "' > hyperv-drivers.conf -# There's no floppy controller, but probing for it generates timeouts -echo 'omit_drivers+=" floppy "' > nofloppy.conf -popd -# Fix the SELinux context of the new files -restorecon -f - < /tmp/disks.ks +echo "part / --fstype=ext4 --asprimary --size=1024 --grow --ondisk=$disk" >> /tmp/disks.ks +%end + +user --name=vagrant --plaintext --password=vagrant + +%packages --inst-langs=en +bash-completion +man-pages +bzip2 +rsync +nfs-utils +cifs-utils +chrony +yum-utils +hyperv-daemons +open-vm-tools +# Vagrant boxes aren't normally visible, no need for Plymouth +-plymouth +# Microcode updates cannot work in a VM +-microcode_ctl +# Firmware packages are not needed in a VM +-iwl100-firmware +-iwl1000-firmware +-iwl105-firmware +-iwl135-firmware +-iwl2000-firmware +-iwl2030-firmware +-iwl3160-firmware +-iwl3945-firmware +-iwl4965-firmware +-iwl5000-firmware +-iwl5150-firmware +-iwl6000-firmware +-iwl6000g2a-firmware +-iwl6050-firmware +-iwl7260-firmware +# Don't build rescue initramfs +-dracut-config-rescue +%end + +# kdump needs to reserve 160MB + 2bits/4kB RAM, and automatic allocation only +# works on systems with at least 2GB RAM (which excludes most Vagrant boxes) +# CBS doesn't support %addon yet https://bugs.centos.org/view.php?id=12169 +%addon com_redhat_kdump --disable +%end + +%post +# configure swap to a file +fallocate -l 2G /swapfile +chmod 600 /swapfile +mkswap /swapfile +echo "/swapfile none swap defaults 0 0" >> /etc/fstab + +# sudo +echo "%vagrant ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/vagrant +chmod 0440 /etc/sudoers.d/vagrant + +# Fix for https://github.com/CentOS/sig-cloud-instance-build/issues/38 +cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF +DEVICE="eth0" +BOOTPROTO="dhcp" +ONBOOT="yes" +TYPE="Ethernet" +PERSISTENT_DHCLIENT="yes" +EOF + +# sshd: disable password authentication and DNS checks +ex -s /etc/ssh/sshd_config <>/etc/sysconfig/sshd <> /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 +/^account\s\+sufficient\s\+pam_succeed_if.so uid = 0 use_uid quiet$/ +:append +account [success=1 default=ignore] \ + pam_succeed_if.so user = vagrant use_uid quiet +account required pam_succeed_if.so user notin root:vagrant +. +:update +:quit +EOF + +# systemd should generate a new machine id during the first boot, to +# avoid having multiple Vagrant instances with the same id in the local +# network. /etc/machine-id should be empty, but it must exist to prevent +# boot errors (e.g. systemd-journald failing to start). +:>/etc/machine-id + +echo 'vag' > /etc/yum/vars/infra + +# Blacklist the floppy module to avoid probing timeouts +echo blacklist floppy > /etc/modprobe.d/nofloppy.conf +chcon -u system_u -r object_r -t modules_conf_t /etc/modprobe.d/nofloppy.conf + +# Customize the initramfs +pushd /etc/dracut.conf.d +# Enable VMware PVSCSI support for VMware Fusion guests. +echo 'add_drivers+=" vmw_pvscsi "' > vmware-fusion-drivers.conf +echo 'add_drivers+=" hv_netvsc hv_storvsc hv_utils hv_vmbus hid-hyperv "' > hyperv-drivers.conf +# There's no floppy controller, but probing for it generates timeouts +echo 'omit_drivers+=" floppy "' > nofloppy.conf +popd +# Fix the SELinux context of the new files +restorecon -f - <", "inst.text inst.ks=cdrom:/ks.cfg console=tty0", "" ] -cd_files = { - "ks.cfg" = < /tmp/disks.ks -echo "part / --fstype=ext4 --asprimary --size=1024 --grow --ondisk=$disk" >> /tmp/disks.ks -%end - -user --name=vagrant --plaintext --password=vagrant - -%packages --inst-langs=en -bash-completion -man-pages -bzip2 -rsync -nfs-utils -cifs-utils -chrony -yum-utils -hyperv-daemons -open-vm-tools -# Vagrant boxes aren't normally visible, no need for Plymouth --plymouth -# Microcode updates cannot work in a VM --microcode_ctl -# Firmware packages are not needed in a VM --iwl100-firmware --iwl1000-firmware --iwl105-firmware --iwl135-firmware --iwl2000-firmware --iwl2030-firmware --iwl3160-firmware --iwl3945-firmware --iwl4965-firmware --iwl5000-firmware --iwl5150-firmware --iwl6000-firmware --iwl6000g2a-firmware --iwl6050-firmware --iwl7260-firmware -# Don't build rescue initramfs --dracut-config-rescue -%end - -# kdump needs to reserve 160MB + 2bits/4kB RAM, and automatic allocation only -# works on systems with at least 2GB RAM (which excludes most Vagrant boxes) -# CBS doesn't support %addon yet https://bugs.centos.org/view.php?id=12169 -%addon com_redhat_kdump --disable -%end - -%post -# configure swap to a file -fallocate -l 2G /swapfile -chmod 600 /swapfile -mkswap /swapfile -echo "/swapfile none swap defaults 0 0" >> /etc/fstab - -# sudo -echo "%vagrant ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/vagrant -chmod 0440 /etc/sudoers.d/vagrant - -# Fix for https://github.com/CentOS/sig-cloud-instance-build/issues/38 -cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF -DEVICE="eth0" -BOOTPROTO="dhcp" -ONBOOT="yes" -TYPE="Ethernet" -PERSISTENT_DHCLIENT="yes" -EOF - -# sshd: disable password authentication and DNS checks -ex -s /etc/ssh/sshd_config <>/etc/sysconfig/sshd <> /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 -/^account\s\+sufficient\s\+pam_succeed_if.so uid = 0 use_uid quiet$/ -:append -account [success=1 default=ignore] \ - pam_succeed_if.so user = vagrant use_uid quiet -account required pam_succeed_if.so user notin root:vagrant -. -:update -:quit -EOF - -# systemd should generate a new machine id during the first boot, to -# avoid having multiple Vagrant instances with the same id in the local -# network. /etc/machine-id should be empty, but it must exist to prevent -# boot errors (e.g. systemd-journald failing to start). -:>/etc/machine-id - -echo 'vag' > /etc/yum/vars/infra - -# Blacklist the floppy module to avoid probing timeouts -echo blacklist floppy > /etc/modprobe.d/nofloppy.conf -chcon -u system_u -r object_r -t modules_conf_t /etc/modprobe.d/nofloppy.conf - -# Customize the initramfs -pushd /etc/dracut.conf.d -# Enable VMware PVSCSI support for VMware Fusion guests. -echo 'add_drivers+=" vmw_pvscsi "' > vmware-fusion-drivers.conf -echo 'add_drivers+=" hv_netvsc hv_storvsc hv_utils hv_vmbus hid-hyperv "' > hyperv-drivers.conf -# There's no floppy controller, but probing for it generates timeouts -echo 'omit_drivers+=" floppy "' > nofloppy.conf -popd -# Fix the SELinux context of the new files -restorecon -f - <" ] -cd_files = { - "ks.cfg" = < /tmp/disks.ks -echo "part / --fstype=ext4 --asprimary --size=1024 --grow --ondisk=\$disk" >> /tmp/disks.ks -%end - -user --name=vagrant --plaintext --password=vagrant - -%packages --inst-langs=en -bash-completion -man-pages -bzip2 -rsync -nfs-utils -cifs-utils -chrony -yum-utils -hyperv-daemons -open-vm-tools -# Vagrant boxes aren't normally visible, no need for Plymouth --plymouth -# Microcode updates cannot work in a VM --microcode_ctl -# Firmware packages are not needed in a VM --iwl100-firmware --iwl1000-firmware --iwl105-firmware --iwl135-firmware --iwl2000-firmware --iwl2030-firmware --iwl3160-firmware --iwl3945-firmware --iwl4965-firmware --iwl5000-firmware --iwl5150-firmware --iwl6000-firmware --iwl6000g2a-firmware --iwl6050-firmware --iwl7260-firmware -# Don't build rescue initramfs --dracut-config-rescue -%end - -# kdump needs to reserve 160MB + 2bits/4kB RAM, and automatic allocation only -# works on systems with at least 2GB RAM (which excludes most Vagrant boxes) -# CBS doesn't support %addon yet https://bugs.centos.org/view.php?id=12169 -%addon com_redhat_kdump --disable -%end - -%post -# configure swap to a file -fallocate -l 2G /swapfile -chmod 600 /swapfile -mkswap /swapfile -echo "/swapfile none swap defaults 0 0" >> /etc/fstab - -# sudo -echo "%vagrant ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/vagrant -chmod 0440 /etc/sudoers.d/vagrant - -# Fix for https://github.com/CentOS/sig-cloud-instance-build/issues/38 -cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF -DEVICE="eth0" -BOOTPROTO="dhcp" -ONBOOT="yes" -TYPE="Ethernet" -PERSISTENT_DHCLIENT="yes" -EOF - -# sshd: disable password authentication and DNS checks -ex -s /etc/ssh/sshd_config <>/etc/sysconfig/sshd <> /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 -/^account\s\+sufficient\s\+pam_succeed_if.so uid = 0 use_uid quiet\$/ -:append -account [success=1 default=ignore] \\ - pam_succeed_if.so user = vagrant use_uid quiet -account required pam_succeed_if.so user notin root:vagrant -. -:update -:quit -EOF - -# systemd should generate a new machine id during the first boot, to -# avoid having multiple Vagrant instances with the same id in the local -# network. /etc/machine-id should be empty, but it must exist to prevent -# boot errors (e.g. systemd-journald failing to start). -:>/etc/machine-id - -echo 'vag' > /etc/yum/vars/infra - -# Blacklist the floppy module to avoid probing timeouts -echo blacklist floppy > /etc/modprobe.d/nofloppy.conf -chcon -u system_u -r object_r -t modules_conf_t /etc/modprobe.d/nofloppy.conf - -# Customize the initramfs -pushd /etc/dracut.conf.d -# Enable VMware PVSCSI support for VMware Fusion guests. -echo 'add_drivers+=" vmw_pvscsi "' > vmware-fusion-drivers.conf -echo 'add_drivers+=" hv_netvsc hv_storvsc hv_utils hv_vmbus hid-hyperv "' > hyperv-drivers.conf -# There's no floppy controller, but probing for it generates timeouts -echo 'omit_drivers+=" floppy "' > nofloppy.conf -popd -# Fix the SELinux context of the new files -restorecon -f - < /etc/sudoers.d/vagrant +Defaults:vagrant !requiretty +vagrant ALL=(ALL) NOPASSWD: ALL +EOF +chmod 440 /etc/sudoers.d/vagrant + +ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules +cat > /etc/sysconfig/network-scripts/ifcfg-eth0 < inst.ks=cdrom:/ks.cfg console=tty0", "" ] -cd_files = { - "ks.cfg" = < /etc/sudoers.d/vagrant -Defaults:vagrant !requiretty -vagrant ALL=(ALL) NOPASSWD: ALL -EOF -chmod 440 /etc/sudoers.d/vagrant - -ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules -cat > /etc/sysconfig/network-scripts/ifcfg-eth0 < /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/distros/debian/10/x86_64.pkrvars.hcl b/distros/debian/10/x86_64.pkrvars.hcl index 429f9b6..58ae6cf 100644 --- a/distros/debian/10/x86_64.pkrvars.hcl +++ b/distros/debian/10/x86_64.pkrvars.hcl @@ -13,65 +13,4 @@ boot_command = [ "--- net.ifnames=0 biosdevnames=0 ", "" ] -http_files = { - "/preseed.cfg" = < /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 -KICKSTART -} +http_directory = "distros/debian/10/http/" diff --git a/distros/debian/11/build.xsh b/distros/debian/11/build.xsh deleted file mode 100755 index cdb9b50..0000000 --- a/distros/debian/11/build.xsh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env xonsh -$RAISE_SUBPROC_ERROR = True -from pathlib import Path -import sys -self = Path(__file__).absolute() -base = self.parent.parent.parent.parent -source @(base / "test.xsh") - - -unsupported = set({ - "virtualbox-iso.x86_64" -}) - -opts = get_parser(sys.argv[1:], unsupported) - -cd @(str(base)) -for provider in opts["providers"]: - packer build -var=@(opts["headless"]) -var-file=@(self.parent / "x86_64.pkrvars.hcl") @(opts["upload"]) -only=@(provider) @(base / "sources") diff --git a/distros/debian/11/http/preseed.cfg b/distros/debian/11/http/preseed.cfg new file mode 100644 index 0000000..8a20817 --- /dev/null +++ b/distros/debian/11/http/preseed.cfg @@ -0,0 +1,64 @@ +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; \ + sed -i -e 's/ens3/ens5/g' /target/etc/network/interfaces + +#echo '[Match]' >> /target/etc/systemd/network/dhcp.network; \ +#echo 'Name=en*' >> /target/etc/systemd/network/dhcp.network; \ +#echo '[Network]' >> /target/etc/systemd/network/dhcp.network; \ +#echo 'DHCP=yes' >> /target/etc/systemd/network/dhcp.network; \ diff --git a/distros/debian/11/x86_64.pkrvars.hcl b/distros/debian/11/x86_64.pkrvars.hcl index fe1e9e3..d722830 100644 --- a/distros/debian/11/x86_64.pkrvars.hcl +++ b/distros/debian/11/x86_64.pkrvars.hcl @@ -13,70 +13,4 @@ boot_command = [ "--- net.ifnames=0 biosdevnames=0 ", "" ] -http_files = { - "/preseed.cfg" = < /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; \ - sed -i -e 's/ens3/ens5/g' /target/etc/network/interfaces -KICKSTART -} -#echo '[Match]' >> /target/etc/systemd/network/dhcp.network; \ -#echo 'Name=en*' >> /target/etc/systemd/network/dhcp.network; \ -#echo '[Network]' >> /target/etc/systemd/network/dhcp.network; \ -#echo 'DHCP=yes' >> /target/etc/systemd/network/dhcp.network; \ +http_directory = "distros/debian/11/http/" diff --git a/distros/debian/12/build.xsh b/distros/debian/12/build.xsh deleted file mode 100755 index cdb9b50..0000000 --- a/distros/debian/12/build.xsh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env xonsh -$RAISE_SUBPROC_ERROR = True -from pathlib import Path -import sys -self = Path(__file__).absolute() -base = self.parent.parent.parent.parent -source @(base / "test.xsh") - - -unsupported = set({ - "virtualbox-iso.x86_64" -}) - -opts = get_parser(sys.argv[1:], unsupported) - -cd @(str(base)) -for provider in opts["providers"]: - packer build -var=@(opts["headless"]) -var-file=@(self.parent / "x86_64.pkrvars.hcl") @(opts["upload"]) -only=@(provider) @(base / "sources") diff --git a/distros/debian/12/http/preseed.cfg b/distros/debian/12/http/preseed.cfg new file mode 100644 index 0000000..7e5ea02 --- /dev/null +++ b/distros/debian/12/http/preseed.cfg @@ -0,0 +1,59 @@ +d-i auto-install/enable boolean true +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/distros/debian/12/x86_64.pkrvars.hcl b/distros/debian/12/x86_64.pkrvars.hcl index 59ad1b4..accb654 100644 --- a/distros/debian/12/x86_64.pkrvars.hcl +++ b/distros/debian/12/x86_64.pkrvars.hcl @@ -13,66 +13,4 @@ boot_command = [ "--- net.ifnames=0 biosdevnames=0 ", "" ] -http_files = { - "/preseed.cfg" = < /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 -KICKSTART -} +http_directory = "distros/debian/12/http/" diff --git a/distros/debian/9/build.xsh b/distros/debian/9/build.xsh deleted file mode 100755 index cdb9b50..0000000 --- a/distros/debian/9/build.xsh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env xonsh -$RAISE_SUBPROC_ERROR = True -from pathlib import Path -import sys -self = Path(__file__).absolute() -base = self.parent.parent.parent.parent -source @(base / "test.xsh") - - -unsupported = set({ - "virtualbox-iso.x86_64" -}) - -opts = get_parser(sys.argv[1:], unsupported) - -cd @(str(base)) -for provider in opts["providers"]: - packer build -var=@(opts["headless"]) -var-file=@(self.parent / "x86_64.pkrvars.hcl") @(opts["upload"]) -only=@(provider) @(base / "sources") diff --git a/distros/debian/9/http/preseed.cfg b/distros/debian/9/http/preseed.cfg new file mode 100644 index 0000000..d61b72e --- /dev/null +++ b/distros/debian/9/http/preseed.cfg @@ -0,0 +1,66 @@ +d-i mirror/country string manual +d-i mirror/http/hostname string archive.kernel.org +d-i mirror/http/directory string /debian-archive/debian + +d-i apt-setup/security_host string archive.kernel.org/debian-archive + +d-i netcfg/hostname string vagrant + +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/distros/debian/9/x86_64.pkrvars.hcl b/distros/debian/9/x86_64.pkrvars.hcl index 9941ac0..96907ba 100644 --- a/distros/debian/9/x86_64.pkrvars.hcl +++ b/distros/debian/9/x86_64.pkrvars.hcl @@ -15,74 +15,4 @@ boot_command = [ "net.ifnames=0 ", "" ] -http_files = { - "/preseed.cfg" = < /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 - -KICKSTART -} +http_directory = "distros/debian/9/http/" diff --git a/distros/ubuntu/18.04/build.xsh b/distros/ubuntu/18.04/build.xsh deleted file mode 100755 index c4058ed..0000000 --- a/distros/ubuntu/18.04/build.xsh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env xonsh -$RAISE_SUBPROC_ERROR = True -from pathlib import Path -import sys -self = Path(__file__).absolute() -base = self.parent.parent.parent.parent -source @(base / "test.xsh") - - -opts = get_parser(sys.argv[1:]) - -cd @(str(base)) -for provider in opts["providers"]: - packer build -var=@(opts["headless"]) -var-file=@(self.parent / "x86_64.pkrvars.hcl") @(opts["upload"]) -only=@(provider) @(base / "sources") diff --git a/distros/ubuntu/20.04/disc/meta-data b/distros/ubuntu/20.04/disc/meta-data new file mode 100644 index 0000000..e69de29 diff --git a/distros/ubuntu/20.04/disc/user-data b/distros/ubuntu/20.04/disc/user-data new file mode 100644 index 0000000..e02cbf8 --- /dev/null +++ b/distros/ubuntu/20.04/disc/user-data @@ -0,0 +1,41 @@ +#cloud-config +# vim: set ft=yaml: +autoinstall: + version: 1 + network: # Should disable networking, workaround for unattended-updates failing in install + version: 2 + ethernets: + eth0: + match: + name: e* + dhcp4: yes + dhcp6: no + refresh-installer: + update: no + keyboard: + layout: us + toggle: null + variant: '' + locale: en_US.UTF-8 + identity: + hostname: vagrant + username: vagrant + password: $6$rounds=4096$mJTRlY/vwPMquLe0$s4Ld3ZnvF.pM86xzbAgQD7Xpi/NMVgyQNb5CEfabFgL6nLRsP56WtwA.o.Jg/xC6HaJmM2p5fCGIo37jmKVRI0 + ssh: + install-server: yes + authorized_keys: + - ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key + 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 + - curtin in-target --target=/target -- logger "finished late-commands" + packages: + - ca-certificates + - curl + - sudo diff --git a/distros/ubuntu/20.04/x86_64.pkrvars.hcl b/distros/ubuntu/20.04/x86_64.pkrvars.hcl index e4bd0ae..69f5e11 100644 --- a/distros/ubuntu/20.04/x86_64.pkrvars.hcl +++ b/distros/ubuntu/20.04/x86_64.pkrvars.hcl @@ -14,49 +14,6 @@ boot_command = [ "priority=critical ", "autoinstall ds=nocloud" ] -cd_files = { - "/meta-data" = "" - "/user-data" = < /target/etc/sudoers.d/vagrant - - echo 'vagrant ALL=(ALL) NOPASSWD:ALL' >> /target/etc/sudoers.d/vagrant - - chmod 440 /target/etc/sudoers.d/vagrant - - curtin in-target --target=/target -- logger "finished late-commands" - packages: - - ca-certificates - - curl - - sudo -HEREDOC -} +cd_files = [ + "distros/ubuntu/20.04/disc/*" +] diff --git a/distros/ubuntu/22.04/disc/meta-data b/distros/ubuntu/22.04/disc/meta-data new file mode 100644 index 0000000..e69de29 diff --git a/distros/ubuntu/22.04/disc/user-data b/distros/ubuntu/22.04/disc/user-data new file mode 100644 index 0000000..2c5cc4e --- /dev/null +++ b/distros/ubuntu/22.04/disc/user-data @@ -0,0 +1,41 @@ +#cloud-config +# vim: set ft=yaml: +autoinstall: + version: 1 + network: # Should disable networking, workaround for unattended-updates failing in install + version: 2 + ethernets: + eth0: + match: + name: e* + dhcp4: yes + dhcp6: no + refresh-installer: + update: no + keyboard: + layout: us + toggle: null + variant: '' + locale: en_US.UTF-8 + identity: + hostname: vagrant + username: vagrant + password: $6$rounds=4096$mJTRlY/vwPMquLe0$s4Ld3ZnvF.pM86xzbAgQD7Xpi/NMVgyQNb5CEfabFgL6nLRsP56WtwA.o.Jg/xC6HaJmM2p5fCGIo37jmKVRI0 + ssh: + install-server: yes + authorized_keys: + - ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key + 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 + - curtin in-target --target=/target -- logger "finished late-commands" + packages: + - ca-certificates + - curl + - sudo diff --git a/distros/ubuntu/22.04/x86_64.pkrvars.hcl b/distros/ubuntu/22.04/x86_64.pkrvars.hcl index 4aadb2a..210b88d 100644 --- a/distros/ubuntu/22.04/x86_64.pkrvars.hcl +++ b/distros/ubuntu/22.04/x86_64.pkrvars.hcl @@ -14,49 +14,6 @@ boot_command = [ "autoinstall", "", ] -cd_files = { - "/meta-data" = "" - "/user-data" = < /target/etc/sudoers.d/vagrant - - echo 'vagrant ALL=(ALL) NOPASSWD:ALL' >> /target/etc/sudoers.d/vagrant - - chmod 440 /target/etc/sudoers.d/vagrant - - curtin in-target --target=/target -- logger "finished late-commands" - packages: - - ca-certificates - - curl - - sudo -HEREDOC -} +cd_files = [ + "distros/ubuntu/22.04/disc/*" +] diff --git a/sources/inputs.pkr.hcl b/sources/inputs.pkr.hcl index c11f00a..cf47c53 100644 --- a/sources/inputs.pkr.hcl +++ b/sources/inputs.pkr.hcl @@ -49,11 +49,16 @@ variable "build" { default = "0.1" } -variable "cd_files" { +variable "cd_content" { type = map(string) default = {} } +variable "cd_files" { + type = list(string) + default = [] +} + variable "cd_label" { type = string default = "cidata" @@ -64,6 +69,11 @@ variable "http_files" { default = {} } +variable "http_directory" { + type = string + default = "" +} + locals { name = "${var.distro}-${var.version}-${var.arch}" description = templatefile("../README.box.md", { diff --git a/sources/qemu.pkr.hcl b/sources/qemu.pkr.hcl index 2ce4707..058acc9 100644 --- a/sources/qemu.pkr.hcl +++ b/sources/qemu.pkr.hcl @@ -33,6 +33,8 @@ source "qemu" "x86_64" { accelerator = var.qemu_accelerator http_content = var.http_files - cd_content = var.cd_files + http_directory = var.http_directory + cd_content = var.cd_content + 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 5693012..ff73535 100644 --- a/sources/virtualbox-iso.pkr.hcl +++ b/sources/virtualbox-iso.pkr.hcl @@ -28,6 +28,8 @@ source "virtualbox-iso" "x86_64" { ] http_content = var.http_files - cd_content = var.cd_files + http_directory = var.http_directory + cd_content = var.cd_content + cd_files = var.cd_files cd_label = var.cd_label } diff --git a/test.xsh b/test.xsh index 0ce9dbd..6e73cbf 100755 --- a/test.xsh +++ b/test.xsh @@ -53,7 +53,7 @@ def main(): #$RAISE_SUBPROC_ERROR = True for box in g`*.box`: sed -e f's#@@BOX@@#file:///home/greg/src/vms/vms/{box}#' -e f's/@@BOX_NAME@@/{box}/' Vagrantfile.in > Vagrantfile - vagrant up --provider libvirt + vagrant up --provider virtualbox vagrant destroy -f rm -rf .vagrant