-
-
Notifications
You must be signed in to change notification settings - Fork 331
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
227 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.11.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Example - Runner - Docker runner | ||
|
||
Example how create a gitlab runner using the docker executor on a single node, running in a private subnet. | ||
|
||
## 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
resource "tls_private_key" "ssh" { | ||
algorithm = "RSA" | ||
} | ||
|
||
resource "local_file" "public_ssh_key" { | ||
depends_on = ["tls_private_key.ssh"] | ||
|
||
content = "${tls_private_key.ssh.public_key_openssh}" | ||
filename = "${var.public_ssh_key_filename}" | ||
} | ||
|
||
resource "local_file" "private_ssh_key" { | ||
depends_on = ["tls_private_key.ssh"] | ||
|
||
content = "${tls_private_key.ssh.private_key_pem}" | ||
filename = "${var.private_ssh_key_filename}" | ||
} | ||
|
||
resource "null_resource" "file_permission" { | ||
depends_on = ["local_file.private_ssh_key"] | ||
|
||
provisioner "local-exec" { | ||
command = "${format("chmod 600 %s", var.private_ssh_key_filename)}" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module "vpc" { | ||
source = "terraform-aws-modules/vpc/aws" | ||
version = "1.37.0" | ||
|
||
name = "vpc-${var.environment}" | ||
cidr = "10.1.0.0/16" | ||
|
||
azs = ["eu-west-1a"] | ||
public_subnets = ["10.1.101.0/24"] | ||
|
||
tags = { | ||
Environment = "${var.environment}" | ||
} | ||
} | ||
|
||
module "runner" { | ||
source = "../../" | ||
|
||
aws_region = "${var.aws_region}" | ||
environment = "${var.environment}" | ||
|
||
ssh_public_key = "${local_file.public_ssh_key.content}" | ||
|
||
runners_use_private_address = false | ||
|
||
vpc_id = "${module.vpc.vpc_id}" | ||
subnet_ids_gitlab_runner = "${module.vpc.public_subnets}" | ||
subnet_id_runners = "${element(module.vpc.public_subnets, 0)}" | ||
|
||
runners_executor = "docker" | ||
runners_name = "${var.runner_name}" | ||
runners_gitlab_url = "${var.gitlab_url}" | ||
runners_token = "${var.runner_token}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
provider "aws" { | ||
region = "${var.aws_region}" | ||
version = "1.23" | ||
} | ||
|
||
provider "template" { | ||
version = "1.0" | ||
} | ||
|
||
provider "local" { | ||
version = "1.1" | ||
} | ||
|
||
provider "null" { | ||
version = "1.0" | ||
} | ||
|
||
provider "tls" { | ||
version = "1.1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
key_name = "gitlab-runner" | ||
|
||
environment = "runner-docker" | ||
|
||
aws_region = "eu-west-1" | ||
|
||
# Add the following variables: | ||
runner_name = "docker.m3" | ||
|
||
gitlab_url = "https://gitlab.com" | ||
|
||
runner_token = "3939146918cced54ecf1dd08e6b87e" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
variable "aws_region" { | ||
description = "AWS region." | ||
type = "string" | ||
default = "eu-west-1" | ||
} | ||
|
||
variable "environment" { | ||
description = "A name that indentifies the environment, will used as prefix and for taggin." | ||
default = "ci-runners" | ||
type = "string" | ||
} | ||
|
||
variable "public_ssh_key_filename" { | ||
default = "generated/id_rsa.pub" | ||
} | ||
|
||
variable "private_ssh_key_filename" { | ||
default = "generated/id_rsa" | ||
} | ||
|
||
variable "runner_name" { | ||
description = "Name of the runner, will be used in the runner config.toml" | ||
type = "string" | ||
} | ||
|
||
variable "gitlab_url" { | ||
description = "URL of the gitlab instance to connect to." | ||
type = "string" | ||
} | ||
|
||
variable "runner_token" { | ||
description = "Token for the runner, will be used in the runner config.toml" | ||
type = "string" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.