Lots of improvements everywhere

This commit is contained in:
Greg Hellings
2023-08-03 14:44:02 -05:00
parent 0a3832d2c4
commit bb63ff7534
44 changed files with 388 additions and 249 deletions
+1
View File
@@ -5,6 +5,7 @@ output_*
serial-output*
grub.cfg
isolinux.cfg
Vagrantfile
# Generated distros
distros/fedora-rawhide-*.hcl
+8
View File
@@ -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
+1 -6
View File
@@ -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.
+1
View File
@@ -0,0 +1 @@
CentOS 7 with virtualbox-iso does not auto-build. Network will not enable by default during building
+3 -2
View File
@@ -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
+8
View File
@@ -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
+6
View File
@@ -0,0 +1,6 @@
- name: Install qemu-guest-agent
become: true
ansible.builtin.package:
name:
- qemu-guest-agent
state: present
+1 -1
View File
@@ -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
+3 -13
View File
@@ -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: []
@@ -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 = [
"<esc><wait>",
"linux net.ifnames=0 biosdevnames=0 inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/centos/9stream-x86_64.ks console=ttyS0",
"<enter>"
]
EOF
+1 -1
View File
@@ -6,6 +6,6 @@ iso = {
}
boot_command = [
"<esc><wait>",
"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",
"<enter>"
]
+3 -3
View File
@@ -17,8 +17,8 @@ iso = {
checksum = "${sha}"
}
boot_command = [
"<esc><wait>",
"linux net.ifnames=0 biosdevnames=0 inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/centos/8stream/x86_64.ks console=ttyS0",
"<enter>"
"<up><tab><wait><bs><bs><bs><bs><bs>",
"inst.text inst.ks=cdrom:/http/centos/8stream/x86_64.ks console=ttyS0",
"<enter><wait>"
]
EOF
+28
View File
@@ -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 = [
"<up><tab><wait><bs><bs><bs><bs><bs>",
"inst.text inst.ks=cdrom:/http/centos/9stream-x86_64.ks console=tty0",
"<enter><wait>"
]
EOF
+3 -2
View File
@@ -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 = [
"<esc><wait>",
@@ -12,5 +12,6 @@ boot_command = [
"biosdevnames=0 ",
"preseed/url=http://{{.HTTPIP}}:{{ .HTTPPort }}/debian/10-preseed.cfg ",
"console=ttyS0 ",
"console=tty0 ",
"<enter>"
]
+2 -2
View File
@@ -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 = [
"<esc><wait>",
+16
View File
@@ -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 = [
"<esc><wait>",
"auto ",
"DEBIAN_FRONTEND=text ",
"net.ifnames=0 ",
"biosdevnames=0 ",
"preseed/url=http://{{.HTTPIP}}:{{ .HTTPPort }}/debian/12-preseed.cfg ",
"console=ttyS0 ",
"<enter>"
]
+10
View File
@@ -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 = [
"<up>e<down><down><end> ",
"net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/http/fedora/37-x86_64.ks console=tty0 console=ttyS0<f10>"
]
+10
View File
@@ -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 = [
"<up>e<down><down><end> ",
"net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/http/fedora/38-x86_64.ks console=tty0 console=ttyS0<f10>"
]
+1 -1
View File
@@ -35,7 +35,7 @@ iso = {
}
boot_command = [
"<up>e<down><down><end><bs><bs><bs><bs><bs>",
"edd=off net.ifnames=0 biosdevnames=0 inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/fedora/rawhide-x86_64.ks console=ttyS0<f10>"
"net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/http/fedora/rawhide-x86_64.ks console=tty0 console=ttyS0<f10>"
]
EOF
-2
View File
@@ -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"
}
+5 -2
View File
@@ -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/<enter><wait>"
]
+7 -4
View File
@@ -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<down><down><down><end><bs><bs><bs>",
"console=ttyS0 ",
"fsck.mode=skip ",
"autoinstall ds=\"nocloud-net;s=http://{{.HTTPIP}}:{{.HTTPPort}}/ubuntu/22.04/\" console=ttyS0<F10>"
"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<F10> ",
]
+10 -11
View File
@@ -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
+10 -12
View File
@@ -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
+58
View File
@@ -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
+23
View File
@@ -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
+23
View File
@@ -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
+1
Submodule http/fedora/f37 added at dc9e3b2cea
+1
Submodule http/fedora/f38 added at 69c726f753
+11 -75
View File
@@ -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
+12 -66
View File
@@ -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
+20 -3
View File
@@ -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"
]
}
+11
View File
@@ -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"
}
}
+6 -1
View File
@@ -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
}
+5 -3
View File
@@ -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}" ]
}
-13
View File
@@ -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
Executable
+59
View File
@@ -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()
Executable
+16
View File
@@ -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()
+2
View File
@@ -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