From 09daa75adf32a7d3a30f1bba7b6856b3e4ccde1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Mon, 3 Oct 2022 16:31:48 +0200 Subject: [PATCH] templates/packer: set the GCP bucket in the worker configuration Similar to AWS, set the GCP bucket in the worker configuration. --- .../worker-initialization-scripts/get_gcp_creds.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/templates/packer/ansible/roles/common/files/worker-initialization-scripts/get_gcp_creds.sh b/templates/packer/ansible/roles/common/files/worker-initialization-scripts/get_gcp_creds.sh index 1b8f816a46..d99a62cddf 100755 --- a/templates/packer/ansible/roles/common/files/worker-initialization-scripts/get_gcp_creds.sh +++ b/templates/packer/ansible/roles/common/files/worker-initialization-scripts/get_gcp_creds.sh @@ -4,6 +4,15 @@ source /tmp/cloud_init_vars echo "Deploy GCP credentials." +echo "Write the bucket." +# Always create the header and write the bucket, it's slightly ugly but it will work +# The bucket is always set, becuase the instance can potentially authenticate to GCP +# with a service account connected to it, without any explicit credentials. +sudo tee -a /etc/osbuild-worker/osbuild-worker.toml > /dev/null << EOF +[gcp] +bucket = "${WORKER_CONFIG_GCP_BUCKET:-}" +EOF + if [[ -z "$GCP_SERVICE_ACCOUNT_IMAGE_BUILDER_ARN" ]]; then echo "GCP_SERVICE_ACCOUNT_IMAGE_BUILDER_ARN not defined, skipping." exit 0 @@ -16,6 +25,5 @@ fi sudo tee -a /etc/osbuild-worker/osbuild-worker.toml > /dev/null << EOF -[gcp] credentials = "/etc/osbuild-worker/gcp_credentials.json" EOF