diff --git a/main.tf b/main.tf index 490b947db..30bf2f780 100644 --- a/main.tf +++ b/main.tf @@ -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) }) diff --git a/template/user-data.tpl b/template/user-data.tpl index ed10b0611..09fbff865 100644 --- a/template/user-data.tpl +++ b/template/user-data.tpl @@ -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} diff --git a/template/yum_update.tpl b/template/yum_update.tpl new file mode 100644 index 000000000..1bf4378b6 --- /dev/null +++ b/template/yum_update.tpl @@ -0,0 +1,4 @@ +for i in {1..7}; do + echo "Attempt: ---- " $i + yum -y update && break || sleep 60 +done diff --git a/variables.tf b/variables.tf index 488407113..649fdd6de 100644 --- a/variables.tf +++ b/variables.tf @@ -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 +}