Files
ansible-role-common/terraform/drone-runners.tf
2022-03-17 22:29:45 +13:00

58 lines
1.6 KiB
HCL

variable "drone_instances" {
description = "How many runner instances should there be?"
default = 3
}
variable "root_pass" {
description = "Root password to set on the node"
}
variable "linode_api_token" {
description = "Linode API Token"
}
variable "ssh_pubkey" {
description = "SSH key to be allowed access by default"
}
terraform {
required_providers {
linode = {
source = "linode/linode"
version = "1.16.0"
}
}
backend "local" {
path = "/data/runner.tfstate"
}
}
provider "linode" {
token = var.linode_api_token
}
resource "linode_instance" "terraform-drone" {
connection {
type = "ssh"
user = "root"
password = var.root_pass
host = self.ip_address
}
count = var.drone_instances
image = "private/15818922"
label = "drone-runner-${count.index + 1}"
group = "docker"
tags = ["tag_Testing","docker"]
region = "ap-southeast"
type = "g6-standard-2"
authorized_keys = [ var.ssh_pubkey ]
root_pass = var.root_pass
provisioner "remote-exec" {
inline = [
"yum upgrade -y && systemctl restart docker",
"docker rm -f runner",
"docker run --detach --volume=/var/run/docker.sock:/var/run/docker.sock --env=DRONE_RPC_PROTO=https --env=DRONE_RPC_HOST=drone.guise.net.nz --env=DRONE_RPC_SECRET=super-duper-secret --env=DRONE_RUNNER_CAPACITY=2 --env=DRONE_RUNNER_NAME=drone-runner-${count.index + 1} --env=DRONE_RUNNER_LABELS='linodrone:true' --env=--publish=3000:3000 --restart=always --name=runner drone/drone-runner-docker:1"
]
}
}