init: copied modules from lawndale-infra

This commit is contained in:
2022-05-26 00:40:29 +02:00
commit 414feb48ee
39 changed files with 1435 additions and 0 deletions

13
lawndale-vm-ipam/dns.tf Normal file
View File

@@ -0,0 +1,13 @@
resource "dns_a_record_set" "this" {
zone = "lawndale."
name = "${var.name}.${var.interface}"
addresses = [local.ip_address]
ttl = var.ttl
}
resource "dns_ptr_record" "this" {
zone = "168.192.in-addr.arpa."
name = local.ptr_name
ptr = "${var.name}.${var.interface}.lawndale."
ttl = var.ttl
}

View File

@@ -0,0 +1,18 @@
locals {
interface_ip_map = {
"internal" = "192.168.254"
"nat" = "192.168.253"
}
interface_ptr_map = {
"internal" = "254"
"nat" = "253"
}
ip_address = "${local.interface_ip_map[var.interface]}.${var.id}"
ptr_name = "${var.id}.${local.interface_ip_map[var.interface]}"
lawndale_interface_map = {
"internal" = "brInternal"
"nat" = "brNAT"
}
}

View File

@@ -0,0 +1,35 @@
output "ip_address" {
value = local.ip_address
}
output "fqdn" {
value = "${dns_a_record_set.this.name}.${dns_a_record_set.this.zone}"
}
output "interface" {
value = var.interface
}
output "name" {
value = var.name
}
output "gateway" {
value = "${local.interface_ip_map[var.interface]}.254"
}
output "nameserver" {
value = "${local.interface_ip_map[var.interface]}.254"
}
output "search_domains" {
value = ["${var.interface}.lawndale.", "lawndale."]
}
output "cidr" {
value = 24
}
output "lawndale_interface" {
value = local.lawndale_interface_map[var.interface]
}

View File

@@ -0,0 +1,8 @@
terraform {
required_providers {
dns = {
source = "hashicorp/dns"
version = "~> 3.2"
}
}
}

View File

@@ -0,0 +1,21 @@
variable "id" {
type = number
description = "The ID for the VM that will be transposed into an IP address"
}
variable "name" {
type = string
description = "The domain name for the vm"
}
variable "interface" {
type = string
description = "Which interface should be used. Can be either nat or internal"
}
variable "ttl" {
type = number
description = "TTL value for the new records"
default = 300
}