Compare commits

...

2 Commits

Author SHA1 Message Date
4b49404a0c
Create Vagrant box from base image 2025-08-21 23:25:27 -04:00
509b6af145
Make root password configurable 2025-08-17 19:05:57 -04:00
5 changed files with 92 additions and 5 deletions

View File

@ -4,8 +4,13 @@ HEADLESS ?= true
default: install
install:
packer build -var 'headless=$(HEADLESS)' .
install: base
base:
PKR_VAR_headless="$(HEADLESS)" packer build x86_64-qemu-base.pkr.hcl
vagrant:
PKR_VAR_headless="$(HEADLESS)" packer build x86_64-qemu-vagrant.pkr.hcl
clean:
rm -rf ./builds

View File

@ -12,8 +12,8 @@ d-i apt-setup/cdrom/set-first boolean false
# (Initial) root account setup
d-i passwd/make-user boolean false
d-i passwd/root-login boolean true
d-i passwd/root-password password debian
d-i passwd/root-password-again password debian
# d-i passwd/root-password password debian
# d-i passwd/root-password-again password debian
# Time
d-i clock-setup/utc boolean true

View File

@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -eu
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y openssl curl sudo
useradd -m -p "$(openssl passwd -1 vagrant)" vagrant
echo "vagrant ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/vagrant
chmod 440 /etc/sudoers.d/vagrant
install -d -m 0700 -o vagrant -g vagrant /home/vagrant/.ssh
BASE_GH_URL="https://raw.githubusercontent.com/hashicorp/vagrant/refs/heads"
curl -fsSL "${BASE_GH_URL}/main/keys/vagrant.pub" \
-o /home/vagrant/.ssh/authorized_keys
chmod 600 /home/vagrant/.ssh/authorized_keys
sed -i 's/PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config
passwd -d root

View File

@ -23,6 +23,10 @@ variable "memory" {
default = 2048
}
variable "ssh_password" {
default = "debian"
}
variable "headless" {
default = true
}
@ -40,7 +44,7 @@ source "qemu" "debian-13-64-base" {
accelerator = "kvm"
http_directory = "http"
ssh_username = "root"
ssh_password = "debian"
ssh_password = var.ssh_password
ssh_timeout = "60m"
vm_name = "debian-13-64-base"
net_device = "virtio-net"
@ -50,6 +54,8 @@ source "qemu" "debian-13-64-base" {
"<tab>",
" auto=true",
" priority=critical",
" passwd/root-password=${var.ssh_password}",
" passwd/root-password-again=${var.ssh_password}",
" hostname=trixie",
" domain=",
" url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg",

View File

@ -0,0 +1,56 @@
packer {
required_plugins {
qemu = {
version = ">= 1.1.3"
source = "github.com/hashicorp/qemu"
}
}
}
variable "memory" {
default = 2048
}
variable "ssh_password" {
default = "debian"
}
variable "headless" {
default = true
}
variable "disk_size" {
default = 102400
}
source "qemu" "debian-13-64-vagrant" {
iso_url = "builds/qemu/debian-13-64-base/debian-13-64-base"
disk_image = true
iso_checksum = "none"
output_directory = "builds/qemu/debian-13-64-vagrant"
shutdown_command = "/usr/bin/systemctl poweroff"
disk_interface = "virtio"
disk_size = var.disk_size
memory = var.memory
headless = var.headless
format = "qcow2"
accelerator = "kvm"
http_directory = "http"
ssh_username = "root"
ssh_password = var.ssh_password
ssh_timeout = "60m"
vm_name = "debian-13-64-base"
net_device = "virtio-net"
boot_wait = "5s"
}
build {
name = "debian-base"
sources = ["source.qemu.debian-13-64-vagrant"]
provisioner "shell" {
scripts = [
"scripts/vagrant.sh"
]
}
}