diff --git a/locals.tf b/locals.tf index 5520b6f..3590c2e 100644 --- a/locals.tf +++ b/locals.tf @@ -57,6 +57,7 @@ locals { runners_enable_monitoring = var.runners_enable_monitoring runners_network = var.network runners_subnetwork = var.subnetwork + runners_docker_machine_image = var.runner_machine_image }) template_shutdown_script = templatefile("${path.module}/templates/shutdown-script.sh.tpl", { @@ -116,3 +117,4 @@ locals { } ) } + diff --git a/templates/startup-script.sh.tpl b/templates/startup-script.sh.tpl index a5b60de..cd48959 100644 --- a/templates/startup-script.sh.tpl +++ b/templates/startup-script.sh.tpl @@ -63,7 +63,7 @@ else # See: https://github.com/docker/machine/issues/3845#issuecomment-280389178 export USER=root export HOME=/root - suffix="$(< /dev/urandom tr -dc _a-z-0-9 | head -c6)" + suffix="$(< /dev/urandom tr -dc a-z-0-9 | head -c6)" dummymachine="${prefix}-gitlab-runner-dummy-machine-$suffix" echo "Verifying docker-machine and generating SSH keys ahead of time." docker-machine create --driver google \ @@ -79,6 +79,9 @@ else %{~ if runners_subnetwork != "" ~} --google-subnetwork ${runners_subnetwork} \ %{~ endif ~} + %{~ if runners_docker_machine_image != "" ~} + --google-machine-image ${runners_docker_machine_image} \ + %{~ endif ~} $dummymachine docker-machine rm -y $dummymachine unset HOME @@ -136,3 +139,4 @@ ${post_install} service gitlab-runner restart chkconfig gitlab-runner on + diff --git a/variables.tf b/variables.tf index cca96bb..5fd6148 100644 --- a/variables.tf +++ b/variables.tf @@ -82,7 +82,7 @@ variable "docker_machine_preemptible" { variable "runner_machine_image" { description = "A GCP custom image to use for spinning up runners when using docker-machine" type = string - default = "ubuntu-os-cloud/global/images/ubuntu-2004-focal-v20220419" + default = "cos-cloud/global/images/family/cos-97-lts" } variable "docker_machine_disk_type" {