Skip to content

Commit a902cc9

Browse files
committed
wip: testing packer for google cloud
Signed-off-by: vsoch <[email protected]>
1 parent 0bac4b3 commit a902cc9

File tree

4 files changed

+440
-1
lines changed

4 files changed

+440
-1
lines changed

tutorial/aws/tf-hpc6a/build/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -euo pipefail
44

55
################################################################
66
#
7-
# Flux, Singularity, and EFA
7+
# Flux, Singularity, and ORAS
88
#
99

1010
/usr/bin/cloud-init status --wait
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.PHONY: all
2+
all: init fmt validate build
3+
4+
.PHONY: init
5+
init:
6+
packer init .
7+
8+
.PHONY: fmt
9+
fmt:
10+
packer fmt .
11+
12+
.PHONY: validate
13+
validate:
14+
packer validate .
15+
16+
.PHONY: build
17+
build:
18+
# Rocky-8-EC2-Base-8.7-20230215.0.x86_64-d6577ceb-8ea8-4e0e-84c6-f098fc302e82
19+
packer build -var machine_architecture="x86-64" -var project_id=${GOOGLE_PROJECT} build.pkr.hcl
20+
# gcloud builds submit --config=cloudbuild.yaml .
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Generate a packer build for an AMI (Amazon Image)
2+
3+
packer {
4+
required_plugins {
5+
googlecompute = {
6+
version = "= 1.1.3"
7+
source = "github.com/hashicorp/googlecompute"
8+
}
9+
}
10+
}
11+
12+
variable "enable_secure_boot" {
13+
type = bool
14+
default = true
15+
}
16+
17+
variable "machine_architecture" {
18+
type = string
19+
default = "x86-64"
20+
}
21+
22+
variable "machine_type" {
23+
type = string
24+
default = "c2-standard-16"
25+
}
26+
27+
variable "project_id" {
28+
type = string
29+
default = "llnl-flux"
30+
}
31+
32+
variable "builder_service_account" {
33+
type = string
34+
default = "llnl-flux"
35+
}
36+
37+
# gcloud compute images describe-from-family rocky-linux-8-optimized-gcp --project=rocky-linux-cloud
38+
variable "source_image" {
39+
type = string
40+
default = "rocky-linux-8-optimized-gcp-v20240709"
41+
}
42+
43+
variable "source_image_project_id" {
44+
type = string
45+
default = "rocky-linux-cloud"
46+
}
47+
48+
variable "subnetwork" {
49+
type = string
50+
default = "default"
51+
}
52+
53+
variable "zone" {
54+
type = string
55+
default = "us-central1-a"
56+
}
57+
58+
# "timestamp" template function replacement for image naming
59+
# This is so us of the future can remember when images were built
60+
locals { timestamp = regex_replace(timestamp(), "[- TZ:]", "") }
61+
62+
source "googlecompute" "flux-framework" {
63+
project_id = var.project_id
64+
source_image = var.source_image
65+
source_image_project_id = [var.source_image_project_id]
66+
zone = var.zone
67+
image_name = "flux-framework-${var.machine_architecture}-v{{timestamp}}"
68+
image_family = "flux-framework-${var.machine_architecture}"
69+
image_description = "flux-framework"
70+
machine_type = var.machine_type
71+
disk_size = 256
72+
subnetwork = var.subnetwork
73+
tags = ["packer", "flux-framework", "${var.machine_architecture}"]
74+
startup_script_file = "build.sh"
75+
ssh_username = "rocky"
76+
# IMPORTANT: you need to generate this
77+
# account_file = "packer-build.key"
78+
# impersonate_service_account = var.builder_service_account
79+
enable_secure_boot = var.enable_secure_boot
80+
}
81+
82+
build {
83+
sources = ["sources.googlecompute.flux-framework"]
84+
}

0 commit comments

Comments
 (0)