Split project
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
data "dns_a_record_set" "guests" {
|
||||
for_each = toset([ for guest in var.vm_guests: guest.name ])
|
||||
host = "${each.value}.${var.local_domain}"
|
||||
}
|
||||
|
||||
data "dns_aaaa_record_set" "guests" {
|
||||
for_each = toset([ for guest in var.vm_guests: guest.name ])
|
||||
host = "${each.value}.${var.local_domain}"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
data "http" "arch_qcow_hash" {
|
||||
insecure = false
|
||||
method = "GET"
|
||||
retry {
|
||||
attempts = 1
|
||||
min_delay_ms = 5000
|
||||
}
|
||||
url = "https://${var.arch_mirror}/images/latest/Arch-Linux-x86_64-cloudimg.qcow2.SHA256"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
data "proxmox_virtual_environment_nodes" "hvc01" {}
|
||||
|
||||
data "proxmox_virtual_environment_node" "hvc01" {
|
||||
for_each = toset(data.proxmox_virtual_environment_nodes.hvc01.names)
|
||||
node_name = each.value
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
locals {
|
||||
arch_qcow_hash = split(" ", data.http.arch_qcow_hash.response_body)[0]
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
output "debug" {
|
||||
description = "For debugging resource or data key values"
|
||||
value = local.arch_qcow_hash
|
||||
sensitive = false
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
provider "proxmox" {
|
||||
endpoint = "https://hvc01.balsillie.house:443/"
|
||||
insecure = false
|
||||
# api_token = # Takes value from PROXMOX_VE_API_TOKEN env var
|
||||
random_vm_ids = true
|
||||
random_vm_id_start = 10000
|
||||
random_vm_id_end = 99999
|
||||
ssh {
|
||||
username = "ladmin"
|
||||
# SSH Private Key provided by env var PROXMOX_VE_SSH_PRIVATE_KEY
|
||||
agent = false
|
||||
node_address_source = "dns"
|
||||
node {
|
||||
name = "hv01"
|
||||
address = "hv01.balsillie.house"
|
||||
port = 22
|
||||
}
|
||||
node {
|
||||
name = "hv02"
|
||||
address = "hv02.balsillie.house"
|
||||
port = 22
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "dns" {}
|
||||
|
||||
provider "http" {}
|
||||
@@ -0,0 +1,16 @@
|
||||
resource "proxmox_virtual_environment_file" "arch_qcow" {
|
||||
for_each = data.proxmox_virtual_environment_node.hvc01
|
||||
content_type = "import"
|
||||
datastore_id = "local"
|
||||
node_name = each.value.id
|
||||
overwrite = true
|
||||
source_file {
|
||||
checksum = local.arch_qcow_hash
|
||||
file_name = "archlinux_cloudimg_amd64.qcow2"
|
||||
insecure = false
|
||||
min_tls = "1.2"
|
||||
path = "https://${var.arch_mirror}/images/latest/Arch-Linux-x86_64-cloudimg.qcow2"
|
||||
}
|
||||
timeout_upload = 300
|
||||
upload_mode = "stream"
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
terraform {
|
||||
required_version = ">= 1.15.9"
|
||||
|
||||
required_providers {
|
||||
proxmox = {
|
||||
source = "registry.terraform.io/bpg/proxmox"
|
||||
version = ">= 0.111.1"
|
||||
}
|
||||
dns = {
|
||||
source = "registry.terraform.io/hashicorp/dns"
|
||||
version = ">= 3.6.1"
|
||||
}
|
||||
http = {
|
||||
source = "registry.terraform.io/hashicorp/http"
|
||||
version = ">= 3.6.1"
|
||||
}
|
||||
}
|
||||
|
||||
backend "local" {
|
||||
path = "/mnt/nfs/terraform/proxmox/archlinux.tfstate"
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
variable "vm_guests" {
|
||||
type = list(object({
|
||||
name = string
|
||||
host = string
|
||||
role = string
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
variable "ipv4_gateway" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "ipv6_gateway" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "ipv4_ntp_servers" {
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
variable "ipv6_ntp_servers" {
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
variable "ipv4_subnet_mask" {
|
||||
type = number
|
||||
}
|
||||
|
||||
variable "search_domains" {
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
variable "ipv4_nameservers" {
|
||||
type = list(object({
|
||||
address = string
|
||||
}))
|
||||
}
|
||||
|
||||
variable "ipv6_nameservers" {
|
||||
type = list(object({
|
||||
address = string
|
||||
}))
|
||||
}
|
||||
|
||||
variable "local_domain" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "arch_mirror" {
|
||||
type = string
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
arch_mirror = "mirrors.mit.edu/archlinux"
|
||||
@@ -0,0 +1,20 @@
|
||||
ipv4_gateway = "10.96.10.254"
|
||||
ipv4_subnet_mask = 24
|
||||
ipv6_gateway = "2600:4040:593d:8b10:6662:66ff:fe21:e9c4"
|
||||
ipv4_nameservers = [
|
||||
{address = "10.96.10.254"}
|
||||
]
|
||||
ipv6_nameservers = [
|
||||
{address = "2600:4040:593d:8b10:6662:66ff:fe21:e9c4"}
|
||||
]
|
||||
local_domain = "balsillie.house"
|
||||
search_domains = [
|
||||
"balsillie.net",
|
||||
"balsillie.house"
|
||||
]
|
||||
ipv4_ntp_servers = [
|
||||
"10.96.10.254"
|
||||
]
|
||||
ipv6_ntp_servers = [
|
||||
"2600:4040:593d:8b10:6662:66ff:fe21:e9c4"
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
vm_guests = [
|
||||
{
|
||||
host = "hv02"
|
||||
name = "ch01"
|
||||
role = "container_host"
|
||||
},
|
||||
{
|
||||
host = "hv03"
|
||||
name = "ch02"
|
||||
role = "container_host"
|
||||
},
|
||||
{
|
||||
host = "hv03"
|
||||
name = "dl01"
|
||||
role = "download"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user