forked from jenkins-infra/packer-images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-jenkins-agent-ubuntu.pkr.hcl
62 lines (53 loc) · 1.72 KB
/
build-jenkins-agent-ubuntu.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
build {
source "docker.base" {
name = "ubuntu"
}
source "amazon-ebs.base" {
name = "ubuntu"
ssh_username = "ubuntu"
}
source "azure-arm.base" {
name = "ubuntu"
# List available offers and publishers with the command `az vm image list --output table`
image_offer = "0001-com-ubuntu-server-focal"
image_publisher = "canonical"
# List available SKUs with the command `az vm image list-skus --offer 0001-com-ubuntu-server-focal --location eastus --publisher canonical --output table`
image_sku = "${local.agent_os_version_safe}-lts-gen2"
os_type = "Linux"
vm_size = local.azure_vm_size
}
provisioner "shell" {
only = ["docker.ubuntu"]
environment_vars = local.provisioning_env_vars
script = "./provisioning/docker-jenkins-agent.sh"
}
provisioner "file" {
source = "./provisioning/add_auth_key_to_user.sh"
destination = "/tmp/add_auth_key_to_user.sh"
}
provisioner "file" {
source = "./provisioning/docker.gpg"
destination = "/tmp/docker.gpg"
}
provisioner "shell" {
environment_vars = local.provisioning_env_vars
execute_command = "chmod +x {{ .Path }}; {{ .Vars }} sudo -E bash '{{ .Path }}'"
script = "./provisioning/ubuntu-provision.sh"
}
provisioner "file" {
source = "./goss/goss.yaml"
destination = "/tmp/goss.yaml"
}
provisioner "shell" {
inline = [
"set -xeu",
"goss --version",
"goss --gossfile /tmp/goss.yaml validate --retry-timeout 5s",
]
}
post-processor "docker-tag" {
only = ["docker.ubuntu"]
repository = "${var.docker_namespace}/${local.image_name}"
tags = [var.image_version, "latest"]
}
}