-
Notifications
You must be signed in to change notification settings - Fork 0
/
flatcar-linux.json.pkr.hcl
81 lines (68 loc) · 2.1 KB
/
flatcar-linux.json.pkr.hcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
variable "FLATCAR_RELEASE" {
type = string
default = "3139.2.0"
}
variable "HCLOUD_SERVER_TYPE" {
type = string
default = "cx11"
}
variable "HCLOUD_TOKEN" {
type = string
default = ""
}
variable "HCLOUD_REGION" {
type = string
default = "hel1"
}
variable "system-keymap" {
type = string
default = "us"
}
variable "system-locale" {
type = string
default = "en_US.UTF-8"
}
variable "system-timezone" {
type = string
default = "UTC"
}
source "hcloud" "flatcar" {
image = "debian-10"
location = var.HCLOUD_REGION
rescue = "linux64"
server_type = var.HCLOUD_SERVER_TYPE
snapshot_labels = {
"flatcar/iso.release" = var.FLATCAR_RELEASE
os-flavor = "flatcar-linux"
"packer.io/build.id" = "{{ build_name }}"
"packer.io/build.time" = "{{ timestamp }}"
"packer.io/version" = "{{ packer_version }}"
}
snapshot_name = format("flatcar-linux-%s", var.FLATCAR_RELEASE)
ssh_username = "root"
token = var.HCLOUD_TOKEN
}
build {
sources = ["source.hcloud.flatcar"]
provisioner "file" {
content = templatefile("${path.root}/cl-config.yaml", {})
destination = "/cl-config.yaml"
}
provisioner "shell" {
inline = [
"curl -fsSLO --retry-delay 1 --retry 60 --retry-connrefused --retry-max-time 60 --connect-timeout 20 https://raw.githubusercontent.com/kinvolk/init/flatcar-master/bin/flatcar-install",
"chmod +x flatcar-install",
"apt update -yqq && apt install -yqq gawk",
"wget https://github.com/flatcar-linux/container-linux-config-transpiler/releases/download/v0.9.3/ct-v0.9.3-x86_64-unknown-linux-gnu -O /usr/bin/ct && chmod +x /usr/bin/ct",
"ct -in-file /cl-config.yaml -out-file /ignition.json",
"cat /ignition.json",
"./flatcar-install -s -V ${var.FLATCAR_RELEASE} -i /ignition.json",
"mkdir /tmp/oem && mount /dev/sda6 /tmp/oem",
"echo 'set linux_append=\"$linux_append nameserver=185.12.64.1 flatcar.autologin=tty1\"' > /tmp/oem/grub.cfg",
"cat /tmp/oem/grub.cfg",
"umount /tmp/oem"
]
}
post-processor "manifest" {
}
}