Skip to content

Commit f17ff6b

Browse files
committed
test changes
Signed-off-by: Glen Yu <glen.yu@gmail.com>
1 parent 69c1ecb commit f17ff6b

File tree

9 files changed

+76
-23
lines changed

9 files changed

+76
-23
lines changed

.github/workflows/packer.yaml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
with:
4343
version: 'latest'
4444
project_id: '${{ vars.GCP_PROJECT_ID }}'
45-
install_components: 'beta' # optional: install additional components
45+
#install_components: 'beta' # optional: install additional components
4646

4747
- name: Setup `packer`
4848
uses: hashicorp/setup-packer@main
@@ -81,6 +81,12 @@ jobs:
8181
with:
8282
workload_identity_provider: '${{ secrets.WIF_PROVIDER }}'
8383
service_account: '${{ secrets.WIF_SERVICE_ACCOUNT }}'
84+
- name: 'Set up Google Cloud SDK'
85+
uses: 'google-github-actions/setup-gcloud@v2'
86+
with:
87+
version: 'latest'
88+
project_id: '${{ vars.GCP_PROJECT_ID }}'
89+
#install_components: 'beta' # optional: install additional components
8490

8591
- name: Setup `packer`
8692
uses: hashicorp/setup-packer@main
@@ -119,6 +125,12 @@ jobs:
119125
with:
120126
workload_identity_provider: '${{ secrets.WIF_PROVIDER }}'
121127
service_account: '${{ secrets.WIF_SERVICE_ACCOUNT }}'
128+
- name: 'Set up Google Cloud SDK'
129+
uses: 'google-github-actions/setup-gcloud@v2'
130+
with:
131+
version: 'latest'
132+
project_id: '${{ vars.GCP_PROJECT_ID }}'
133+
#install_components: 'beta' # optional: install additional components
122134

123135
- name: Setup `packer`
124136
uses: hashicorp/setup-packer@main
@@ -158,6 +170,12 @@ jobs:
158170
with:
159171
workload_identity_provider: '${{ secrets.WIF_PROVIDER }}'
160172
service_account: '${{ secrets.WIF_SERVICE_ACCOUNT }}'
173+
- name: 'Set up Google Cloud SDK'
174+
uses: 'google-github-actions/setup-gcloud@v2'
175+
with:
176+
version: 'latest'
177+
project_id: '${{ vars.GCP_PROJECT_ID }}'
178+
#install_components: 'beta' # optional: install additional components
161179

162180
- name: Setup `packer`
163181
uses: hashicorp/setup-packer@main
@@ -197,6 +215,12 @@ jobs:
197215
with:
198216
workload_identity_provider: '${{ secrets.WIF_PROVIDER }}'
199217
service_account: '${{ secrets.WIF_SERVICE_ACCOUNT }}'
218+
- name: 'Set up Google Cloud SDK'
219+
uses: 'google-github-actions/setup-gcloud@v2'
220+
with:
221+
version: 'latest'
222+
project_id: '${{ vars.GCP_PROJECT_ID }}'
223+
#install_components: 'beta' # optional: install additional components
200224

201225
- name: Setup `packer`
202226
uses: hashicorp/setup-packer@main
@@ -236,6 +260,12 @@ jobs:
236260
with:
237261
workload_identity_provider: '${{ secrets.WIF_PROVIDER }}'
238262
service_account: '${{ secrets.WIF_SERVICE_ACCOUNT }}'
263+
- name: 'Set up Google Cloud SDK'
264+
uses: 'google-github-actions/setup-gcloud@v2'
265+
with:
266+
version: 'latest'
267+
project_id: '${{ vars.GCP_PROJECT_ID }}'
268+
#install_components: 'beta' # optional: install additional components
239269

240270
- name: Setup `packer`
241271
uses: hashicorp/setup-packer@main

CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
88
## [1.2.0] - 2025-??-??
99
### Added
1010
- `dev` branch to GHA trigger
11-
- `Set up Google Cloud SDK` step to the GHA job steps
12-
- using IAP to connect to the VM to build (which requires Google Cloud SDK)
13-
- `use_iap` = true
14-
- `preemptible` = true
11+
- Set up Google Cloud SDK (`google-github-actions/setup-gcloud@v2`) step to the GHA job steps
12+
- Using IAP to connect to the VM to build, which requires Google Cloud SDK (`use_iap = true`)
13+
- Packer variable `machine_type` (default: `n2-standard-4`)
14+
- Using preemptible VM instance (`preemptible = true`)
1515
### Changed
1616
- Updated Consul version from `1.20.5` to `1.21.0`
1717
- Updated Nomad version from `1.9.7` to `1.10.0`

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
[Medium: Getting started with HashiCorp Packer on Google Cloud Platform](https://medium.com/@glen.yu/getting-started-with-hashicorp-packer-on-google-cloud-platform-a36bfeffbfa9)
99

10+
I'm also using larger machine types (i.e. *n2-standard-4*), but with [preemptible VM instances](https://cloud.google.com/compute/docs/instances/preemptible) which should both speed up the build process and reduce overall cost.
11+
1012
## Setup
1113

1214
### 0 - Fork this repo
@@ -45,7 +47,7 @@ jobs:
4547
4648
- name: 'Authenticate to Google Cloud'
4749
id: 'auth'
48-
uses: 'google-github-actions/auth@v1'
50+
uses: 'google-github-actions/auth@v2'
4951
with:
5052
credentials_json: '${{ secrets.GCP_CREDENTIALS_JSON }}'
5153

hashistack/consul_base.pkr.hcl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ packer {
1212
variable "project_id" {}
1313
variable "zone" {}
1414
variable "arch" {}
15+
variable "machine_type" {}
1516
variable "source_image_family" {}
1617
variable "image_family" {}
1718
variable "consul_version" {}
@@ -30,9 +31,8 @@ locals {
3031
source "googlecompute" "consul-base" {
3132
project_id = var.project_id
3233
zone = var.zone
33-
machine_type = "n1-standard-2"
34-
ssh_username = "packer"
35-
use_os_login = "false"
34+
machine_type = var.machine_type
35+
preemptible = true
3636

3737
# use custom base image that was built
3838
source_image_family = var.source_image_family
@@ -41,6 +41,10 @@ source "googlecompute" "consul-base" {
4141
image_name = "consul-${local.image_consul_version}-${var.arch}-base-${local.datestamp}"
4242
image_description = "Consul base image"
4343

44+
ssh_username = "packer"
45+
use_os_login = false
46+
use_iap = true
47+
4448
tags = ["packer"]
4549
}
4650

hashistack/consul_server.pkr.hcl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ packer {
1212
variable "project_id" {}
1313
variable "zone" {}
1414
variable "arch" {}
15+
variable "machine_type" {}
1516
variable "source_image_family" {}
1617
variable "image_family" {}
1718
variable "consul_version" {}
@@ -30,9 +31,8 @@ locals {
3031
source "googlecompute" "consul-server" {
3132
project_id = var.project_id
3233
zone = var.zone
33-
machine_type = "n1-standard-2"
34-
ssh_username = "packer"
35-
use_os_login = "false"
34+
machine_type = var.machine_type
35+
preemptible = true
3636

3737
# use custom base image that was built
3838
source_image_family = var.source_image_family
@@ -41,6 +41,10 @@ source "googlecompute" "consul-server" {
4141
image_name = "consul-${local.image_consul_version}-${var.arch}-server-${local.datestamp}"
4242
image_description = "Consul server image"
4343

44+
ssh_username = "packer"
45+
use_os_login = false
46+
use_iap = true
47+
4448
tags = ["packer"]
4549
}
4650

hashistack/nomad_client.pkr.hcl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ packer {
1212
variable "project_id" {}
1313
variable "zone" {}
1414
variable "arch" {}
15+
variable "machine_type" {}
1516
variable "source_image_family" {}
1617
variable "image_family" {}
1718
variable "consul_version" {}
@@ -32,9 +33,8 @@ locals {
3233
source "googlecompute" "nomad-client" {
3334
project_id = var.project_id
3435
zone = var.zone
35-
machine_type = "n1-standard-2"
36-
ssh_username = "packer"
37-
use_os_login = "false"
36+
machine_type = var.machine_type
37+
preemptible = true
3838

3939
# use custom base image that was built
4040
source_image_family = var.source_image_family
@@ -43,6 +43,10 @@ source "googlecompute" "nomad-client" {
4343
image_name = "nomad-${local.image_nomad_version}-${var.arch}-client-${local.datestamp}"
4444
image_description = "Nomad client image"
4545

46+
ssh_username = "packer"
47+
use_os_login = false
48+
use_iap = true
49+
4650
tags = ["packer"]
4751
}
4852

hashistack/nomad_server.pkr.hcl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ packer {
1212
variable "project_id" {}
1313
variable "zone" {}
1414
variable "arch" {}
15+
variable "machine_type" {}
1516
variable "source_image_family" {}
1617
variable "image_family" {}
1718
variable "nomad_version" {}
@@ -30,9 +31,8 @@ locals {
3031
source "googlecompute" "nomad-server" {
3132
project_id = var.project_id
3233
zone = var.zone
33-
machine_type = "n1-standard-2"
34-
ssh_username = "packer"
35-
use_os_login = "false"
34+
machine_type = var.machine_type
35+
preemptible = true
3636

3737
# use custom base image that was built
3838
source_image_family = var.source_image_family
@@ -41,6 +41,10 @@ source "googlecompute" "nomad-server" {
4141
image_name = "nomad-${local.image_nomad_version}-${var.arch}-server-${local.datestamp}"
4242
image_description = "Nomad server image"
4343

44+
ssh_username = "packer"
45+
use_os_login = false
46+
use_iap = true
47+
4448
tags = ["packer"]
4549
}
4650

hashistack/variables.pkrvars.hcl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
zone = "northamerica-northeast2-c"
2-
arch = "amd64"
1+
zone = "northamerica-northeast2-c"
2+
arch = "amd64"
3+
machine_type = "n2-standard-4"
34

45
consul_version = "1.21.0"
56
nomad_version = "1.10.0"

hashistack/vault_base.pkr.hcl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ packer {
1212
variable "project_id" {}
1313
variable "zone" {}
1414
variable "arch" {}
15+
variable "machine_type" {}
1516
variable "source_image_family" {}
1617
variable "image_family" {}
1718
variable "vault_version" {}
@@ -30,9 +31,8 @@ locals {
3031
source "googlecompute" "vault-base" {
3132
project_id = var.project_id
3233
zone = var.zone
33-
machine_type = "n1-standard-2"
34-
ssh_username = "packer"
35-
use_os_login = "false"
34+
machine_type = var.machine_type
35+
preemptible = true
3636

3737
# use custom base image that was built
3838
source_image_family = var.source_image_family
@@ -41,6 +41,10 @@ source "googlecompute" "vault-base" {
4141
image_name = "vault-${local.image_vault_version}-${var.arch}-base-${local.datestamp}"
4242
image_description = "Vault base image"
4343

44+
ssh_username = "packer"
45+
use_os_login = false
46+
use_iap = true
47+
4448
tags = ["packer"]
4549
}
4650

0 commit comments

Comments
 (0)