From 855ecc0192e41416aad4adcb999c6e25106afc2e Mon Sep 17 00:00:00 2001 From: Niek Palm Date: Sun, 18 Aug 2019 12:26:50 +0200 Subject: [PATCH 1/5] Add release badge --- README.md | 3 ++- _docs/README.md | 3 ++- _docs/TF_MODULE.md | 2 ++ cache/README.md | 3 ++- cache/_docs/TF_MODULE.md | 2 ++ 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 647a785a4..5a1d370cc 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.com/npalm/terraform-aws-gitlab-runner.svg?branch=master)](https://travis-ci.com/npalm/terraform-aws-gitlab-runner) [![Gitter](https://badges.gitter.im/terraform-aws-gitlab-runner/Lobby.svg)](https://gitter.im/terraform-aws-gitlab-runner/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) +[![Build Status](https://travis-ci.com/npalm/terraform-aws-gitlab-runner.svg?branch=master)](https://travis-ci.com/npalm/terraform-aws-gitlab-runner) [![Gitter](https://badges.gitter.im/terraform-aws-gitlab-runner/Lobby.svg)](https://gitter.im/terraform-aws-gitlab-runner/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)[![GitHub release](https://img.shields.io/github/release/Naereen/StrapDown.js.svg)](https://GitHub.com/Naereen/StrapDown.js/releases/) # Terraform module for GitLab auto scaling runners on AWS spot instances @@ -221,6 +221,7 @@ terraform destroy | aws\_region | AWS region. | string | n/a | yes | | aws\_zone | AWS availability zone (typically 'a', 'b', or 'c'). | string | `"a"` | no | | cache\_bucket | Configuration to control the creation of the cache bucket. By default the bucket will be created and used as shared cache. To use the same cache cross multiple runners disable the cration of the cache and provice a policy and bucket name. See the public runner example for more details. | map | `` | no | +| cache\_bucket\_name\_include\_account\_id | Boolean to add current account ID to cache bucket name. | bool | `"true"` | no | | cache\_bucket\_prefix | Prefix for s3 cache bucket name. | string | `""` | no | | cache\_bucket\_versioning | Boolean used to enable versioning on the cache bucket, false by default. | bool | `"false"` | no | | cache\_expiration\_days | Number of days before cache objects expires. | number | `"1"` | no | diff --git a/_docs/README.md b/_docs/README.md index 3163b7d16..618543831 100644 --- a/_docs/README.md +++ b/_docs/README.md @@ -1,4 +1,5 @@ -[![Build Status](https://travis-ci.com/npalm/terraform-aws-gitlab-runner.svg?branch=master)](https://travis-ci.com/npalm/terraform-aws-gitlab-runner) [![Gitter](https://badges.gitter.im/terraform-aws-gitlab-runner/Lobby.svg)](https://gitter.im/terraform-aws-gitlab-runner/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) +[![Build Status](https://travis-ci.com/npalm/terraform-aws-gitlab-runner.svg?branch=master)](https://travis-ci.com/npalm/terraform-aws-gitlab-runner) [![Gitter](https://badges.gitter.im/terraform-aws-gitlab-runner/Lobby.svg)](https://gitter.im/terraform-aws-gitlab-runner/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)[![GitHub release](https://img.shields.io/github/release/Naereen/StrapDown.js.svg)](https://GitHub.com/Naereen/StrapDown.js/releases/) + # Terraform module for GitLab auto scaling runners on AWS spot instances diff --git a/_docs/TF_MODULE.md b/_docs/TF_MODULE.md index 95da241d8..23e817a77 100644 --- a/_docs/TF_MODULE.md +++ b/_docs/TF_MODULE.md @@ -8,6 +8,7 @@ | aws\_region | AWS region. | string | n/a | yes | | aws\_zone | AWS availability zone (typically 'a', 'b', or 'c'). | string | `"a"` | no | | cache\_bucket | Configuration to control the creation of the cache bucket. By default the bucket will be created and used as shared cache. To use the same cache cross multiple runners disable the cration of the cache and provice a policy and bucket name. See the public runner example for more details. | map | `` | no | +| cache\_bucket\_name\_include\_account\_id | Boolean to add current account ID to cache bucket name. | bool | `"true"` | no | | cache\_bucket\_prefix | Prefix for s3 cache bucket name. | string | `""` | no | | cache\_bucket\_versioning | Boolean used to enable versioning on the cache bucket, false by default. | bool | `"false"` | no | | cache\_expiration\_days | Number of days before cache objects expires. | number | `"1"` | no | @@ -82,3 +83,4 @@ | runner\_cache\_bucket\_name | Name of the S3 for the build cache. | | runner\_role\_arn | ARN of the role used for the docker machine runners. | | runner\_role\_name | Name of the role used for the docker machine runners. | + diff --git a/cache/README.md b/cache/README.md index bd1f7e7bc..036fbe73b 100644 --- a/cache/README.md +++ b/cache/README.md @@ -4,7 +4,7 @@ This sub module creates an S3 bucket for build caches. The cache will have by de ## Usages -``` +``` module "cache" { source = "https://github.com/npalm/terraform-aws-gitlab-runner/tree/move-cache-to-moudle/cache" @@ -29,6 +29,7 @@ module "runner" { | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| +| cache\_bucket\_name\_include\_account\_id | Boolean to add current account ID to cache bucket name. | bool | `"true"` | no | | cache\_bucket\_prefix | Prefix for s3 cache bucket name. | string | `""` | no | | cache\_bucket\_versioning | Boolean used to enable versioning on the cache bucket, false by default. | string | `"false"` | no | | cache\_expiration\_days | Number of days before cache objects expires. | number | `"1"` | no | diff --git a/cache/_docs/TF_MODULE.md b/cache/_docs/TF_MODULE.md index 6801f41a1..421108a8a 100644 --- a/cache/_docs/TF_MODULE.md +++ b/cache/_docs/TF_MODULE.md @@ -2,6 +2,7 @@ | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| +| cache\_bucket\_name\_include\_account\_id | Boolean to add current account ID to cache bucket name. | bool | `"true"` | no | | cache\_bucket\_prefix | Prefix for s3 cache bucket name. | string | `""` | no | | cache\_bucket\_versioning | Boolean used to enable versioning on the cache bucket, false by default. | string | `"false"` | no | | cache\_expiration\_days | Number of days before cache objects expires. | number | `"1"` | no | @@ -16,3 +17,4 @@ | arn | The ARN of the created bucket. | | bucket | Name of the created bucket. | | policy\_arn | Policy for users of the cache (bucket). | + From 84d23c5661b50c3b23a80a225b6121c422dd44fb Mon Sep 17 00:00:00 2001 From: Niek Palm Date: Sun, 18 Aug 2019 12:27:58 +0200 Subject: [PATCH 2/5] Add release badge --- README.md | 2 +- _docs/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5a1d370cc..5ff32a888 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.com/npalm/terraform-aws-gitlab-runner.svg?branch=master)](https://travis-ci.com/npalm/terraform-aws-gitlab-runner) [![Gitter](https://badges.gitter.im/terraform-aws-gitlab-runner/Lobby.svg)](https://gitter.im/terraform-aws-gitlab-runner/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)[![GitHub release](https://img.shields.io/github/release/Naereen/StrapDown.js.svg)](https://GitHub.com/Naereen/StrapDown.js/releases/) +[![Build Status](https://travis-ci.com/npalm/terraform-aws-gitlab-runner.svg?branch=master)](https://travis-ci.com/npalm/terraform-aws-gitlab-runner) [![Gitter](https://badges.gitter.im/terraform-aws-gitlab-runner/Lobby.svg)](https://gitter.im/terraform-aws-gitlab-runner/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)[![GitHub release](https://img.shields.io/github/release/Naereen/StrapDown.js.svg)](https://github.com/npalm/terraform-aws-gitlab-runner/releases/) # Terraform module for GitLab auto scaling runners on AWS spot instances diff --git a/_docs/README.md b/_docs/README.md index 618543831..b251841c2 100644 --- a/_docs/README.md +++ b/_docs/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.com/npalm/terraform-aws-gitlab-runner.svg?branch=master)](https://travis-ci.com/npalm/terraform-aws-gitlab-runner) [![Gitter](https://badges.gitter.im/terraform-aws-gitlab-runner/Lobby.svg)](https://gitter.im/terraform-aws-gitlab-runner/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)[![GitHub release](https://img.shields.io/github/release/Naereen/StrapDown.js.svg)](https://GitHub.com/Naereen/StrapDown.js/releases/) +[![Build Status](https://travis-ci.com/npalm/terraform-aws-gitlab-runner.svg?branch=master)](https://travis-ci.com/npalm/terraform-aws-gitlab-runner) [![Gitter](https://badges.gitter.im/terraform-aws-gitlab-runner/Lobby.svg)](https://gitter.im/terraform-aws-gitlab-runner/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)[![GitHub release](https://img.shields.io/github/release/Naereen/StrapDown.js.svg)](https://github.com/npalm/terraform-aws-gitlab-runner/releases/) # Terraform module for GitLab auto scaling runners on AWS spot instances From 52ca88f89f0bb5461930c9b5cabe45cc6e0fbd8f Mon Sep 17 00:00:00 2001 From: Niek Palm Date: Sun, 18 Aug 2019 12:29:49 +0200 Subject: [PATCH 3/5] Remove release badge --- README.md | 2 +- _docs/README.md | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5ff32a888..41a452226 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.com/npalm/terraform-aws-gitlab-runner.svg?branch=master)](https://travis-ci.com/npalm/terraform-aws-gitlab-runner) [![Gitter](https://badges.gitter.im/terraform-aws-gitlab-runner/Lobby.svg)](https://gitter.im/terraform-aws-gitlab-runner/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)[![GitHub release](https://img.shields.io/github/release/Naereen/StrapDown.js.svg)](https://github.com/npalm/terraform-aws-gitlab-runner/releases/) +[![Build Status](https://travis-ci.com/npalm/terraform-aws-gitlab-runner.svg?branch=master)](https://travis-ci.com/npalm/terraform-aws-gitlab-runner) [![Gitter](https://badges.gitter.im/terraform-aws-gitlab-runner/Lobby.svg)](https://gitter.im/terraform-aws-gitlab-runner/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) # Terraform module for GitLab auto scaling runners on AWS spot instances diff --git a/_docs/README.md b/_docs/README.md index b251841c2..3163b7d16 100644 --- a/_docs/README.md +++ b/_docs/README.md @@ -1,5 +1,4 @@ -[![Build Status](https://travis-ci.com/npalm/terraform-aws-gitlab-runner.svg?branch=master)](https://travis-ci.com/npalm/terraform-aws-gitlab-runner) [![Gitter](https://badges.gitter.im/terraform-aws-gitlab-runner/Lobby.svg)](https://gitter.im/terraform-aws-gitlab-runner/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)[![GitHub release](https://img.shields.io/github/release/Naereen/StrapDown.js.svg)](https://github.com/npalm/terraform-aws-gitlab-runner/releases/) - +[![Build Status](https://travis-ci.com/npalm/terraform-aws-gitlab-runner.svg?branch=master)](https://travis-ci.com/npalm/terraform-aws-gitlab-runner) [![Gitter](https://badges.gitter.im/terraform-aws-gitlab-runner/Lobby.svg)](https://gitter.im/terraform-aws-gitlab-runner/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) # Terraform module for GitLab auto scaling runners on AWS spot instances From 0ff8eabe8706540fb2c7fb564a77a07aaf79a615 Mon Sep 17 00:00:00 2001 From: Gertjan Maas Date: Mon, 19 Aug 2019 15:46:13 +0200 Subject: [PATCH 4/5] Add MaxBuilds variable to gitlab runner config (#122) * Add MaxBuilds variable to gitlab runner config * Update variables.tf Co-Authored-By: Niek Palm * Update docs --- README.md | 1 + _docs/TF_MODULE.md | 1 + locals.tf | 3 +++ main.tf | 1 + template/runner-config.tpl | 1 + variables.tf | 6 ++++++ 6 files changed, 13 insertions(+) diff --git a/README.md b/README.md index 41a452226..99b03fcd0 100644 --- a/README.md +++ b/README.md @@ -258,6 +258,7 @@ terraform destroy | runners\_idle\_time | Idle time of the runners, will be used in the runner config.toml. | number | `"600"` | no | | runners\_image | Image to run builds, will be used in the runner config.toml | string | `"docker:18.03.1-ce"` | no | | runners\_limit | Limit for the runners, will be used in the runner config.toml. | number | `"0"` | no | +| runners\_max\_builds | Max builds for each runner after which it will be removed, will be used in the runner config.toml. By default set to 0, no maxBuilds will be set in the configuration. | number | `"0"` | no | | runners\_monitoring | Enable detailed cloudwatch monitoring for spot instances. | bool | `"false"` | no | | runners\_name | Name of the runner, will be used in the runner config.toml. | string | n/a | yes | | runners\_off\_peak\_idle\_count | Off peak idle count of the runners, will be used in the runner config.toml. | number | `"0"` | no | diff --git a/_docs/TF_MODULE.md b/_docs/TF_MODULE.md index 23e817a77..f8a0e8e9e 100644 --- a/_docs/TF_MODULE.md +++ b/_docs/TF_MODULE.md @@ -45,6 +45,7 @@ | runners\_idle\_time | Idle time of the runners, will be used in the runner config.toml. | number | `"600"` | no | | runners\_image | Image to run builds, will be used in the runner config.toml | string | `"docker:18.03.1-ce"` | no | | runners\_limit | Limit for the runners, will be used in the runner config.toml. | number | `"0"` | no | +| runners\_max\_builds | Max builds for each runner after which it will be removed, will be used in the runner config.toml. By default set to 0, no maxBuilds will be set in the configuration. | number | `"0"` | no | | runners\_monitoring | Enable detailed cloudwatch monitoring for spot instances. | bool | `"false"` | no | | runners\_name | Name of the runner, will be used in the runner config.toml. | string | n/a | yes | | runners\_off\_peak\_idle\_count | Off peak idle count of the runners, will be used in the runner config.toml. | number | `"0"` | no | diff --git a/locals.tf b/locals.tf index cc88eb7a4..6aef47f5f 100644 --- a/locals.tf +++ b/locals.tf @@ -8,6 +8,9 @@ locals { // Ensure off peak is optional runners_off_peak_periods_string = var.runners_off_peak_periods == "" ? "" : format("OffPeakPeriods = %s", var.runners_off_peak_periods) + // Ensure max builds is optional + runners_max_builds_string = var.runners_max_builds == 0 ? "" : format("MaxBuilds = %d", var.runners_max_builds) + // Define key for runner token for SSM secure_parameter_store_runner_token_key = "${var.environment}-${var.secure_parameter_store_runner_token_key}" diff --git a/main.tf b/main.tf index a9421a057..8b8999cbf 100644 --- a/main.tf +++ b/main.tf @@ -168,6 +168,7 @@ data "template_file" "runners" { runners_pull_policy = var.runners_pull_policy runners_idle_count = var.runners_idle_count runners_idle_time = var.runners_idle_time + runners_max_builds = local.runners_max_builds_string runners_off_peak_timezone = var.runners_off_peak_timezone runners_off_peak_idle_count = var.runners_off_peak_idle_count runners_off_peak_idle_time = var.runners_off_peak_idle_time diff --git a/template/runner-config.tpl b/template/runner-config.tpl index 8d6af5813..774f1a63b 100644 --- a/template/runner-config.tpl +++ b/template/runner-config.tpl @@ -32,6 +32,7 @@ check_interval = 0 [runners.machine] IdleCount = ${runners_idle_count} IdleTime = ${runners_idle_time} + ${runners_max_builds} MachineDriver = "amazonec2" MachineName = "runner-%s" MachineOptions = [ diff --git a/variables.tf b/variables.tf index 02c3c6300..987f99cc1 100644 --- a/variables.tf +++ b/variables.tf @@ -117,6 +117,12 @@ variable "runners_idle_count" { default = 0 } +variable "runners_max_builds" { + description = "Max builds for each runner after which it will be removed, will be used in the runner config.toml. By default set to 0, no maxBuilds will be set in the configuration." + type = number + default = 0 +} + variable "runners_image" { description = "Image to run builds, will be used in the runner config.toml" type = string From d3fa369a4d2c9cf0e1980b9f0d82cb09da7ee07e Mon Sep 17 00:00:00 2001 From: Niek Palm Date: Mon, 19 Aug 2019 23:00:02 +0200 Subject: [PATCH 5/5] Release 4.3.0 --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd31eb071..67bcbb0c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## 4.3.0 - 2019-08-19 + +- Added + - Add MaxBuilds variable to gitlab runner config #122 @gertjanmaas + ## 4.2.0 - 2019-08-18 - Added @@ -210,7 +215,8 @@ Module is available as Terraform 0.11 module, pin module to version 3.x. Please - Update default AMI's to The latest Amazon Linux AMI 2017.09.1 - released on 2018-01-17. - Minor updates in the example -[Unreleased]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/4.2.0...HEAD +[Unreleased]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/4.3.0...HEAD +[4.3.0]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/4.2.0...4.3.0 [4.2.0]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/4.1.0...4.2.0 [4.1.0]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/4.0.0...4.1.0 [4.0.0]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/3.10.0...4.0.0