From 3e3467ac80fb581e538888553e56d380f0d41aaf Mon Sep 17 00:00:00 2001 From: Tomasz <35335044+czomo@users.noreply.github.com> Date: Fri, 29 Nov 2024 09:52:53 +0100 Subject: [PATCH 1/5] feat: Allow to specify ci_runner_image --- main.tf | 2 +- variables.tf | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/main.tf b/main.tf index db1d1cc..0ea0f6f 100644 --- a/main.tf +++ b/main.tf @@ -71,7 +71,7 @@ resource "google_compute_instance" "ci_runner" { boot_disk { initialize_params { - image = "centos-cloud/centos-7" + image = var.ci_runner_image size = var.ci_runner_disk_size type = "pd-standard" } diff --git a/variables.tf b/variables.tf index 6d24408..22d891c 100644 --- a/variables.tf +++ b/variables.tf @@ -55,11 +55,19 @@ variable "ci_runner_disk_size" { default = "20" description = "The size of the persistent disk in GB." } + +variable "ci_runner_image" { + type = string + default = "centos-cloud/centos-stream-9" + description = "Name of the image for the runner" +} + variable "ci_runner_gitlab_name" { type = string default = "" description = "Register the runner in GitLab using this name. If empty the value \"gcp-$${var.gcp_project}\" will be used." } + variable "ci_runner_gitlab_tags" { type = string default = "" From 52c568a5b2b04abe51f0dcb609675d665c9a92c6 Mon Sep 17 00:00:00 2001 From: Tomasz <35335044+czomo@users.noreply.github.com> Date: Fri, 29 Nov 2024 10:58:01 +0100 Subject: [PATCH 2/5] chore: Adapt runner register script to new formula --- main.tf | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/main.tf b/main.tf index 0ea0f6f..e5de57e 100644 --- a/main.tf +++ b/main.tf @@ -98,23 +98,23 @@ echo "Installing docker machine." curl -L https://github.com/docker/machine/releases/download/v0.16.2/docker-machine-Linux-x86_64 -o /tmp/docker-machine sudo install /tmp/docker-machine /usr/local/bin/docker-machine -echo "Verifying docker-machine and generating SSH keys ahead of time." -docker-machine create --driver google \ - --google-project ${var.gcp_project} \ - --google-machine-type f1-micro \ - --google-zone ${var.gcp_zone} \ - --google-service-account ${google_service_account.ci_worker.email} \ - --google-scopes https://www.googleapis.com/auth/cloud-platform \ - --google-disk-type pd-ssd \ - --google-disk-size ${var.ci_worker_disk_size} \ - --google-machine-image ubuntu-os-cloud/global/images/ubuntu-2004-focal-v20220419 \ - --google-tags ${var.ci_worker_instance_tags} \ - --google-use-internal-ip \ - --google-network ${var.ci_runner_network} \ - %{if var.ci_runner_subnetwork != ""}--google-subnetwork ${var.ci_runner_subnetwork}%{endif} \ - ${var.gcp_resource_prefix}-test-machine - -docker-machine rm -y ${var.gcp_resource_prefix}-test-machine +# echo "Verifying docker-machine and generating SSH keys ahead of time." +# docker-machine create --driver google \ +# --google-project ${var.gcp_project} \ +# --google-machine-type f1-micro \ +# --google-zone ${var.gcp_zone} \ +# --google-service-account ${google_service_account.ci_worker.email} \ +# --google-scopes https://www.googleapis.com/auth/cloud-platform \ +# --google-disk-type pd-ssd \ +# --google-disk-size ${var.ci_worker_disk_size} \ +# --google-machine-image ubuntu-os-cloud/global/images/ubuntu-2004-focal-v20220419 \ +# --google-tags ${var.ci_worker_instance_tags} \ +# --google-use-internal-ip \ +# --google-network ${var.ci_runner_network} \ +# %{if var.ci_runner_subnetwork != ""}--google-subnetwork ${var.ci_runner_subnetwork}%{endif} \ +# ${var.gcp_resource_prefix}-test-machine + +# docker-machine rm -y ${var.gcp_resource_prefix}-test-machine echo "Setting GitLab concurrency" sed -i "s/concurrent = .*/concurrent = ${var.ci_concurrency}/" /etc/gitlab-runner/config.toml @@ -125,7 +125,6 @@ sudo gitlab-runner register -n \ --token ${var.ci_token} \ --executor "docker+machine" \ --docker-image "alpine:latest" \ - --tag-list "${var.ci_runner_gitlab_tags}" \ --machine-machine-driver google \ --docker-privileged=${var.docker_privileged} \ --machine-idle-time ${var.ci_worker_idle_time} \ From 08e79979c0cc8fe393c8c1af611b1c9dd6b8e06c Mon Sep 17 00:00:00 2001 From: Tomasz <35335044+czomo@users.noreply.github.com> Date: Fri, 29 Nov 2024 11:07:07 +0100 Subject: [PATCH 3/5] chore: Remove script --- main.tf | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/main.tf b/main.tf index e5de57e..3d82112 100644 --- a/main.tf +++ b/main.tf @@ -98,24 +98,6 @@ echo "Installing docker machine." curl -L https://github.com/docker/machine/releases/download/v0.16.2/docker-machine-Linux-x86_64 -o /tmp/docker-machine sudo install /tmp/docker-machine /usr/local/bin/docker-machine -# echo "Verifying docker-machine and generating SSH keys ahead of time." -# docker-machine create --driver google \ -# --google-project ${var.gcp_project} \ -# --google-machine-type f1-micro \ -# --google-zone ${var.gcp_zone} \ -# --google-service-account ${google_service_account.ci_worker.email} \ -# --google-scopes https://www.googleapis.com/auth/cloud-platform \ -# --google-disk-type pd-ssd \ -# --google-disk-size ${var.ci_worker_disk_size} \ -# --google-machine-image ubuntu-os-cloud/global/images/ubuntu-2004-focal-v20220419 \ -# --google-tags ${var.ci_worker_instance_tags} \ -# --google-use-internal-ip \ -# --google-network ${var.ci_runner_network} \ -# %{if var.ci_runner_subnetwork != ""}--google-subnetwork ${var.ci_runner_subnetwork}%{endif} \ -# ${var.gcp_resource_prefix}-test-machine - -# docker-machine rm -y ${var.gcp_resource_prefix}-test-machine - echo "Setting GitLab concurrency" sed -i "s/concurrent = .*/concurrent = ${var.ci_concurrency}/" /etc/gitlab-runner/config.toml From 4763945eb1c7e6c0326302e39ae09e2b927f8d7b Mon Sep 17 00:00:00 2001 From: Tomasz <35335044+czomo@users.noreply.github.com> Date: Fri, 29 Nov 2024 11:56:13 +0100 Subject: [PATCH 4/5] chore: Update worker ubuntu image --- main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.tf b/main.tf index 3d82112..d932b1e 100644 --- a/main.tf +++ b/main.tf @@ -113,7 +113,7 @@ sudo gitlab-runner register -n \ --machine-machine-name "${var.gcp_resource_prefix}-worker-%s" \ --machine-machine-options "google-project=${var.gcp_project}" \ --machine-machine-options "google-machine-type=${var.ci_worker_instance_type}" \ - --machine-machine-options "google-machine-image=ubuntu-os-cloud/global/images/ubuntu-2004-focal-v20220419" \ + --machine-machine-options "google-machine-image=ubuntu-os-cloud/global/images/ubuntu-2404-noble-amd64-v20241115" \ --machine-machine-options "google-zone=${var.gcp_zone}" \ --machine-machine-options "google-service-account=${google_service_account.ci_worker.email}" \ --machine-machine-options "google-scopes=https://www.googleapis.com/auth/cloud-platform" \ From 97308717093e13b3a5db86ce1390741b8787f867 Mon Sep 17 00:00:00 2001 From: Tomasz <35335044+czomo@users.noreply.github.com> Date: Fri, 29 Nov 2024 12:36:09 +0100 Subject: [PATCH 5/5] chore: Allow to specify ci_worker_image --- main.tf | 2 +- variables.tf | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/main.tf b/main.tf index d932b1e..5012fe9 100644 --- a/main.tf +++ b/main.tf @@ -113,7 +113,7 @@ sudo gitlab-runner register -n \ --machine-machine-name "${var.gcp_resource_prefix}-worker-%s" \ --machine-machine-options "google-project=${var.gcp_project}" \ --machine-machine-options "google-machine-type=${var.ci_worker_instance_type}" \ - --machine-machine-options "google-machine-image=ubuntu-os-cloud/global/images/ubuntu-2404-noble-amd64-v20241115" \ + --machine-machine-options "google-machine-image=${var.ci_worker_image}" \ --machine-machine-options "google-zone=${var.gcp_zone}" \ --machine-machine-options "google-service-account=${google_service_account.ci_worker.email}" \ --machine-machine-options "google-scopes=https://www.googleapis.com/auth/cloud-platform" \ diff --git a/variables.tf b/variables.tf index 22d891c..aa20235 100644 --- a/variables.tf +++ b/variables.tf @@ -62,6 +62,12 @@ variable "ci_runner_image" { description = "Name of the image for the runner" } +variable "ci_worker_image" { + type = string + default = "ubuntu-os-cloud/global/images/ubuntu-2404-noble-amd64-v20241115" + description = "Name of the image for the worker" +} + variable "ci_runner_gitlab_name" { type = string default = ""