Variabilize GCE region and zone, only use hostname for cloud, not hostname+target

This commit is contained in:
Samuel Aubertin 2025-04-27 16:43:03 +02:00
parent 6603cc9518
commit ba48937b12
2 changed files with 14 additions and 8 deletions

View File

@ -37,7 +37,7 @@ endef
define OPACK_INSTALL_CLOUD_CONTENT = define OPACK_INSTALL_CLOUD_CONTENT =
Choose your keyboard layout = fr Choose your keyboard layout = fr
System hostname = $(OPACK_SYS_HOSTNAME)-$(OPACK_TARGET) System hostname = $(OPACK_SYS_HOSTNAME)
Which network interface = vio0 Which network interface = vio0
IPv4 address for vio0 = dhcp IPv4 address for vio0 = dhcp
IPv6 address for vio0 = none IPv6 address for vio0 = none
@ -91,10 +91,10 @@ endef
define OPACK_TERRAFORM_CONTENT = define OPACK_TERRAFORM_CONTENT =
variable "credentials" { default = "../$(OPACK_GCE_JSON_KEY)" } variable "credentials" { default = "../$(OPACK_GCE_JSON_KEY)" }
variable "project" { default = "$(OPACK_GCE_PROJECT)" } variable "project" { default = "$(OPACK_GCE_PROJECT)" }
variable "region" { default = "europe-west4" } variable "region" { default = "$(OPACK_GCE_REGION)" }
variable "zone" { default = "europe-west4-b" } variable "zone" { default = "$(OPACK_GCE_ZONE)" }
provider "google" { provider "google" {
region = "$${var.region}" region = "$${var.region}"
@ -125,7 +125,7 @@ resource "google_compute_instance" "$(OPACK_TARGET)" {
zone = "$${var.gce_zone}" zone = "$${var.gce_zone}"
boot_disk { boot_disk {
initialize_params { initialize_params {
image = "openbsd" image = "openbsd"
} }
} }
network_interface { network_interface {

View File

@ -129,7 +129,13 @@ OPACK_GCE_JSON_KEY?=
# OPACK_GCE_BUCKET: The Google Cloud Storage bucket name, typically associated with the project, for the image import. # OPACK_GCE_BUCKET: The Google Cloud Storage bucket name, typically associated with the project, for the image import.
OPACK_GCE_BUCKET?=$(OPACK_GCE_PROJECT) OPACK_GCE_BUCKET?=$(OPACK_GCE_PROJECT)
# Define the machine type for the VM # OPACK_GCE_REGION: The Google Cloud Compute Engine region.
OPACK_GCE_REGION?=europe-west4
# OPACK_GCE_REGION: The Google Cloud Compute Engine zone.
OPACK_GCE_REGION?=europe-west4-b
# Define the machine type for the VM
OPACK_GCE_MACHINE?=e2-micro OPACK_GCE_MACHINE?=e2-micro
# The SSH key to use to connect to the cloud VM # The SSH key to use to connect to the cloud VM
@ -142,7 +148,7 @@ OPACK_TERRAFORM_DIR?=opack_deploy_$(OPACK_SHORT_REV)
# Terraform module dir # Terraform module dir
OPACK_TERRAFORM_MODULE_DIR?=$(OPACK_TERRAFORM_DIR)/opack-module OPACK_TERRAFORM_MODULE_DIR?=$(OPACK_TERRAFORM_DIR)/opack-module
ifdef OPACK_DEBUG ifndef OPACK_DEBUG
$(infoBOX $(OPACK_BOX_FILE)) $(infoBOX $(OPACK_BOX_FILE))
$(infoHOSTNAME $(OPACK_SYS_HOSTNAME)-$(OPACK_TARGET)) $(infoHOSTNAME $(OPACK_SYS_HOSTNAME)-$(OPACK_TARGET))
$(infoUSER $(OPACK_SYS_USER)) $(infoUSER $(OPACK_SYS_USER))