mirror of
https://github.com/apricote/flatcar-packer-hcloud.git
synced 2026-01-13 13:21:01 +00:00
feat: initial templates
This commit is contained in:
parent
755b02cf21
commit
a0ecbbe1bc
4 changed files with 187 additions and 0 deletions
93
flatcar.pkr.hcl
Normal file
93
flatcar.pkr.hcl
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
packer {
|
||||
required_plugins {
|
||||
hcloud = {
|
||||
source = "github.com/hetznercloud/hcloud"
|
||||
version = "~> 1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
variable "hcloud_token" {
|
||||
type = string
|
||||
default = "${env("HCLOUD_TOKEN")}"
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
variable "hcloud_server_type" {
|
||||
type = map(string)
|
||||
default = {
|
||||
x86 = "cx11"
|
||||
arm = "cax11"
|
||||
}
|
||||
}
|
||||
|
||||
variable "flatcar_install_script" {
|
||||
type = string
|
||||
default = "https://raw.githubusercontent.com/flatcar/init/flatcar-master/bin/flatcar-install"
|
||||
}
|
||||
|
||||
variable "flatcar_channel" {
|
||||
type = string
|
||||
default = "alpha"
|
||||
}
|
||||
|
||||
locals {
|
||||
hcloud_location = "fsn1"
|
||||
hcloud_rescue = "linux64"
|
||||
hcloud_initial_os = "ubuntu-22.04"
|
||||
flatcar_oem_id = "hetzner"
|
||||
}
|
||||
|
||||
source "hcloud" "flatcar" {
|
||||
token = var.hcloud_token
|
||||
|
||||
image = local.hcloud_initial_os
|
||||
location = local.hcloud_location
|
||||
rescue = local.hcloud_rescue
|
||||
|
||||
snapshot_labels = {
|
||||
os = "flatcar"
|
||||
"flatcar.channel" = var.flatcar_channel
|
||||
}
|
||||
|
||||
ssh_username = "root"
|
||||
}
|
||||
|
||||
|
||||
build {
|
||||
source "hcloud.flatcar" {
|
||||
name = "x86"
|
||||
server_type = var.hcloud_server_type["x86"]
|
||||
snapshot_name = "flatcar-${var.flatcar_channel}-x86"
|
||||
}
|
||||
|
||||
source "hcloud.flatcar" {
|
||||
name = "arm"
|
||||
server_type = var.hcloud_server_type["arm"]
|
||||
snapshot_name = "flatcar-${var.flatcar_channel}-arm"
|
||||
}
|
||||
|
||||
provisioner "file" {
|
||||
source = "ignition-oem.json"
|
||||
destination = "/ignition.json"
|
||||
}
|
||||
|
||||
provisioner "shell" {
|
||||
inline = [
|
||||
# Download script and dependencies
|
||||
"apt-get update",
|
||||
"apt-get -y install gawk",
|
||||
"curl -fsSLO --retry-delay 1 --retry 60 --retry-connrefused --retry-max-time 60 --connect-timeout 20 ${var.flatcar_install_script}",
|
||||
"chmod +x flatcar-install",
|
||||
|
||||
# Install flatcar
|
||||
"./flatcar-install -s -C ${var.flatcar_channel} -i /ignition.json",
|
||||
|
||||
# Setup Kernel Parameters for OEM Platform
|
||||
"mkdir /root/OEM",
|
||||
"mount /dev/disk/by-label/OEM /root/OEM",
|
||||
"echo 'set oem_id=${local.flatcar_oem_id}' > /root/OEM/grub.cfg",
|
||||
"umount /root/OEM",
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue