init: copied modules from lawndale-infra
This commit is contained in:
13
lawndale-vm-ipam/dns.tf
Normal file
13
lawndale-vm-ipam/dns.tf
Normal 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
|
||||
}
|
||||
18
lawndale-vm-ipam/locals.tf
Normal file
18
lawndale-vm-ipam/locals.tf
Normal 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"
|
||||
}
|
||||
}
|
||||
35
lawndale-vm-ipam/outputs.tf
Normal file
35
lawndale-vm-ipam/outputs.tf
Normal 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]
|
||||
}
|
||||
8
lawndale-vm-ipam/providers.tf
Normal file
8
lawndale-vm-ipam/providers.tf
Normal file
@@ -0,0 +1,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
dns = {
|
||||
source = "hashicorp/dns"
|
||||
version = "~> 3.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
21
lawndale-vm-ipam/variables.tf
Normal file
21
lawndale-vm-ipam/variables.tf
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user