~samirnassar/debian

debian/default.pkr.hcl -rw-r--r-- 1.6 KiB
b4e0145bSamir Nassar Edit README.md for formatting and conformance with others 8 months ago
                                                                                
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
variable "hcloud_token" {
  type = string
}

variable "ssh_keys" {
  type = list(string)
}

locals {
  snapshotbuildtime = formatdate("YYYY-MM-DD-hhmm", timestamp())
  # Also here I believe naming this variable `buildtime` could lead to 
  # confusion mainly because this is evaluated a 'parsing-time'.
  hcloud-servertype = "cx11"
  arch-release = "{{ isotime `2006-01` }}-01"
  system-keymap = "us"
  system-locale = "en_US.UTF-8"
  system-timezone = "UTC"
  extra-packages = ""
}

source "hcloud" "debian-11" {
  image        = "debian-11"
  location     = "hel1"
  server_type  = "cx11"
  ssh_username = "root"
  token        = "${var.hcloud_token}"
  rescue       = "linux64"
  ssh_keys     = "${var.ssh_keys}"
  ssh_agent_auth = true
  server_name = "debian-11-${ local.snapshotbuildtime }"
  snapshot_name = "debian-11-${ local.snapshotbuildtime }"
  snapshot_labels = {
    "packer.io/version" = "${packer.version}",
    "packer.io/build.time" = "${ local.snapshotbuildtime }",
    "os-flavor" = "debian-11",
    "image_type" = "debian-11"
  }
}

build {
  sources = ["source.hcloud.debian-11"]

  provisioner "shell" {
    inline = ["echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections"]
  }

  provisioner "shell" {
    inline = ["/usr/bin/apt-get update"]
  }

  provisioner "shell" {
    inline = ["/usr/bin/apt-get -y upgrade"]
  }

  provisioner "shell" {
    inline = ["/usr/bin/apt-get -y install python3 python3-pip python3-setuptools python3-wheel"]
  }

  provisioner "shell" {
    inline = ["/usr/bin/apt-get -y install ssl-cert"]
  }

  provisioner "shell" {
    inline = ["make-ssl-cert generate-default-snakeoil --force-overwrite"]
  }
}