105 lines
2.3 KiB
HCL
105 lines
2.3 KiB
HCL
|
variable "cpus" {
|
||
|
type = number
|
||
|
default = 2
|
||
|
}
|
||
|
|
||
|
variable "memory" {
|
||
|
type = number
|
||
|
default = 1024
|
||
|
}
|
||
|
|
||
|
variable "disk_size" {
|
||
|
type = string
|
||
|
default = "3G"
|
||
|
}
|
||
|
|
||
|
variable "iso_url" {
|
||
|
type = string
|
||
|
default = "https://mirrors.edge.kernel.org/archlinux/iso/latest/archlinux-x86_64.iso"
|
||
|
}
|
||
|
|
||
|
variable "iso_checksum" {
|
||
|
type = string
|
||
|
default = "file:https://mirrors.edge.kernel.org/archlinux/iso/latest/sha256sums.txt"
|
||
|
}
|
||
|
|
||
|
variable "ssh_username" {
|
||
|
type = string
|
||
|
default = "root"
|
||
|
}
|
||
|
|
||
|
variable "ssh_password" {
|
||
|
type = string
|
||
|
default = "password"
|
||
|
}
|
||
|
|
||
|
source "qemu" "arch" {
|
||
|
headless = true
|
||
|
accelerator = "kvm"
|
||
|
vm_name = "arch.img"
|
||
|
http_directory = "http"
|
||
|
output_directory = "output"
|
||
|
|
||
|
cpus = var.cpus
|
||
|
memory = var.memory
|
||
|
|
||
|
disk_size = var.disk_size
|
||
|
format = "raw"
|
||
|
|
||
|
iso_url = var.iso_url
|
||
|
iso_checksum = var.iso_checksum
|
||
|
iso_target_path = "cache/arch.iso"
|
||
|
|
||
|
boot_wait = "2s"
|
||
|
boot_key_interval = "25ms"
|
||
|
boot_command = [
|
||
|
"<enter>",
|
||
|
"<wait30s>",
|
||
|
"echo '${var.ssh_username}:${var.ssh_password}' | chpasswd<enter>"
|
||
|
]
|
||
|
|
||
|
ssh_username = var.ssh_username
|
||
|
ssh_password = var.ssh_password
|
||
|
|
||
|
shutdown_command = "sudo -S shutdown -P now"
|
||
|
}
|
||
|
|
||
|
build {
|
||
|
sources = ["source.qemu.arch"]
|
||
|
|
||
|
provisioner "shell" {
|
||
|
pause_before = "5s"
|
||
|
scripts = [
|
||
|
"${path.root}/scripts/partition_disk.sh",
|
||
|
"${path.root}/scripts/install_system.sh",
|
||
|
"${path.root}/scripts/timezone_and_locale.sh",
|
||
|
"${path.root}/scripts/add_deploy_user.sh",
|
||
|
]
|
||
|
}
|
||
|
|
||
|
provisioner "file" {
|
||
|
source = "files/99-dhcp-wildcard.network"
|
||
|
destination = "/mnt/etc/systemd/network/99-dhcp-wildcard.network"
|
||
|
}
|
||
|
|
||
|
provisioner "shell" {
|
||
|
pause_before = "10s"
|
||
|
scripts = [
|
||
|
"${path.root}/scripts/enable_services.sh",
|
||
|
"${path.root}/scripts/install_bootloader.sh",
|
||
|
"${path.root}/scripts/truncate_empty_space.sh",
|
||
|
"${path.root}/scripts/finalization.sh"
|
||
|
]
|
||
|
}
|
||
|
|
||
|
post-processor "checksum" {
|
||
|
checksum_types = ["sha256"]
|
||
|
keep_input_artifact = true
|
||
|
}
|
||
|
|
||
|
# Validate that the image is good
|
||
|
// post-processor "shell-local" {
|
||
|
// inline = ["qemu-system-x86_64 -drive file=output/arch.img -m 1024"]
|
||
|
// }
|
||
|
}
|