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 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 | 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 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"