From dfa571dc83d5cca14b3ca3b50c4cc88ba4ddc81d Mon Sep 17 00:00:00 2001 From: Roman Pertl <533172+roock@users.noreply.github.com> Date: Tue, 2 Jul 2019 21:58:36 +0200 Subject: [PATCH 1/5] 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 --- ci/bin/autodocs.sh | 6 +++--- ci/bin/verify-examples.sh | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ci/bin/autodocs.sh b/ci/bin/autodocs.sh index e1a6727fc..413c730b5 100755 --- a/ci/bin/autodocs.sh +++ b/ci/bin/autodocs.sh @@ -2,8 +2,8 @@ # script to auto-generate terraform documentation -pandoc -v &> /dev/null || echo "ERROR: Pandoc not installed" -terraform-docs --version &> /dev/null || echo "ERROR: terraform-docs not installed" +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 @@ -39,4 +39,4 @@ do elif [[ ! -d "$docs_dir" && $i != *".terraform"* ]]; then terraform-docs markdown table $i > README.md fi -done \ No newline at end of file +done diff --git a/ci/bin/verify-examples.sh b/ci/bin/verify-examples.sh index 650f92eef..afb1eeda0 100755 --- a/ci/bin/verify-examples.sh +++ b/ci/bin/verify-examples.sh @@ -4,7 +4,8 @@ DIR=${1:-examples} source $(dirname $0)/terraform.sh EXAMPLES="$(find ${DIR} -maxdepth 1 -mindepth 1 -type d 2> /dev/null )" -if [[ -z $EXAMPLES || "$($(echo $EXAMPLES) | wc -l)" -gt 0 ]] ; then +echo $EXAMPLES +if [[ -z $EXAMPLES || $( echo $EXAMPLES | wc -l ) -eq 0 ]] ; then echo "No example(s) directories found." exit 1 fi From 7a895995fb7dec9b668abdab2893e29506e98fda Mon Sep 17 00:00:00 2001 From: Roman Pertl <533172+roock@users.noreply.github.com> Date: Thu, 4 Jul 2019 09:07:04 +0200 Subject: [PATCH 2/5] adding paramter to allow specify docker-machine ami this allows us to also use the latest ubuntu 18.04 for the docker-machine instances --- main.tf | 9 +++++++++ template/runner-config.tpl | 3 ++- variables.tf | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/main.tf b/main.tf index 402aaf5de..363baa6df 100644 --- a/main.tf +++ b/main.tf @@ -147,6 +147,7 @@ data "template_file" "runners" { runners_subnet_id = "${var.subnet_id_runners}" runners_aws_zone = "${var.aws_zone}" runners_instance_type = "${var.docker_machine_instance_type}" + runners_ami = "${data.aws_ami.docker-machine.id}" runners_spot_price_bid = "${var.docker_machine_spot_price_bid}" runners_security_group_name = "${aws_security_group.docker_machine.name}" runners_monitoring = "${var.runners_monitoring}" @@ -199,6 +200,14 @@ resource "aws_autoscaling_group" "gitlab_runner_instance" { ] } +data "aws_ami" "docker-machine" { + most_recent = true + + filter = "${var.runner_ami_filter}" + + owners = ["${var.runner_ami_owners}"] +} + data "aws_ami" "runner" { most_recent = "true" diff --git a/template/runner-config.tpl b/template/runner-config.tpl index 96a79e5f4..19acb4941 100644 --- a/template/runner-config.tpl +++ b/template/runner-config.tpl @@ -47,7 +47,8 @@ check_interval = 0 "amazonec2-tags=${runners_tags}", "amazonec2-monitoring=${runners_monitoring}", "amazonec2-iam-instance-profile=${runners_instance_profile}", - "amazonec2-root-size=${runners_root_size}" + "amazonec2-root-size=${runners_root_size}", + "amazonec2-ami=${runners_ami}" ${docker_machine_options} ] OffPeakTimezone = "${runners_off_peak_timezone}" diff --git a/variables.tf b/variables.tf index 9518e4485..00b89b5c9 100644 --- a/variables.tf +++ b/variables.tf @@ -315,6 +315,24 @@ variable "ami_owners" { default = ["amazon"] } +variable "runner_ami_filter" { + description = "List of maps used to create the AMI filter for the Gitlab runner docker-machine AMI." + type = "list" + + default = [{ + name = "name" + values = ["ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*"] + }] +} + +variable "runner_ami_owners" { + description = "The list of owners used to select the AMI of Gitlab runner docker-machine instances." + type = "list" + + # Canonical + 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" From 60bde8ceb10294233ea6d124a9763fcd5c260b83 Mon Sep 17 00:00:00 2001 From: Roman Pertl <533172+roock@users.noreply.github.com> Date: Thu, 4 Jul 2019 21:58:11 +0200 Subject: [PATCH 3/5] 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 --- main.tf | 9 +++++++++ template/runner-config.tpl | 3 ++- variables.tf | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/main.tf b/main.tf index 402aaf5de..363baa6df 100644 --- a/main.tf +++ b/main.tf @@ -147,6 +147,7 @@ data "template_file" "runners" { runners_subnet_id = "${var.subnet_id_runners}" runners_aws_zone = "${var.aws_zone}" runners_instance_type = "${var.docker_machine_instance_type}" + runners_ami = "${data.aws_ami.docker-machine.id}" runners_spot_price_bid = "${var.docker_machine_spot_price_bid}" runners_security_group_name = "${aws_security_group.docker_machine.name}" runners_monitoring = "${var.runners_monitoring}" @@ -199,6 +200,14 @@ resource "aws_autoscaling_group" "gitlab_runner_instance" { ] } +data "aws_ami" "docker-machine" { + most_recent = true + + filter = "${var.runner_ami_filter}" + + owners = ["${var.runner_ami_owners}"] +} + data "aws_ami" "runner" { most_recent = "true" diff --git a/template/runner-config.tpl b/template/runner-config.tpl index 96a79e5f4..19acb4941 100644 --- a/template/runner-config.tpl +++ b/template/runner-config.tpl @@ -47,7 +47,8 @@ check_interval = 0 "amazonec2-tags=${runners_tags}", "amazonec2-monitoring=${runners_monitoring}", "amazonec2-iam-instance-profile=${runners_instance_profile}", - "amazonec2-root-size=${runners_root_size}" + "amazonec2-root-size=${runners_root_size}", + "amazonec2-ami=${runners_ami}" ${docker_machine_options} ] OffPeakTimezone = "${runners_off_peak_timezone}" diff --git a/variables.tf b/variables.tf index 9518e4485..00b89b5c9 100644 --- a/variables.tf +++ b/variables.tf @@ -315,6 +315,24 @@ variable "ami_owners" { default = ["amazon"] } +variable "runner_ami_filter" { + description = "List of maps used to create the AMI filter for the Gitlab runner docker-machine AMI." + type = "list" + + default = [{ + name = "name" + values = ["ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*"] + }] +} + +variable "runner_ami_owners" { + description = "The list of owners used to select the AMI of Gitlab runner docker-machine instances." + type = "list" + + # Canonical + 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" From 136bc9e5f41b0c5745cf0ead93bee6749c243131 Mon Sep 17 00:00:00 2001 From: Niek Palm Date: Thu, 4 Jul 2019 22:07:40 +0200 Subject: [PATCH 4/5] Update docs --- README.md | 2 ++ _docs/TF_MODULE.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index 7936b102c..0dd4d3b5d 100644 --- a/README.md +++ b/README.md @@ -210,6 +210,8 @@ terraform destroy | instance\_type | Instance type used for the GitLab runner. | string | `"t3.micro"` | no | | name\_runners\_docker\_machine | | string | `""` | no | | overrides | This maps provides the possibility to override some defaults. The following attributes are supported: `name_sg` overwrite the `Name` tag for all security groups created by this module. `name_runner_agent_instance` override the `Name` tag for the ec2 instance defined in the auto launch configuration. `name_docker_machine_runners` ovverrid the `Name` tag spot instances created by the runner agent. | map | `` | no | +| runner\_ami\_filter | List of maps used to create the AMI filter for the Gitlab runner docker-machine AMI. | list | `` | no | +| runner\_ami\_owners | The list of owners used to select the AMI of Gitlab runner docker-machine instances. | list | `` | 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\_concurrent | Concurrent value for the runners, will be used in the runner config.toml. | string | `"10"` | 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 | `` | no | diff --git a/_docs/TF_MODULE.md b/_docs/TF_MODULE.md index bf930ed22..f92f23b22 100644 --- a/_docs/TF_MODULE.md +++ b/_docs/TF_MODULE.md @@ -29,6 +29,8 @@ | instance\_type | Instance type used for the GitLab runner. | string | `"t3.micro"` | no | | name\_runners\_docker\_machine | | string | `""` | no | | overrides | This maps provides the possibility to override some defaults. The following attributes are supported: `name_sg` overwrite the `Name` tag for all security groups created by this module. `name_runner_agent_instance` override the `Name` tag for the ec2 instance defined in the auto launch configuration. `name_docker_machine_runners` ovverrid the `Name` tag spot instances created by the runner agent. | map | `` | no | +| runner\_ami\_filter | List of maps used to create the AMI filter for the Gitlab runner docker-machine AMI. | list | `` | no | +| runner\_ami\_owners | The list of owners used to select the AMI of Gitlab runner docker-machine instances. | list | `` | 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\_concurrent | Concurrent value for the runners, will be used in the runner config.toml. | string | `"10"` | 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 | `` | no | From 91be174bf57127557f526f656bb676d40e73dbcc Mon Sep 17 00:00:00 2001 From: Niek Palm Date: Thu, 4 Jul 2019 22:12:27 +0200 Subject: [PATCH 5/5] Release 3.6.0 --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d15e77446..3265c2be4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## 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 + - 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