Create terraform for gitlab runner

This commit is contained in:
Adam Shamblin 2022-09-25 20:18:21 -06:00
parent 725a60596c
commit edc6b85046
No known key found for this signature in database
GPG Key ID: 22E0BC8E6B4D8C8E
3 changed files with 51 additions and 0 deletions

2
cicd/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.terraform*
terraform.tfstate*

20
cicd/provider.tf Normal file
View File

@ -0,0 +1,20 @@
terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
version = "~> 2.0"
}
}
}
variable "do_token" {}
variable "ssh_key" {}
variable "pvt_key" {}
provider "digitalocean" {
token = var.do_token
}
data "digitalocean_ssh_key" "ssh_key" {
name = var.ssh_key
}

29
cicd/runner.tf Normal file
View File

@ -0,0 +1,29 @@
resource "digitalocean_droplet" "veilid-runner-1" {
image = "debian-11-x64"
name = "veilid-runner-1"
region = "nyc1"
size = "s-1vcpu-512mb-10gb"
ssh_keys = [
data.digitalocean_ssh_key.ssh_key.id
]
connection {
host = self.ipv4_address
user = "root"
type = "ssh"
private_key = file(var.pvt_key)
timeout = "2m"
}
provisioner "remote-exec" {
inline = [
"apt-get update",
"apt-get -y install ca-certificates curl gnupg lsb-release",
"mkdir -p /etc/apt/keyrings/",
"curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg",
"echo \"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable\" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null",
"apt-get update",
"apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin"
]
}
}