Skip to content

Instantly share code, notes, and snippets.

@AlexVlan
Created September 30, 2024 15:06
Show Gist options
  • Select an option

  • Save AlexVlan/1cf70c6f028d34d11face839d8a68270 to your computer and use it in GitHub Desktop.

Select an option

Save AlexVlan/1cf70c6f028d34d11face839d8a68270 to your computer and use it in GitHub Desktop.
redos-7.pkr.hcl
packer {
required_version = ">= 1.7.0"
required_plugins {
qemu = {
version = "~> 1.0"
source = "github.com/hashicorp/qemu"
}
}
}
variable "filename" {
type = string
default = "redos-7.tar.gz"
description = "The filename of the tarball to produce"
}
# variable "redos_7_iso_url" {
# type = string
# default = "http://127.0.0.1:8080/redos-MUROM-7.3.4-20231220.0-Everything-x86_64-DVD1.iso"
# # default = "https://repo1.red-soft.ru/redos/7.3/x86_64/oem/redos-MUROM-7.3.4-20231220.0-Everything-x86_64-DVD1-kickstart.iso"
# }
variable "redos_7_sha256sum_url" {
type = string
default = "http://127.0.0.1:8080/redos-MUROM-7.3.4-20231220.0-Everything-x86_64-DVD1.iso.MD5SUM"
# default = "https://repo1.red-soft.ru/redos/7.3/x86_64/oem/redos-MUROM-7.3.4-20231220.0-Everything-x86_64-DVD1-kickstart.md5"
}
variable "redos_iso_path" {
type = string
default = "/home/alex/share/redos-MUROM-7.3.4-20231220.0-Everything-x86_64-DVD1.iso"
}
variable ks_proxy {
type = string
default = "${env("KS_PROXY")}"
}
variable "ks_os_repos" {
type = string
default = "--url='https://repo1.red-soft.ru/redos/7.3/x86_64/os/'"
}
variable "ks_updates_repos" {
type = string
default = "--baseurl='https://repo1.red-soft.ru/redos/7.3/x86_64/updates/'"
}
variable "ks_extras_repos" {
type = string
default = "--baseurl='https://repo1.red-soft.ru/redos/7.3/x86_64/extras/'"
}
variable ks_mirror {
type = string
default = "${env("KS_MIRROR")}"
}
variable "timeout" {
type = string
default = "1h"
description = "Timeout for building the image"
}
locals {
ks_proxy = var.ks_proxy != "" ? "--proxy=${var.ks_proxy}" : ""
ks_os_repos = var.ks_mirror != "" ? "--url=${var.ks_mirror}/os/x86_64" : var.ks_os_repos
ks_updates_repos = var.ks_mirror != "" ? "--baseurl=${var.ks_mirror}/updates/x86_64" : var.ks_updates_repos
ks_extras_repos = var.ks_mirror != "" ? "--baseurl=${var.ks_mirror}/extras/x86_64" : var.ks_extras_repos
}
source "qemu" "redos-7" {
boot_command = ["<up><tab> ", "inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/redos-7.ks ", "console=ttyS0 inst.cmdline", "<enter>"]
boot_wait = "10s"
communicator = "none"
disk_size = "5G"
#
disk_interface = "ide"
#
headless = true
iso_checksum = "file:${var.redos_7_sha256sum_url}"
# iso_url = var.redos_7_iso_url
iso_url = var.redos_iso_path
# iso_checksum = "none"
memory = 2048
qemuargs = [["-serial", "stdio"]]
shutdown_timeout = var.timeout
http_content = {
"/redos-7.ks" = templatefile("${path.root}/http/redos-7.ks.pkrtpl.hcl",
{
KS_PROXY = local.ks_proxy,
KS_OS_REPOS = local.ks_os_repos,
KS_UPDATES_REPOS = local.ks_updates_repos,
KS_EXTRAS_REPOS = local.ks_extras_repos
}
)
}
}
build {
sources = ["source.qemu.redos-7"]
post-processor "shell-local" {
inline = [
"SOURCE=${source.name}",
"OUTPUT=${var.filename}",
"source ../scripts/fuse-nbd",
"source ../scripts/fuse-tar-root",
"rm -rf output-${source.name}",
]
inline_shebang = "/bin/bash -e"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment