Add working provisioning and configuration for MS SQL data warehouse
This commit is contained in:
103
provisioning/modules/vm/main.tf
Normal file
103
provisioning/modules/vm/main.tf
Normal file
@@ -0,0 +1,103 @@
|
||||
resource "proxmox_virtual_environment_vm" "this" {
|
||||
node_name = var.node_name
|
||||
vm_id = var.vm_id
|
||||
name = var.name
|
||||
description = var.description
|
||||
tags = var.tags
|
||||
on_boot = var.on_boot
|
||||
bios = var.bios
|
||||
machine = var.machine
|
||||
|
||||
dynamic "clone" {
|
||||
for_each = var.clone_vm_id != null ? [1] : []
|
||||
content {
|
||||
vm_id = var.clone_vm_id
|
||||
full = var.clone_full
|
||||
datastore_id = var.clone_datastore_id
|
||||
}
|
||||
}
|
||||
|
||||
operating_system {
|
||||
type = var.os_type
|
||||
}
|
||||
|
||||
cpu {
|
||||
cores = var.cpu_cores
|
||||
sockets = var.cpu_sockets
|
||||
type = var.cpu_type
|
||||
numa = true
|
||||
}
|
||||
|
||||
memory {
|
||||
dedicated = var.memory_dedicated
|
||||
}
|
||||
|
||||
disk {
|
||||
datastore_id = var.disk_datastore
|
||||
interface = var.disk_interface
|
||||
size = var.disk_size
|
||||
file_id = var.clone_vm_id == null ? var.disk_file_id : null
|
||||
discard = "on"
|
||||
file_format = "raw"
|
||||
}
|
||||
|
||||
dynamic "disk" {
|
||||
for_each = var.data_disk_size != null ? [1] : []
|
||||
content {
|
||||
datastore_id = var.data_disk_datastore
|
||||
interface = var.data_disk_interface
|
||||
size = var.data_disk_size
|
||||
discard = "on"
|
||||
file_format = "raw"
|
||||
}
|
||||
}
|
||||
|
||||
dynamic "efi_disk" {
|
||||
for_each = var.bios == "ovmf" ? [1] : []
|
||||
content {
|
||||
datastore_id = var.disk_datastore
|
||||
file_format = "raw"
|
||||
type = "4m"
|
||||
}
|
||||
}
|
||||
|
||||
network_device {
|
||||
bridge = var.network_bridge
|
||||
model = "virtio"
|
||||
vlan_id = var.network_vlan_id
|
||||
}
|
||||
|
||||
agent {
|
||||
enabled = true
|
||||
trim = true
|
||||
}
|
||||
|
||||
initialization {
|
||||
datastore_id = var.cloud_init_datastore
|
||||
|
||||
dynamic "dns" {
|
||||
for_each = length(var.init_dns_servers) > 0 ? [1] : []
|
||||
content {
|
||||
servers = var.init_dns_servers
|
||||
}
|
||||
}
|
||||
|
||||
ip_config {
|
||||
ipv4 {
|
||||
address = var.init_ipv4_address
|
||||
gateway = var.init_ipv4_gateway
|
||||
}
|
||||
}
|
||||
|
||||
user_account {
|
||||
username = var.init_username
|
||||
password = var.admin_password
|
||||
}
|
||||
}
|
||||
|
||||
lifecycle {
|
||||
ignore_changes = [
|
||||
disk[0].file_id,
|
||||
]
|
||||
}
|
||||
}
|
||||
19
provisioning/modules/vm/outputs.tf
Normal file
19
provisioning/modules/vm/outputs.tf
Normal file
@@ -0,0 +1,19 @@
|
||||
output "vm_id" {
|
||||
description = "The Proxmox VM ID"
|
||||
value = proxmox_virtual_environment_vm.this.vm_id
|
||||
}
|
||||
|
||||
output "name" {
|
||||
description = "The VM hostname"
|
||||
value = proxmox_virtual_environment_vm.this.name
|
||||
}
|
||||
|
||||
output "ipv4_addresses" {
|
||||
description = "All IPv4 addresses reported by the QEMU agent"
|
||||
value = proxmox_virtual_environment_vm.this.ipv4_addresses
|
||||
}
|
||||
|
||||
output "mac_addresses" {
|
||||
description = "MAC addresses of the network interfaces"
|
||||
value = proxmox_virtual_environment_vm.this.mac_addresses
|
||||
}
|
||||
187
provisioning/modules/vm/variables.tf
Normal file
187
provisioning/modules/vm/variables.tf
Normal file
@@ -0,0 +1,187 @@
|
||||
variable "node_name" {
|
||||
description = "The name of the Proxmox node to provision the VM on"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "vm_id" {
|
||||
description = "The unique ID for the VM (100-999999999)"
|
||||
type = number
|
||||
}
|
||||
|
||||
variable "name" {
|
||||
description = "The VM name (must be a valid DNS name)"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "description" {
|
||||
description = "A description for the VM"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "tags" {
|
||||
description = "List of tags to apply to the VM"
|
||||
type = list(string)
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "on_boot" {
|
||||
description = "Whether to start the VM automatically on host boot"
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "os_type" {
|
||||
description = "OS type hint for Proxmox (l26 = Linux 2.6+, win10, etc.)"
|
||||
type = string
|
||||
default = "l26"
|
||||
}
|
||||
|
||||
variable "bios" {
|
||||
description = "BIOS type: seabios or ovmf (UEFI)"
|
||||
type = string
|
||||
default = "seabios"
|
||||
}
|
||||
|
||||
variable "machine" {
|
||||
description = "Machine type: pc or q35"
|
||||
type = string
|
||||
default = "q35"
|
||||
}
|
||||
|
||||
# CPU
|
||||
variable "cpu_cores" {
|
||||
description = "Number of CPU cores per socket"
|
||||
type = number
|
||||
default = 2
|
||||
}
|
||||
|
||||
variable "cpu_sockets" {
|
||||
description = "Number of CPU sockets"
|
||||
type = number
|
||||
default = 2
|
||||
}
|
||||
|
||||
variable "cpu_type" {
|
||||
description = "CPU emulation type (host for best performance, qemu64 for compatibility)"
|
||||
type = string
|
||||
default = "host"
|
||||
}
|
||||
|
||||
# Memory
|
||||
variable "memory_dedicated" {
|
||||
description = "Dedicated RAM in MB"
|
||||
type = number
|
||||
default = 2048
|
||||
}
|
||||
|
||||
# Clone
|
||||
variable "clone_vm_id" {
|
||||
description = "VM ID of the template to clone. When set, a clone block is used instead of disk_file_id."
|
||||
type = number
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "clone_full" {
|
||||
description = "Perform a full clone (true) or linked clone (false)"
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "clone_datastore_id" {
|
||||
description = "Target datastore for the cloned disks (null = keep on source datastore)"
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
# Disk
|
||||
variable "disk_datastore" {
|
||||
description = "Proxmox datastore ID for the VM disk"
|
||||
type = string
|
||||
default = "local-lvm"
|
||||
}
|
||||
|
||||
variable "disk_interface" {
|
||||
description = "Disk interface (scsi0, virtio0, sata0)"
|
||||
type = string
|
||||
default = "scsi0"
|
||||
}
|
||||
|
||||
variable "disk_size" {
|
||||
description = "Disk size in GB"
|
||||
type = number
|
||||
default = 20
|
||||
}
|
||||
|
||||
variable "disk_file_id" {
|
||||
description = "File ID of the base disk image to import (e.g. local:iso/debian-12-cloud.img). Ignored when clone_vm_id is set."
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "data_disk_size" {
|
||||
description = "Size in GB of an optional second data disk. Set to null to skip."
|
||||
type = number
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "data_disk_datastore" {
|
||||
description = "Proxmox datastore ID for the data disk."
|
||||
type = string
|
||||
default = "local-lvm"
|
||||
}
|
||||
|
||||
variable "data_disk_interface" {
|
||||
description = "Disk interface for the data disk (must differ from the OS disk)."
|
||||
type = string
|
||||
default = "scsi1"
|
||||
}
|
||||
|
||||
# Network
|
||||
variable "network_bridge" {
|
||||
description = "The Linux bridge to attach the network device to"
|
||||
type = string
|
||||
default = "vmbr0"
|
||||
}
|
||||
|
||||
variable "network_vlan_id" {
|
||||
description = "Optional VLAN tag for the network device (null = no VLAN)"
|
||||
type = number
|
||||
default = null
|
||||
}
|
||||
|
||||
# Initialization (provider-native)
|
||||
variable "init_ipv4_address" {
|
||||
description = "IPv4 address in CIDR notation (e.g. 10.10.2.100/24) or dhcp"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "init_ipv4_gateway" {
|
||||
description = "IPv4 gateway address"
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "init_dns_servers" {
|
||||
description = "List of DNS servers for initialization"
|
||||
type = list(string)
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "init_username" {
|
||||
description = "Username for the initial account"
|
||||
type = string
|
||||
default = "Administrator"
|
||||
}
|
||||
|
||||
variable "admin_password" {
|
||||
description = "Password for the initial account"
|
||||
type = string
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
variable "cloud_init_datastore" {
|
||||
description = "Datastore used to store the cloud-init drive"
|
||||
type = string
|
||||
default = "local"
|
||||
}
|
||||
8
provisioning/modules/vm/versions.tf
Normal file
8
provisioning/modules/vm/versions.tf
Normal file
@@ -0,0 +1,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
proxmox = {
|
||||
source = "bpg/proxmox"
|
||||
version = "~> 0.73"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user