diff --git a/CHANGELOG.md b/CHANGELOG.md index cba5a99f1..a9bb004b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ 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.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 + - 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 @@ -116,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 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/main.tf b/main.tf index 398cadccd..acf60cdcf 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)))}", ] } @@ -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 @@ -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}" } 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": "*" + } + ] + } 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 diff --git a/variables.tf b/variables.tf index 648e20538..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" { @@ -334,6 +334,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 = ""