-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.pkr.hcl
47 lines (41 loc) · 997 Bytes
/
build.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
packer {
required_plugins {
upcloud = {
version = ">=v1.0.0"
source = "github.com/UpCloudLtd/upcloud"
}
}
}
variable "username" {
type = string
description = "UpCloud API username"
default = "${env("UPCLOUD_USERNAME")}"
}
variable "password" {
type = string
description = "UpCloud API password"
default = "${env("UPCLOUD_PASSWORD")}"
sensitive = true
}
variable "ssh_public_key" {
type = string
description = "Path to your SSH public key file"
default = "~/.ssh/id_rsa.pub"
}
source "upcloud" "test" {
username = "${var.username}"
password = "${var.password}"
zone = "nl-ams1"
storage_name = "ubuntu server 20.04"
template_prefix = "ubuntu-server"
}
build {
sources = ["source.upcloud.test"]
provisioner "shell" {
inline = [
"apt-get update",
"apt-get upgrade -y",
"echo '${file(var.ssh_public_key)}' | tee /root/.ssh/authorized_keys"
]
}
}