From 6397ba51703d26820e8d815ab28995a199c9970b Mon Sep 17 00:00:00 2001 From: Florent Blaison Date: Mon, 20 May 2019 18:08:42 +0200 Subject: [PATCH 1/8] Update variables.tf --- variables.tf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/variables.tf b/variables.tf index 648e20538..cdeb6d174 100644 --- a/variables.tf +++ b/variables.tf @@ -334,7 +334,8 @@ variable "name_runners_docker_machine" { variable "overrides" { description = "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." - + type = "map" + default = { name_sg = "" name_runner_agent_instance = "" From 2f45f1d73ba0cffd310a859cf30f08e88b8a1b03 Mon Sep 17 00:00:00 2001 From: Philou Date: Sat, 25 May 2019 23:08:56 +0200 Subject: [PATCH 2/8] add count to prevent from creating the resource (#69) when enable_manage_gitlab_token is false the policy "ssm" does not exist --- main.tf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.tf b/main.tf index 398cadccd..2f997438e 100644 --- a/main.tf +++ b/main.tf @@ -192,8 +192,8 @@ resource "aws_autoscaling_group" "gitlab_runner_instance" { launch_configuration = "${aws_launch_configuration.gitlab_runner_instance.name}" tags = [ - "${concat( - data.null_data_source.tags.*.outputs, + "${concat( + data.null_data_source.tags.*.outputs, list(map("key", "Name", "value", local.name_runner_instance, "propagate_at_launch", true)))}", ] } @@ -346,6 +346,8 @@ resource "aws_iam_policy" "ssm" { } resource "aws_iam_role_policy_attachment" "ssm" { + count = "${var.enable_manage_gitlab_token ? 1 : 0}" + role = "${aws_iam_role.instance.name}" policy_arn = "${aws_iam_policy.ssm.arn}" } From c1b7806b024f10bfcc390b0fffb782657fa88a89 Mon Sep 17 00:00:00 2001 From: Philou Date: Sat, 25 May 2019 23:12:12 +0200 Subject: [PATCH 3/8] fix #70 update policy to get authorization to start runners (#71) when spot instances are not used. --- policies/instance-docker-machine-policy.json | 51 ++++++++++---------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/policies/instance-docker-machine-policy.json b/policies/instance-docker-machine-policy.json index 5034a7197..35e90ee61 100644 --- a/policies/instance-docker-machine-policy.json +++ b/policies/instance-docker-machine-policy.json @@ -1,26 +1,27 @@ { - "Version": "2012-10-17", - "Statement": [ - { - "Action": [ - "ec2:DescribeKeyPairs", - "ec2:TerminateInstances", - "ec2:StopInstances", - "ec2:StartInstances", - "ec2:RebootInstances", - "ec2:CreateKeyPair", - "ec2:DeleteKeyPair", - "ec2:ImportKeyPair", - "ec2:Describe*", - "ec2:CreateTags", - "ec2:RequestSpotInstances", - "ec2:CancelSpotInstanceRequests", - "ec2:DescribeSubnets", - "ec2:AssociateIamInstanceProfile", - "iam:PassRole" - ], - "Effect": "Allow", - "Resource": "*" - } - ] -} + "Version": "2012-10-17", + "Statement": [ + { + "Action": [ + "ec2:DescribeKeyPairs", + "ec2:TerminateInstances", + "ec2:StopInstances", + "ec2:StartInstances", + "ec2:RunInstances", + "ec2:RebootInstances", + "ec2:CreateKeyPair", + "ec2:DeleteKeyPair", + "ec2:ImportKeyPair", + "ec2:Describe*", + "ec2:CreateTags", + "ec2:RequestSpotInstances", + "ec2:CancelSpotInstanceRequests", + "ec2:DescribeSubnets", + "ec2:AssociateIamInstanceProfile", + "iam:PassRole" + ], + "Effect": "Allow", + "Resource": "*" + } + ] + } From 9213aa655bc52c2d3cce69971990d912a5e781b5 Mon Sep 17 00:00:00 2001 From: Niek Palm Date: Sat, 25 May 2019 23:20:45 +0200 Subject: [PATCH 4/8] Fix formatting --- variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variables.tf b/variables.tf index cdeb6d174..724098a5a 100644 --- a/variables.tf +++ b/variables.tf @@ -335,7 +335,7 @@ variable "name_runners_docker_machine" { variable "overrides" { description = "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." type = "map" - + default = { name_sg = "" name_runner_agent_instance = "" From 3f7740454fcea430036a9a5e85553844e26754c1 Mon Sep 17 00:00:00 2001 From: Elias Dorneles Date: Wed, 29 May 2019 17:41:17 +0200 Subject: [PATCH 5/8] add retries for docker machine download (#74) Fix #72 --- template/gitlab-runner.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/gitlab-runner.tpl b/template/gitlab-runner.tpl index 31b6d3039..23338e964 100644 --- a/template/gitlab-runner.tpl +++ b/template/gitlab-runner.tpl @@ -16,7 +16,7 @@ fi curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | bash yum install gitlab-runner-${gitlab_runner_version} -y -curl -L https://github.com/docker/machine/releases/download/v${docker_machine_version}/docker-machine-`uname -s`-`uname -m` >/tmp/docker-machine && \ +curl --fail --retry 6 -L https://github.com/docker/machine/releases/download/v${docker_machine_version}/docker-machine-`uname -s`-`uname -m` >/tmp/docker-machine && \ chmod +x /tmp/docker-machine && \ cp /tmp/docker-machine /usr/local/bin/docker-machine && \ ln -s /usr/local/bin/docker-machine /usr/bin/docker-machine From 8f82aea7f30e241cf0371288b8a02fb4b14215e8 Mon Sep 17 00:00:00 2001 From: Hidetake Iwata Date: Wed, 5 Jun 2019 04:38:53 +0900 Subject: [PATCH 6/8] Fix runner is not reachable when runners_use_private_address = false (#79) Fix #75 --- main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.tf b/main.tf index 2f997438e..acf60cdcf 100644 --- a/main.tf +++ b/main.tf @@ -215,7 +215,7 @@ resource "aws_launch_configuration" "gitlab_runner_instance" { spot_price = "${var.runner_instance_spot_price}" iam_instance_profile = "${aws_iam_instance_profile.instance.name}" - associate_public_ip_address = false + associate_public_ip_address = "${!var.runners_use_private_address}" lifecycle { create_before_destroy = true From 812d143705dbaa84a912c35f7edaf3dab10bc54e Mon Sep 17 00:00:00 2001 From: Niek Palm Date: Thu, 6 Jun 2019 01:03:52 +0200 Subject: [PATCH 7/8] Update default runner type, GitLab runner version, and versions in examples --- CHANGELOG.md | 9 +++++++++ examples/runner-default/.terraform-version | 2 +- examples/runner-default/main.tf | 4 +++- examples/runner-default/providers.tf | 10 +++++----- examples/runner-docker/main.tf | 2 +- examples/runner-docker/providers.tf | 10 +++++----- examples/runner-public/.terraform-version | 2 +- examples/runner-public/main.tf | 9 +++++---- examples/runner-public/providers.tf | 10 +++++----- variables.tf | 6 +++--- 10 files changed, 38 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cba5a99f1..20bdd1594 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +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/). +## Unrleases +- Changed: + - Update default runner type, GitLab runner version, and versions in examples. + - Buffix #75 runner is not reachable when runners_use_private_address = false + - Buffix - Missing typ - @Orkin + - Bugfix #72 - Detect and retry when docker machine download fails eliasdorneles + - Bugfix #68 - add count to prevent resource creation failing @philippefuentes + - Bugfix #70 - update policy to allow runners to start when not using spot instances @philippefuentes + ## [3.3.0] - 2019-05-20 - Changed: Default version of GitLab runner set to 11.10.1 - Added: Option to enable / disable SSH login diff --git a/examples/runner-default/.terraform-version b/examples/runner-default/.terraform-version index 44ab23e43..a95c45d4f 100644 --- a/examples/runner-default/.terraform-version +++ b/examples/runner-default/.terraform-version @@ -1 +1 @@ -0.11.13 +0.11.14 diff --git a/examples/runner-default/main.tf b/examples/runner-default/main.tf index 779e78bb0..e4f2e8f24 100644 --- a/examples/runner-default/main.tf +++ b/examples/runner-default/main.tf @@ -1,6 +1,6 @@ module "vpc" { source = "terraform-aws-modules/vpc/aws" - version = "1.60.0" + version = "1.66.0" name = "vpc-${var.environment}" cidr = "10.0.0.0/16" @@ -33,6 +33,8 @@ module "runner" { runners_name = "${var.runner_name}" runners_gitlab_url = "${var.gitlab_url}" + docker_machine_spot_price_bid = "0.06" + gitlab_runner_registration_config = { registration_token = "${var.registration_token}" tag_list = "docker_spot_runner" diff --git a/examples/runner-default/providers.tf b/examples/runner-default/providers.tf index 8f3bc2aed..02546632f 100644 --- a/examples/runner-default/providers.tf +++ b/examples/runner-default/providers.tf @@ -1,20 +1,20 @@ provider "aws" { region = "${var.aws_region}" - version = "2.4" + version = "2.13" } provider "template" { - version = "2.1" + version = "2.1.2" } provider "local" { - version = "1.2" + version = "1.2.2" } provider "null" { - version = "2.1" + version = "2.1.2" } provider "tls" { - version = "1.2" + version = "2.0.1" } diff --git a/examples/runner-docker/main.tf b/examples/runner-docker/main.tf index 6f1db551a..759e5de42 100644 --- a/examples/runner-docker/main.tf +++ b/examples/runner-docker/main.tf @@ -1,6 +1,6 @@ module "vpc" { source = "terraform-aws-modules/vpc/aws" - version = "1.59.0" + version = "1.66.0" name = "vpc-${var.environment}" cidr = "10.1.0.0/16" diff --git a/examples/runner-docker/providers.tf b/examples/runner-docker/providers.tf index 8f3bc2aed..02546632f 100644 --- a/examples/runner-docker/providers.tf +++ b/examples/runner-docker/providers.tf @@ -1,20 +1,20 @@ provider "aws" { region = "${var.aws_region}" - version = "2.4" + version = "2.13" } provider "template" { - version = "2.1" + version = "2.1.2" } provider "local" { - version = "1.2" + version = "1.2.2" } provider "null" { - version = "2.1" + version = "2.1.2" } provider "tls" { - version = "1.2" + version = "2.0.1" } diff --git a/examples/runner-public/.terraform-version b/examples/runner-public/.terraform-version index 44ab23e43..a95c45d4f 100644 --- a/examples/runner-public/.terraform-version +++ b/examples/runner-public/.terraform-version @@ -1 +1 @@ -0.11.13 +0.11.14 diff --git a/examples/runner-public/main.tf b/examples/runner-public/main.tf index 62aff0c09..7a2339f6e 100644 --- a/examples/runner-public/main.tf +++ b/examples/runner-public/main.tf @@ -1,6 +1,6 @@ module "vpc" { source = "terraform-aws-modules/vpc/aws" - version = "1.60.0" + version = "1.66.0" name = "vpc-${var.environment}" cidr = "10.1.0.0/16" @@ -8,6 +8,8 @@ module "vpc" { azs = ["eu-west-1b"] public_subnets = ["10.1.101.0/24"] + map_public_ip_on_launch = "false" + tags = { Environment = "${var.environment}" } @@ -19,8 +21,7 @@ module "runner" { aws_region = "${var.aws_region}" environment = "${var.environment}" - ssh_public_key = "${local_file.public_ssh_key.content}" - + ssh_public_key = "${local_file.public_ssh_key.content}" runners_use_private_address = false vpc_id = "${module.vpc.vpc_id}" @@ -28,7 +29,7 @@ module "runner" { subnet_id_runners = "${element(module.vpc.public_subnets, 0)}" aws_zone = "b" - runner_instance_spot_price = "0.006" + docker_machine_spot_price_bid = "0.1" runners_name = "${var.runner_name}" runners_gitlab_url = "${var.gitlab_url}" diff --git a/examples/runner-public/providers.tf b/examples/runner-public/providers.tf index 8f3bc2aed..02546632f 100644 --- a/examples/runner-public/providers.tf +++ b/examples/runner-public/providers.tf @@ -1,20 +1,20 @@ provider "aws" { region = "${var.aws_region}" - version = "2.4" + version = "2.13" } provider "template" { - version = "2.1" + version = "2.1.2" } provider "local" { - version = "1.2" + version = "1.2.2" } provider "null" { - version = "2.1" + version = "2.1.2" } provider "tls" { - version = "1.2" + version = "2.0.1" } diff --git a/variables.tf b/variables.tf index 724098a5a..5922bb294 100644 --- a/variables.tf +++ b/variables.tf @@ -48,12 +48,12 @@ variable "ssh_public_key" { variable "docker_machine_instance_type" { description = "Instance type used for the instances hosting docker-machine." - default = "m5.large" + default = "m5a.large" } variable "docker_machine_spot_price_bid" { description = "Spot price bid." - default = "0.04" + default = "0.06" } variable "docker_machine_version" { @@ -239,7 +239,7 @@ variable "cache_shared" { variable "gitlab_runner_version" { description = "Version of the GitLab runner." type = "string" - default = "11.10.1" + default = "11.11.2" } variable "enable_gitlab_runner_ssh_access" { From b71a8f0f47d2ea7b43e64bc34d045f069fa233df Mon Sep 17 00:00:00 2001 From: Niek Palm Date: Thu, 6 Jun 2019 01:06:34 +0200 Subject: [PATCH 8/8] Release 3.4.0 --- CHANGELOG.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20bdd1594..a9bb004b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ 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/). -## Unrleases + +## [3.3.0] - 2019-06-06 - Changed: - Update default runner type, GitLab runner version, and versions in examples. - Buffix #75 runner is not reachable when runners_use_private_address = false @@ -125,7 +126,8 @@ 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.3.0...HEAD +[Unreleased]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/3.4.0...HEAD +[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 [3.1.0]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/3.0.0...3.1.0