-
Notifications
You must be signed in to change notification settings - Fork 3
/
gcp.pkr.hcl
298 lines (262 loc) · 8.03 KB
/
gcp.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
packer {
required_plugins {
googlecompute = {
version = ">= 1.1.4"
source = "github.com/hashicorp/googlecompute"
}
}
}
variable "image_name" {
type = string
default = "${env("IMAGE_NAME")}"
}
variable "disk_size" {
type = number
default = 100
}
variable "project_id" {
type = string
default = "${env("PROJECT_ID")}"
}
variable "taskcluster_version" {
type = string
default = "${env("TASKCLUSTER_VERSION")}"
}
variable "tc_arch" {
type = string
default = "${env("TC_ARCH")}"
}
variable "source_image_family" {
type = string
default = "${env("SOURCE_IMAGE_FAMILY")}"
}
variable "zone" {
type = string
default = "${env("ZONE")}"
}
variable "access_token" {
type = string
default = "${env("ACCESS_TOKEN")}"
sensitive = true
}
variable "worker_env_var_key" {
type = string
default = "${env("WORKER_ENV_VAR_KEY")}"
sensitive = true
}
variable "tc_worker_cert" {
type = string
default = "${env("TC_WORKER_CERT")}"
sensitive = true
}
variable "tc_worker_key" {
type = string
default = "${env("TC_WORKER_KEY")}"
sensitive = true
}
source "googlecompute" "gw-fxci-gcp-l1-2404-gui-alpha" {
disk_size = var.disk_size
image_licenses = ["projects/vm-options/global/licenses/enable-vmx"]
image_name = var.image_name
machine_type = null
project_id = var.project_id
source_image_family = var.source_image_family
ssh_username = "ubuntu"
zone = var.zone
use_iap = true
}
source "googlecompute" "gw-fxci-gcp-l1-2404-headless-alpha" {
disk_size = var.disk_size
image_licenses = ["projects/vm-options/global/licenses/enable-vmx"]
image_name = var.image_name
machine_type = null
project_id = var.project_id
source_image_family = var.source_image_family
ssh_username = "ubuntu"
zone = var.zone
use_iap = true
}
build {
sources = [
"source.googlecompute.gw-fxci-gcp-l1-2404-gui-alpha"
]
// ## Every image has tests, so create the tests directory
// provisioner "shell" {
// execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
// inline = [
// "mkdir -p /workerimages/tests",
// "chmod -R 777 /workerimages/tests",
// ]
// }
// ## Every image has taskcluster, so upload the taskcluster tests fle
// provisioner "file" {
// source = "${path.cwd}/tests/linux/taskcluster.tests.ps1"
// destination = "/workerimages/tests/taskcluster.tests.ps1"
// }
## Let's use taskcluster community shell script, the staging version
provisioner "shell" {
execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
environment_vars = [
"CLOUD=google",
"TC_ARCH=${var.tc_arch}",
"TASKCLUSTER_VERSION=${var.taskcluster_version}",
"NUM_LOOPBACK_AUDIO_DEVICES=8",
"NUM_LOOPBACK_VIDEO_DEVICES=8"
]
expect_disconnect = true
scripts = [
"${path.cwd}/scripts/linux/common/papertrail.sh",
"${path.cwd}/scripts/linux/ubuntu-2404-amd64-gui/fxci/01-bootstrap.sh",
"${path.cwd}/scripts/linux/ubuntu-2404-amd64-gui/fxci/02-additional-packages.sh",
"${path.cwd}/scripts/linux/ubuntu-2404-amd64-gui/fxci/04-wayland.sh",
"${path.cwd}/scripts/linux/ubuntu-2404-amd64-gui/fxci/05-pipewire.sh",
"${path.cwd}/scripts/linux/common/v4l2loopback.sh",
"${path.cwd}/scripts/linux/common/userns.sh",
"${path.cwd}/scripts/linux/ubuntu-2404-amd64-gui/fxci/99-additional-talos-reqs.sh"
]
}
## Reboot to get wayland config applied
provisioner "shell" {
execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
expect_disconnect = true
pause_before = "10s"
start_retry_timeout = "30m"
scripts = [
"${path.cwd}/scripts/linux/common/reboot.sh"
]
}
provisioner "shell" {
inline = ["/usr/bin/cloud-init status --wait"]
}
// ## Install dependencies for tests
// provisioner "shell" {
// execute_command = "sudo -S bash -c '{{ .Vars }} {{ .Path }}'"
// scripts = [
// "${path.cwd}/tests/linux/01_prep.sh",
// "${path.cwd}/tests/linux/02_install_pester.sh"
// ]
// }
// ## Run all tests
// provisioner "shell" {
// execute_command = "sudo -S bash -c '{{ .Vars }} {{ .Path }}'"
// scripts = [
// "${path.cwd}/tests/linux/run_all_tests.sh"
// ]
// }
## Install gcp ops agent and cleanup
provisioner "shell" {
execute_command = "sudo -S bash -c '{{ .Vars }} {{ .Path }}'"
expect_disconnect = true
pause_before = "10s"
scripts = [
"${path.cwd}/scripts/linux/common/01-install-ops-agent.sh",
"${path.cwd}/scripts/linux/common/99-clean.sh",
]
start_retry_timeout = "30m"
}
post-processor "manifest" {
output = "packer-artifacts.json"
strip_path = true
}
}
build {
sources = [
"source.googlecompute.gw-fxci-gcp-l1-2404-headless-alpha"
]
## Every image has tests, so create the tests directory
provisioner "shell" {
execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
inline = [
"mkdir -p /workerimages/tests",
"chmod -R 777 /workerimages/tests",
]
}
## Every image has taskcluster, so upload the taskcluster tests fle
provisioner "file" {
source = "${path.cwd}/tests/linux/taskcluster.tests.ps1"
destination = "/workerimages/tests/taskcluster.tests.ps1"
}
provisioner "shell" {
execute_command = "sudo -S bash -c '{{ .Vars }} {{ .Path }}'"
environment_vars = [
"CLOUD=google",
"TC_ARCH=${var.tc_arch}",
"TASKCLUSTER_VERSION=${var.taskcluster_version}",
"NUM_LOOPBACK_AUDIO_DEVICES=8",
"NUM_LOOPBACK_VIDEO_DEVICES=8"
]
scripts = [
"${path.cwd}/scripts/linux/common/papertrail.sh",
"${path.cwd}/scripts/linux/ubuntu-2404-amd64-headless/fxci/01-bootstrap.sh",
"${path.cwd}/scripts/linux/ubuntu-2404-amd64-headless/fxci/02-additional-packages.sh",
"${path.cwd}/scripts/linux/ubuntu-2404-amd64-headless/fxci/03-aslr.sh",
"${path.cwd}/scripts/linux/common/userns.sh",
"${path.cwd}/scripts/linux/common/v4l2loopback.sh"
]
}
provisioner "shell" {
execute_command = "sudo -S bash -c '{{ .Vars }} {{ .Path }}'"
expect_disconnect = true
scripts = [
"${path.cwd}/scripts/linux/ubuntu-2404-amd64-headless/fxci/05-nvidia-gcp-driver-cudnn.sh"
]
}
provisioner "shell" {
execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
expect_disconnect = true
pause_before = "30s"
start_retry_timeout = "30m"
scripts = [
"${path.cwd}/scripts/linux/common/reboot.sh"
]
}
provisioner "shell" {
execute_command = "sudo -S bash -c '{{ .Vars }} {{ .Path }}'"
expect_disconnect = true
scripts = [
"${path.cwd}/scripts/linux/ubuntu-2404-amd64-headless/fxci/06-nvidia-container-toolkit.sh"
]
}
provisioner "shell" {
execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
expect_disconnect = true
pause_before = "30s"
start_retry_timeout = "30m"
scripts = [
"${path.cwd}/scripts/linux/common/reboot.sh"
]
}
## Run all tests
provisioner "shell" {
execute_command = "sudo -S bash -c '{{ .Vars }} {{ .Path }}'"
pause_before = "90s"
environment_vars = [
"CLOUD=google",
"TC_ARCH=${var.tc_arch}",
"TASKCLUSTER_VERSION=${var.taskcluster_version}",
]
scripts = [
"${path.cwd}/tests/linux/01_prep.sh",
"${path.cwd}/tests/linux/02_install_pester.sh",
"${path.cwd}/tests/linux/test_docker.sh",
"${path.cwd}/tests/linux/run_all_tests.sh"
]
valid_exit_codes = [
0
]
}
## Install gcp ops agent and cleanup
provisioner "shell" {
execute_command = "sudo -S bash -c '{{ .Vars }} {{ .Path }}'"
expect_disconnect = true
scripts = [
"${path.cwd}/scripts/linux/common/01-install-ops-agent.sh",
"${path.cwd}/scripts/linux/common/99-clean.sh",
]
start_retry_timeout = "30m"
}
post-processor "manifest" {
output = "packer-artifacts.json"
strip_path = true
}
}