From 0340c083f5c5688b53fea6a69ad36c9a9acb7e3f Mon Sep 17 00:00:00 2001 From: Niek Palm Date: Mon, 22 Jul 2019 22:27:19 +0200 Subject: [PATCH] Feature/terraform 0.12 sync develop (#103) Sync develop branch to tf 0.12 branch * Fix misleading variable description (#86) * changed the description for the variable `enable_manage_gitlab_token`, since the second part of the description was misleading * rewritten the description of the variable `enable_manage_gitlab_token` based on feedback from PR * update changelog * ci script update (#90) * ci/bin/autodocs.sh: exit if dependencies are not installed (pandoc or terraform-docs) * ci/bin/verify-examples: make check for examples working and not print some obscure error messages * Adding docker pull policy Parameter (#89) * adding pull policy parameter * update documentation from master * runautodocs * regenerate README * adding paramter to allow specify docker-machine ami this allows us to also use the latest ubuntu 18.04 for the docker-machine instances * adding paramter to allow specify docker-machine ami (#88) this allows us to also use the latest ubuntu 18.04 for the docker-machine instances * Update docs * Release 3.6.0 * fix: availability zone in AWS region (#93) * fix: availability zone in AWS region * fix: use data source to determine az * fix: use a variable to determine timezone (#94) * fix: use a variable to determine timezone * fix: update documentation * Fix broken public example * Move cache to moudle (#96) FIx #91 * Release 3.7.0 * Add variable docker_machine_role_json allowing role policy customization (#100) * Add variable docker_machine_role_json allowing role policy customization * Update docs * Add variable docker_machine_ssh_cidr_blocks allowing ssh ingress restriction (#101) * Update names for docker machine security-rules (#102) * Fix merge mistake * Fix merge mistake --- CHANGELOG.md | 23 ++++++++++++++++++++++- README.md | 12 +++++++----- _docs/TF_MODULE.md | 12 +++++++----- ci/bin/autodocs.sh | 1 - examples/runner-default/README.md | 2 +- examples/runner-default/_docs/README.md | 4 ++-- examples/runner-public/_docs/README.md | 2 +- examples/runner-public/main.tf | 2 +- main.tf | 1 - migrations/migration-state-3.7.x.sh | 7 +++++++ variables.tf | 1 - 11 files changed, 48 insertions(+), 19 deletions(-) create mode 100755 migrations/migration-state-3.7.x.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index ca433168e..70a039f59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,24 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## 3.7.0 - 2019-07-17 +- Changed + - Creation of multiple instances of the runner is now supported. Cache is therefor moved to an internal module. Pleas see the example `runner-public` for a concrete sample. The change should have no effect if you apply the state migration script `migragations/migration-state-3.7.x.sh`. + - Examples are more generic by removing the time zone and AZ zone to variables. @@theBenForce + +## 3.6.0 - 2019-07-04 +- Changed + - Add option to specify pull policy for docker images by the runner. @roock + - Docker machine AMI image will be by default latest ubuntu 16.06, can be overwritten via variables @roock + - Improved CI docs generation script @roock + +## 3.5.0 - 2019-06-19 +- Changed + - Documentation #85: Misleading Variable-Description @solutionDrive-Alt + - Bugfix #70: docker-machine fails starting runners when `amazonec2-request-spot-instance=false` @philippefuentes + - Bugfix #72: Detect and retry when docker machine installation fails @eliasdorneles + - Changed: Default version of GitLab runner set to 11.11.2 + ## [3.4.0] - 2019-06-06 - Changed: - Update default runner type, GitLab runner version, and versions in examples. @@ -126,7 +144,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - 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/3.4.0...HEAD +[Unreleased]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/3.7.0...HEAD +[3.7.0]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/3.6.0...3.7.0 +[3.6.0]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/3.5.0...3.6.0 +[3.5.0]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/3.4.0...3.5.0 [3.4.0]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/3.3.0...3.4.0 [3.3.0]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/3.2.0...3.3.0 [3.2.0]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/3.1.0...3.2.0 diff --git a/README.md b/README.md index bd9502b84..1ae89e634 100644 --- a/README.md +++ b/README.md @@ -231,8 +231,8 @@ terraform destroy | runner\_ami\_filter | List of maps used to create the AMI filter for the Gitlab runner docker-machine AMI. | map(list(string)) | `` | no | | runner\_ami\_owners | The list of owners used to select the AMI of Gitlab runner docker-machine instances. | list(string) | `` | no | | runner\_instance\_spot\_price | By setting a spot price bid price the runner agent will be created via a spot request. Be aware that spot instances can be stopped by AWS. | string | `""` | no | +| runners\_additional\_volumes | Additional volumes that will be used in the runner config.toml, e.g Docker socket | list | `` | no | | runners\_concurrent | Concurrent value for the runners, will be used in the runner config.toml. | string | `"10"` | no | -| runners\_docker\_socket | Location of Docker socket on host if socket mount if enabled, will be used in the runner config.toml | string | `"/var/run/docker.sock:/var/run/docker.sock"` | no | | runners\_environment\_vars | Environment variables during build execution, e.g. KEY=Value, see runner-public example. Will be used in the runner config.toml | list(string) | `` | no | | runners\_executor | The executor to use. Currently supports `docker+machine` or `docker`. | string | `"docker+machine"` | no | | runners\_gitlab\_url | URL of the GitLab instance to connect to. | string | n/a | yes | @@ -242,7 +242,6 @@ terraform destroy | 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. | string | `"0"` | no | | runners\_monitoring | Enable detailed cloudwatch monitoring for spot instances. | string | `"false"` | no | -| runners\_mount\_docker\_socket | Runners will mount volume with Docker socket, will be used in the runner config.toml | string | `"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. | string | `"0"` | no | | runners\_off\_peak\_idle\_time | Off peak idle time of the runners, will be used in the runner config.toml. | string | `"0"` | no | @@ -261,7 +260,7 @@ terraform destroy | runners\_use\_private\_address | Restrict runners to the use of a private IP address | string | `"true"` | no | | secure\_parameter\_store\_runner\_token\_key | The key name used store the Gitlab runner token in Secure Parameter Store | string | `"runner-token"` | no | | ssh\_key\_pair | Set this to use existing AWS key pair | string | `""` | no | -| ssh\_public\_key | Public SSH key used for the GitLab runner EC2 instance. | string | n/a | yes | +| ssh\_public\_key | Public SSH key used for the GitLab runner EC2 instance. | string | `""` | no | | subnet\_id\_runners | List of subnets used for hosting the gitlab-runners. | string | n/a | yes | | subnet\_ids\_gitlab\_runner | Subnet used for hosting the GitLab runner. | list(string) | n/a | yes | | tags | Map of tags that will be added to created resources. By default resources will be tagged with name and environment. | map(string) | `` | no | @@ -273,7 +272,10 @@ terraform destroy | Name | Description | |------|-------------| -| runner\_agent\_role | ARN of the role used for the ec2 instance for the GitLab runner agent. | +| runner\_agent\_role\_arn | ARN of the role used for the ec2 instance for the GitLab runner agent. | +| runner\_agent\_role\_name | Name of the role used for the ec2 instance for the GitLab runner agent. | | runner\_as\_group\_name | Name of the autoscaling group for the gitlab-runner instance | | runner\_cache\_bucket\_arn | ARN of the S3 for the build cache. | -| runner\_role | ARN of the role used for the docker machine runners. | +| 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/_docs/TF_MODULE.md b/_docs/TF_MODULE.md index afc72ca51..d5586fb01 100644 --- a/_docs/TF_MODULE.md +++ b/_docs/TF_MODULE.md @@ -34,8 +34,8 @@ | runner\_ami\_filter | List of maps used to create the AMI filter for the Gitlab runner docker-machine AMI. | map(list(string)) | `` | no | | runner\_ami\_owners | The list of owners used to select the AMI of Gitlab runner docker-machine instances. | list(string) | `` | no | | runner\_instance\_spot\_price | By setting a spot price bid price the runner agent will be created via a spot request. Be aware that spot instances can be stopped by AWS. | string | `""` | no | +| runners\_additional\_volumes | Additional volumes that will be used in the runner config.toml, e.g Docker socket | list | `` | no | | runners\_concurrent | Concurrent value for the runners, will be used in the runner config.toml. | string | `"10"` | no | -| runners\_docker\_socket | Location of Docker socket on host if socket mount if enabled, will be used in the runner config.toml | string | `"/var/run/docker.sock:/var/run/docker.sock"` | no | | runners\_environment\_vars | Environment variables during build execution, e.g. KEY=Value, see runner-public example. Will be used in the runner config.toml | list(string) | `` | no | | runners\_executor | The executor to use. Currently supports `docker+machine` or `docker`. | string | `"docker+machine"` | no | | runners\_gitlab\_url | URL of the GitLab instance to connect to. | string | n/a | yes | @@ -45,7 +45,6 @@ | 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. | string | `"0"` | no | | runners\_monitoring | Enable detailed cloudwatch monitoring for spot instances. | string | `"false"` | no | -| runners\_mount\_docker\_socket | Runners will mount volume with Docker socket, will be used in the runner config.toml | string | `"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. | string | `"0"` | no | | runners\_off\_peak\_idle\_time | Off peak idle time of the runners, will be used in the runner config.toml. | string | `"0"` | no | @@ -64,7 +63,7 @@ | runners\_use\_private\_address | Restrict runners to the use of a private IP address | string | `"true"` | no | | secure\_parameter\_store\_runner\_token\_key | The key name used store the Gitlab runner token in Secure Parameter Store | string | `"runner-token"` | no | | ssh\_key\_pair | Set this to use existing AWS key pair | string | `""` | no | -| ssh\_public\_key | Public SSH key used for the GitLab runner EC2 instance. | string | n/a | yes | +| ssh\_public\_key | Public SSH key used for the GitLab runner EC2 instance. | string | `""` | no | | subnet\_id\_runners | List of subnets used for hosting the gitlab-runners. | string | n/a | yes | | subnet\_ids\_gitlab\_runner | Subnet used for hosting the GitLab runner. | list(string) | n/a | yes | | tags | Map of tags that will be added to created resources. By default resources will be tagged with name and environment. | map(string) | `` | no | @@ -76,8 +75,11 @@ | Name | Description | |------|-------------| -| runner\_agent\_role | ARN of the role used for the ec2 instance for the GitLab runner agent. | +| runner\_agent\_role\_arn | ARN of the role used for the ec2 instance for the GitLab runner agent. | +| runner\_agent\_role\_name | Name of the role used for the ec2 instance for the GitLab runner agent. | | runner\_as\_group\_name | Name of the autoscaling group for the gitlab-runner instance | | runner\_cache\_bucket\_arn | ARN of the S3 for the build cache. | -| runner\_role | ARN of the role used for the docker machine runners. | +| 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/ci/bin/autodocs.sh b/ci/bin/autodocs.sh index 243211a3c..31995d4e0 100755 --- a/ci/bin/autodocs.sh +++ b/ci/bin/autodocs.sh @@ -5,7 +5,6 @@ pandoc -v &> /dev/null || { echo >&2 "ERROR: Pandoc not installed" ; exit 1 ; } terraform-docs --version &> /dev/null || { echo >&2 "ERROR: terraform-docs not installed" ; exit 1 ; } - IFS=$'\n' # create an array of all unique directories containing .tf files arr=($(find . -name '*.tf' | xargs -I % sh -c 'dirname %' | sort -u)) diff --git a/examples/runner-default/README.md b/examples/runner-default/README.md index c59c8ff3b..09c64fed5 100644 --- a/examples/runner-default/README.md +++ b/examples/runner-default/README.md @@ -12,7 +12,7 @@ This examples shows: - Registration via GitLab token. - Auto scaling using `docker+machine` executor. -## Prerequisite +![runners-default](https://github.com/npalm/assets/raw/master/images/terraform-aws-gitlab-runner/runner-default.png) The Terraform version is managed using [tfenv](https://github.com/Zordrak/tfenv). If you are not using `tfenv` please check `.terraform-version` for the tested version. diff --git a/examples/runner-default/_docs/README.md b/examples/runner-default/_docs/README.md index b59f61c54..3a62425a1 100644 --- a/examples/runner-default/_docs/README.md +++ b/examples/runner-default/_docs/README.md @@ -12,7 +12,7 @@ This examples shows: - Auto scaling using `docker+machine` executor. -## Prerequisite +![runners-default](https://github.com/npalm/assets/raw/master/images/terraform-aws-gitlab-runner/runner-default.png) The Terraform version is managed using [tfenv](https://github.com/Zordrak/tfenv). If you are not using `tfenv` please check `.terraform-version` for the tested version. @@ -27,4 +27,4 @@ This examples shows: - Usages of public / private subnets. - Usages of runner of peak time mode configuration. - Registration via GitLab token. -- Auto scaling using `docker+machine` executor. \ No newline at end of file +- Auto scaling using `docker+machine` executor. diff --git a/examples/runner-public/_docs/README.md b/examples/runner-public/_docs/README.md index a23d4c7fb..548d29b7d 100644 --- a/examples/runner-public/_docs/README.md +++ b/examples/runner-public/_docs/README.md @@ -14,4 +14,4 @@ This examples shows: ## Prerequisite -The Terraform version is managed using [tfenv](https://github.com/Zordrak/tfenv). If you are not using `tfenv` please check `.terraform-version` for the tested version. \ No newline at end of file +The Terraform version is managed using [tfenv](https://github.com/Zordrak/tfenv). If you are not using `tfenv` please check `.terraform-version` for the tested version. diff --git a/examples/runner-public/main.tf b/examples/runner-public/main.tf index 49fdf4344..b7e082a1f 100644 --- a/examples/runner-public/main.tf +++ b/examples/runner-public/main.tf @@ -43,7 +43,7 @@ module "runner" { runners_gitlab_url = var.gitlab_url runners_environment_vars = ["KEY=Value", "FOO=bar"] - runners_privileged = "false" + runners_privileged = "false" runners_additional_volumes = ["/var/run/docker.sock:/var/run/docker.sock"] gitlab_runner_registration_config = { diff --git a/main.tf b/main.tf index 187f2e3e3..0794ab4da 100644 --- a/main.tf +++ b/main.tf @@ -252,7 +252,6 @@ resource "aws_launch_configuration" "gitlab_runner_instance" { } } - ################################################################################ ### Create cache bucket ################################################################################ diff --git a/migrations/migration-state-3.7.x.sh b/migrations/migration-state-3.7.x.sh new file mode 100755 index 000000000..f3024196f --- /dev/null +++ b/migrations/migration-state-3.7.x.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +echo --- +echo --- Migration state for updates in Release 3.7.0 +echo --- +terraform state mv module.runner.aws_s3_bucket.build_cache module.runner.module.cache.aws_s3_bucket.build_cache +terraform state mv module.runner.aws_iam_policy.docker_machine_cache module.runner.module.cache.aws_iam_policy.docker_machine_cache diff --git a/variables.tf b/variables.tf index cea808a52..a0cb8686d 100644 --- a/variables.tf +++ b/variables.tf @@ -351,7 +351,6 @@ variable "runner_ami_owners" { default = ["099720109477"] } - variable "gitlab_runner_registration_config" { description = "Configuration used to register the runner. See the README for an example, or reference the examples in the examples directory of this repo." type = map(string)