terraform

terraform iac
git clone git://git.pyratebeard.net/terraform.git
Log | Files | Refs | README

commit 244904813f755581cc5016c3601814f947de3e10
parent bd2275ef133a9a6e49d7e166cbaf8e937453de43
Author: pyratebeard <root@pyratebeard.net>
Date:   Mon, 23 Jan 2023 13:01:22 +0000

simple do drop on freebsd

Diffstat:
Adigitalocean/data.tf | 15+++++++++++++++
Adigitalocean/infra.tf | 19+++++++++++++++++++
Adigitalocean/provider.tf | 16++++++++++++++++
Adigitalocean/variables.tf | 23+++++++++++++++++++++++
4 files changed, 73 insertions(+), 0 deletions(-)

diff --git a/digitalocean/data.tf b/digitalocean/data.tf @@ -0,0 +1,15 @@ +data "digitalocean_images" "available" { + filter { + key = "distribution" + values = ["FreeBSD"] + } + filter { + key = "regions" + values = ["lon1"] + } + sort { + key = "created" + direction = "desc" + } +} + diff --git a/digitalocean/infra.tf b/digitalocean/infra.tf @@ -0,0 +1,19 @@ +resource "digitalocean_droplet" "zshtest" { + image = "freebsd-12-x64-zfs" + count = var.instance_count + name = "${var.hostname}0${count.index + 1}" + region = "lon1" + size = "s-1vcpu-1gb" + ssh_keys = [ + data.digitalocean_ssh_key.pyrategpgssh.id + ] + + connection { + host = self.ipv4_address + user = "root" + type = "ssh" + agent = true + private_key = file(var.pvt_key) + timeout = "2m" + } +} diff --git a/digitalocean/provider.tf b/digitalocean/provider.tf @@ -0,0 +1,16 @@ +terraform { + required_providers { + digitalocean = { + source = "digitalocean/digitalocean" + version = "~> 2.0" + } + } +} + +provider "digitalocean" { + token = var.do_token +} + +data "digitalocean_ssh_key" "pyrategpgssh" { + name = "pyrategpgssh" +} diff --git a/digitalocean/variables.tf b/digitalocean/variables.tf @@ -0,0 +1,23 @@ +variable "do_token" { + type = string + description = "DO PAT token" + default = "" +} + +variable "pvt_key" { + type = string + description = "private ssh key" + default = "null" +} + +variable "hostname" { + type = string + description = "hostname of system" + default = "test" +} + +variable "instance_count" { + type = string + description = "number of instances to create" + default = "1" +}