Skip to content

Commit 5d00f61

Browse files
committed
move runner config into separate template
1 parent 6971e5e commit 5d00f61

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

main.tf

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ locals {
107107
}]
108108
})
109109

110-
template_runner_config = templatefile("${path.module}/template/runner-config.tftpl",
110+
template_runner_worker_config = templatefile("${path.module}/template/runner-worker-config.tftpl",
111111
{
112112
aws_region = data.aws_region.current.name
113113
gitlab_url = var.runner_gitlab.url
@@ -123,27 +123,34 @@ locals {
123123
runners_token = var.runner_gitlab.registration_token
124124
runners_executor = var.runner_worker.type
125125
runners_limit = var.runner_worker.max_jobs
126-
runners_concurrent = var.runner_manager.maximum_concurrent_jobs
127126
runners_environment_vars = jsonencode(var.runner_worker.environment_variables)
128127
runners_pre_build_script = var.runner_worker_gitlab_pipeline.pre_build_script
129128
runners_post_build_script = var.runner_worker_gitlab_pipeline.post_build_script
130129
runners_pre_clone_script = var.runner_worker_gitlab_pipeline.pre_clone_script
131130
runners_request_concurrency = var.runner_worker.request_concurrency
132131
runners_output_limit = var.runner_worker.output_limit
133-
runners_check_interval = var.runner_manager.gitlab_check_interval
134132
runners_volumes_tmpfs = join("\n", [for v in var.runner_worker_docker_volumes_tmpfs : format("\"%s\" = \"%s\"", v.volume, v.options)])
135133
runners_services_volumes_tmpfs = join("\n", [for v in var.runner_worker_docker_services_volumes_tmpfs : format("\"%s\" = \"%s\"", v.volume, v.options)])
136134
runners_docker_services = local.runners_docker_services
137135
runners_docker_options = local.runners_docker_options_toml
138136
bucket_name = local.bucket_name
139137
shared_cache = var.runner_worker_cache.shared
140-
sentry_dsn = var.runner_manager.sentry_dsn
141-
prometheus_listen_address = var.runner_manager.prometheus_listen_address
142138
auth_type = var.runner_worker_cache.authentication_type
143139
runners_docker_autoscaler = var.runner_worker.type == "docker-autoscaler" ? local.template_runner_docker_autoscaler : ""
144140
runners_docker_machine = var.runner_worker.type == "docker+machine" ? local.template_runner_docker_machine : ""
145141
}
146142
)
143+
144+
template_runner_config = templatefile("runner-agent.tftpl",
145+
{
146+
prometheus_listen_address = var.runner_manager.prometheus_listen_address
147+
runners_check_interval = var.runner_manager.gitlab_check_interval
148+
runners_concurrent = var.runner_manager.maximum_concurrent_jobs
149+
sentry_dsn = var.runner_manager.sentry_dsn
150+
151+
runners = [local.template_runner_worker_config]
152+
}
153+
)
147154
}
148155

149156
# ignores: Autoscaling Groups Supply Tags --> we use a "dynamic" block to create the tags

modules/terminate-agent-hook/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This module is used __internally__ by the parent [_terraform\-aws\-gitlab\-runne
77
## Overview
88

99
The Lambda functions evaluates an EC2 instance tag called `gitlab-runner-parent-id`, set in the
10-
[runner config](../../template/runner-config.tftpl) by the parent module's
10+
[runner config](../../template/runner-agent.tftpl) by the parent module's
1111
[user data](../../template/gitlab-runner.tftpl). Runner instances created by the runner
1212
will have this tag applied with the parent runner's instance ID. When the runner
1313
in the ASG is terminated, the lifecycle hook triggers the Lambda to

template/runner-agent.tftpl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
concurrent = ${runners_concurrent}
2+
check_interval = ${runners_check_interval}
3+
sentry_dsn = "${sentry_dsn}"
4+
log_format = "json"
5+
listen_address = "${prometheus_listen_address}"
6+
7+
́%{ for runner_config in runners }
8+
${runner_config}
9+
%{ endfor }

template/runner-config.tftpl renamed to template/runner-definition.tftpl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
concurrent = ${runners_concurrent}
2-
check_interval = ${runners_check_interval}
3-
sentry_dsn = "${sentry_dsn}"
4-
log_format = "json"
5-
listen_address = "${prometheus_listen_address}"
6-
71
[[runners]]
82
name = "${runners_name}"
93
url = "${gitlab_url}"
@@ -51,4 +45,3 @@ listen_address = "${prometheus_listen_address}"
5145
${key} = ${value}
5246
%{~ endfor ~}
5347
%{~ endfor ~}
54-

0 commit comments

Comments
 (0)