Skip to content

Commit

Permalink
feat: Add option to disable yum update during cloud init (#545)
Browse files Browse the repository at this point in the history
* Add ability to not run yum update at startup

* Rename variable

* Convert runner_yum_update to string to boolean, update user_data to cope

* Improved method for toggling yum update on runners

* Read in file contents rather than templating

Co-authored-by: Steve Wilson <[email protected]>
Co-authored-by: Steve Wilson <[email protected]>
  • Loading branch information
3 people authored Oct 10, 2022
1 parent 6bfca6c commit 9948417
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ locals {
logging = var.enable_cloudwatch_logging ? local.logging_user_data : ""
gitlab_runner = local.template_gitlab_runner
user_data_trace_log = var.enable_runner_user_data_trace_log
yum_update = var.runner_yum_update ? local.file_yum_update : ""
})

file_yum_update = file("${path.module}/template/yum_update.tpl")

template_eip = templatefile("${path.module}/template/eip.tpl", {
eip = join(",", aws_eip.gitlab_runner.*.public_ip)
})
Expand Down
5 changes: 1 addition & 4 deletions template/user-data.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ token=$(curl -f -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-m

${eip}

for i in {1..7}; do
echo "Attempt: ---- " $i
yum -y update && break || sleep 60
done
${yum_update}

${logging}

Expand Down
4 changes: 4 additions & 0 deletions template/yum_update.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
for i in {1..7}; do
echo "Attempt: ---- " $i
yum -y update && break || sleep 60
done
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -824,3 +824,9 @@ variable "asg_terminate_lifecycle_lambda_timeout" {
default = 30
type = number
}

variable "runner_yum_update" {
description = "Run a yum update as part of starting the runner"
type = bool
default = true
}

0 comments on commit 9948417

Please sign in to comment.