Added in Terraform provisioner

This commit is contained in:
2022-03-17 12:09:58 +13:00
parent fb08a64e88
commit dbf1435fd4
2 changed files with 69 additions and 3 deletions

View File

@@ -5,7 +5,6 @@ local distros = ['centos7',
'debian10', 'debian10',
'debian11']; 'debian11'];
/* Configuration of DIND */ /* Configuration of DIND */
local docker_service() = local docker_service() =
{ {
@@ -49,6 +48,7 @@ local test_distro(distribution) =
local gen_pipeline(distro) = local gen_pipeline(distro) =
{kind: 'pipeline', {kind: 'pipeline',
type: 'docker', type: 'docker',
node: {linodrone: true},
name: 'Test on %(distro)s' % { distro: distro }, name: 'Test on %(distro)s' % { distro: distro },
steps: steps:
[test_distro(distro)], [test_distro(distro)],
@@ -58,12 +58,25 @@ local gen_pipeline(distro) =
[{ [{
name: 'dockersock', name: 'dockersock',
temp: {}, temp: {},
}, },],
], depends_on:
['runners']
}; };
// Generate the output // Generate the output
[ [
{kind: 'pipeline',
type: 'docker',
name: 'runners',
steps:
[{name: 'Provision with terraform',
image: 'hashicorp/terraform:1.1.7',
commands: ['cd terraform',
'terraform init',
'terraform plan',
'terraform apply -auto-approve',
]},]
},
gen_pipeline('centos7'), gen_pipeline('centos7'),
gen_pipeline('centos8'), gen_pipeline('centos8'),
gen_pipeline('rockylinux8'), gen_pipeline('rockylinux8'),

View File

@@ -0,0 +1,53 @@
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"
}
}
}
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-nanode-1"
authorized_keys = [ var.ssh_pubkey ]
root_pass = var.root_pass
provisioner "remote-exec" {
inline = [
"yum upgrade -y && systemctl restart docker",
]
}
}