Hi,
i’m trying to get some basic stuff running with packer against hetzner (hcloud).
After packer build i got an hcloud snapshot from wich i can start a new server.
But no changes that were running during packer build process can be found in it.
(no example.txt, no installed ‘mc’, no changes from ssh.sh script)
What am i doing wrong or am i missing something?
variable "ubuntu_version" {
type = string
default = "20.04"
}
variable "location" {
type = string
default = "nbg1"
}
variable "hcloud_token" {
type = string
default = env("HCLOUD_TOKEN")
}
variable "hcloud_servertype" {
type = string
default = "cpx21"
}
locals {
ubuntu_version = "${ legacy_isotime("2006-01") }-01"
build_id = "${ uuidv4() }"
build_labels = {
os-flavor = "ubuntu"
"ubuntu/iso.release" = "${ local.ubuntu_version }"
"packer.io/build.id" = "${ local.build_id }"
"packer.io/build.time" = "{{ timestamp }}"
"packer.io/version" = "{{ packer_version }}"
}
}
source "hcloud" "ubuntu-snapshot" {
server_type = "${var.hcloud_servertype}"
image = "ubuntu-${var.ubuntu_version}"
#image_filter = {
# with_selector = [ "os_flavor=debian" ]
# most_recent = true
#}
rescue = "linux64"
location = var.location
snapshot_name = "ubuntu-${var.ubuntu_version}-{{ timestamp }}"
snapshot_labels = local.build_labels
ssh_username = "root"
token = "${ var.hcloud_token }"
}
build {
name = "ubuntu"
sources = ["source.hcloud.ubuntu-snapshot"]
provisioner "shell" {
script = "scripts/ssh/ssh.sh"
environment_vars = [ "SSH_PORT=2222" ]
}
provisioner "shell" {
inline = [
"echo Adding file to Docker Container",
"echo \"FOO is $FOO\" > example.txt",
]
}
provisioner "shell" {
inline = [
"apt-get update",
"apt-get install -y mc",
]
}
}