Skip to content

Commit 0c66a28

Browse files
committed
Configuration parameters for post_build_script, pre_clone_script, request_concurrency and output_limit. #22
1 parent 8be6375 commit 0c66a28

File tree

5 files changed

+80
-40
lines changed

5 files changed

+80
-40
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

77
## [Unreleased]
8+
9+
- Added: Configuration parameters for post_build_script, pre_clone_script, request_concurrency and output_limit. #22
10+
- Added: Configurable docker image for runner #27
11+
- Added: Add pre/post install user-data snippets for runners #26
12+
813
## [1.7.0] - 2018-11-21
914
- Added option to configure instance-profile for runner pre build script. Thanks to @msvechla
1015

README.md

Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -102,46 +102,51 @@ module "gitlab-runner" {
102102

103103
All variables and defaults:
104104

105-
| Name | Description | Type | Default | Required |
106-
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------- | :----: | :--------------: | :------: |
107-
| amazon_optimized_amis | AMI map per region-zone for the gitlab-runner instance AMI. | map | `<map>` | no |
108-
| aws_region | AWS region. | string | - | yes |
109-
| cache_bucket_prefix | Prefix for s3 cache bucket name. | string | "" | no |
110-
| cache_expiration_days | Number of days before cache objects expires. | string | `1` | no |
111-
| cache_user | User name of the user to create to write and read to the s3 cache. | string | `cache_user` | no |
112-
| docker_machine_instance_type | Instance type used for the instances hosting docker-machine. | string | `m4.large` | no |
113-
| docker_machine_spot_price_bid | Spot price bid. | string | `0.04` | no |
114-
| docker_machine_user | User name for the user to create spot instances to host docker-machine. | string | `docker-machine` | no |
115-
| docker_machine_version | Version of docker-machine. | string | `0.15.0` | no |
116-
| enable_cloudwatch_logging | Enable or disable the CloudWatch logging. | string | `1` | no |
117-
| environment | A name that identifies the environment, will used as prefix and for tagging. | string | - | yes |
118-
| gitlab_runner_version | Version for the gitlab runner. | string | `11.3.1` | no |
119-
| instance_type | Instance type used for the gitlab-runner. | string | `t2.micro` | no |
120-
| userdata_pre_install | User-data script snippet to insert before gitlab-runner install | string | "" | no |
121-
| userdata_post_install | User-data script snippet to insert after gitlab-runner install | string | "" | no |
122-
| runners_concurrent | Concurrent value for the runners, will be used in the runner config.toml | string | `10` | no |
123-
| runners_gitlab_url | URL of the gitlab instance to connect to. | string | - | yes |
124-
| runners_idle_count | Idle count of the runners, will be used in the runner config.toml | string | `0` | no |
125-
| runners_idle_time | Idle time of the runners, will be used in the runner config.toml | string | `600` | no |
126-
| runners_limit | Limit for the runners, will be used in the runner config.toml | string | `0` | no |
127-
| runners_monitoring | Enable detailed cloudwatch monitoring for spot instances. | string | `false` | no |
128-
| runners_name | Name of the runner, will be used in the runner config.toml | string | - | yes |
129-
| runners_off_peak_idle_count | Off peak idle count of the runners, will be used in the runner config.toml. | string | `0` | no |
130-
| runners_off_peak_idle_time | Off peak idle time of the runners, will be used in the runner config.toml. | string | `0` | no |
131-
| runners_off_peak_periods | Off peak periods of the runners, will be used in the runner config.toml. | string | `` | no |
132-
| runners_off_peak_timezone | Off peak idle time zone of the runners, will be used in the runner config.toml. | string | `` | no |
133-
| runners_image | Image to run builds, will be used in the runner config.toml | string | `docker:18.03.1-ce` | no |
134-
| runners_privilled | Runners will run in privilled mode, will be used in the runner config.toml | string | `true` | no |
135-
| runners_root_size | Runnner instance root size in GB. | string | `16` | no |
136-
| runners_iam_instance_profile_name | Instance profile to attach to the runners | string | "" | no |
137-
| runners_pre_build_script | Script to execute in the pipeline just before the build. | string | "" | no |
138-
| runners_use_private_address | Restrict runners to use only private address | string | `true` | no |
139-
| runners_token | Token for the runner, will be used in the runner config.toml | string | - | yes |
140-
| ssh_public_key | Public SSH key used for the gitlab-runner ec2 instance. | string | - | yes |
141-
| subnet_id_gitlab_runner | Subnet used for hosting the gitlab-runner. | string | - | yes |
142-
| subnet_id_runners | Subnet used to hosts the docker-machine runners. | string | - | yes |
143-
| tags | Map of tags that will be added to created resources. By default resources will be taggen with name and environemnt. | map | `<map>` | no |
144-
| vpc_id | The VPC that is used for the instances. | string | - | yes |
105+
| Name | Description | Type | Default | Required |
106+
|------|-------------|:----:|:-----:|:-----:|
107+
| allow_iam_service_linked_role_creation | Attach policy to runner instance to create service linked roles. | string | `true` | no |
108+
| amazon_optimized_amis | AMI map per region-zone for the gitlab-runner instance AMI. | map | `<map>` | no |
109+
| aws_region | AWS region. | string | - | yes |
110+
| cache_bucket_prefix | Prefix for s3 cache bucket name. | string | `` | no |
111+
| cache_expiration_days | Number of days before cache objects expires. | string | `1` | no |
112+
| cache_user | User name of the user to create to write and read to the s3 cache. | string | `cache_user` | no |
113+
| docker_machine_instance_type | Instance type used for the instances hosting docker-machine. | string | `m4.large` | no |
114+
| docker_machine_spot_price_bid | Spot price bid. | string | `0.04` | no |
115+
| docker_machine_user | User name for the user to create spot instances to host docker-machine. | string | `docker-machine` | no |
116+
| docker_machine_version | Version of docker-machine. | string | `0.15.0` | no |
117+
| enable_cloudwatch_logging | Enable or disable the CloudWatch logging. | string | `1` | no |
118+
| environment | A name that identifies the environment, will used as prefix and for tagging. | string | - | yes |
119+
| gitlab_runner_version | Version for the gitlab runner. | string | `11.3.1` | no |
120+
| instance_type | Instance type used for the gitlab-runner. | string | `t2.micro` | no |
121+
| runners_concurrent | Concurrent value for the runners, will be used in the runner config.toml | string | `10` | no |
122+
| runners_gitlab_url | URL of the gitlab instance to connect to. | string | - | yes |
123+
| runners_iam_instance_profile_name | IAM instance profile name of the runners, will be used in the runner config.toml | string | `` | no |
124+
| runners_idle_count | Idle count of the runners, will be used in the runner config.toml | string | `0` | no |
125+
| runners_idle_time | Idle time of the runners, will be used in the runner config.toml | string | `600` | no |
126+
| runners_image | Image to run builds, will be used in the runner config.toml | string | `docker:18.03.1-ce` | no |
127+
| runners_limit | Limit for the runners, will be used in the runner config.toml | string | `0` | no |
128+
| runners_monitoring | Enable detailed cloudwatch monitoring for spot instances. | string | `false` | no |
129+
| runners_name | Name of the runner, will be used in the runner config.toml | string | - | yes |
130+
| runners_off_peak_idle_count | Off peak idle count of the runners, will be used in the runner config.toml. | string | `0` | no |
131+
| runners_off_peak_idle_time | Off peak idle time of the runners, will be used in the runner config.toml. | string | `0` | no |
132+
| runners_off_peak_periods | Off peak periods of the runners, will be used in the runner config.toml. | string | `` | no |
133+
| runners_off_peak_timezone | Off peak idle time zone of the runners, will be used in the runner config.toml. | string | `` | no |
134+
| runners_output_limit | Set maximum build log size in kilobytes, by default set to 4096 (4MB) | string | `4096` | no |
135+
| runners_post_build_script | Commands to be executed on the Runner just after executing the build, but before executing after_script. | string | `` | no |
136+
| runners_pre_build_script | Script to execute in the pipeline just before the build, will be used in the runner config.toml | string | `` | no |
137+
| runners_pre_clone_script | Commands to be executed on the Runner before cloning the Git repository. this can be used to adjust the Git client configuration first, for example. | string | `` | no |
138+
| runners_privilled | Runners will run in privilled mode, will be used in the runner config.toml | string | `true` | no |
139+
| runners_request_concurrency | Limit number of concurrent requests for new jobs from GitLab (default 1) | string | `1` | no |
140+
| runners_root_size | Runnner instance root size in GB. | string | `16` | no |
141+
| runners_token | Token for the runner, will be used in the runner config.toml | string | - | yes |
142+
| runners_use_private_address | Restrict runners to use only private address | string | `true` | no |
143+
| ssh_public_key | Public SSH key used for the gitlab-runner ec2 instance. | string | - | yes |
144+
| subnet_id_gitlab_runner | Subnet used for hosting the gitlab-runner. | string | - | yes |
145+
| subnet_id_runners | Subnet used to hosts the docker-machine runners. | string | - | yes |
146+
| tags | Map of tags that will be added to created resources. By default resources will be taggen with name and environemnt. | map | `<map>` | no |
147+
| userdata_post_install | User-data script snippet to insert after gitlab-runner install | string | `` | no |
148+
| userdata_pre_install | User-data script snippet to insert before gitlab-runner install | string | `` | no |
149+
| vpc_id | The VPC that is used for the instances. | string | - | yes |
145150

146151
## Example
147152

main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ data "template_file" "runners" {
121121
runners_iam_instance_profile_name = "${var.runners_iam_instance_profile_name}"
122122
runners_use_private_address = "${var.runners_use_private_address}"
123123
runners_pre_build_script = "${var.runners_pre_build_script}"
124+
runners_post_build_script = "${var.runners_post_build_script}"
125+
runners_pre_clone_script = "${var.runners_pre_clone_script}"
126+
runners_request_concurrency = "${var.runners_request_concurrency}"
127+
runners_output_limit = "${var.runners_output_limit}"
124128
bucket_user_access_key = "${aws_iam_access_key.cache_user.id}"
125129
bucket_user_secret_key = "${aws_iam_access_key.cache_user.secret}"
126130
bucket_name = "${aws_s3_bucket.build_cache.bucket}"

template/runner-config.tpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ check_interval = 0
77
token = "${runners_token}"
88
executor = "docker+machine"
99
pre_build_script = "${runners_pre_build_script}"
10+
post_build_script = "${runners_post_build_script}"
11+
pre_clone_script = "${runners_pre_clone_script}"
12+
request_concurrency = ${runners_request_concurrency}
13+
output_limit = ${runners_output_limit}
1014
limit = ${runners_limit}
1115
[runners.docker]
1216
tls_verify = false

variables.tf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,28 @@ variable "runners_pre_build_script" {
166166
default = ""
167167
}
168168

169+
variable "runners_post_build_script" {
170+
description = "Commands to be executed on the Runner just after executing the build, but before executing after_script. "
171+
type = "string"
172+
default = ""
173+
}
174+
175+
variable "runners_pre_clone_script" {
176+
description = "Commands to be executed on the Runner before cloning the Git repository. this can be used to adjust the Git client configuration first, for example. "
177+
type = "string"
178+
default = ""
179+
}
180+
181+
variable "runners_request_concurrency" {
182+
description = "Limit number of concurrent requests for new jobs from GitLab (default 1)"
183+
default = "1"
184+
}
185+
186+
variable "runners_output_limit" {
187+
description = "Set maximum build log size in kilobytes, by default set to 4096 (4MB)"
188+
default = "4096"
189+
}
190+
169191
variable "userdata_pre_install" {
170192
description = "User-data script snippet to insert before gitlab-runner install"
171193
type = "string"

0 commit comments

Comments
 (0)