NTP/tf/vm/ntp.tf
Frank Villaro-Dixon 86a215c074 TF: be modularized
Signed-off-by: Frank Villaro-Dixon <frank@villaro-dixon.eu>
2024-06-18 20:21:22 +02:00

72 lines
1.3 KiB
HCL

terraform {
required_providers {
proxmox = {
source = "bpg/proxmox"
version = "0.58.1"
}
}
}
variable "hostname" {
}
variable "ipv4_addr" {
}
variable "ipv4_gw" {
}
variable "px_node" {
}
variable "px_vmid" {
}
variable "px_vlanid" {}
resource "proxmox_virtual_environment_file" "this" {
content_type = "snippets"
datastore_id = "local"
node_name = var.px_node
source_raw {
data = templatefile("${path.module}/cloud-init.tpl.cfg", {
hostname = var.hostname,
ipv4_addr = var.ipv4_addr,
ipv4_gw = var.ipv4_gw,
})
file_name = "${var.hostname}.cloud-config.yaml"
}
}
resource "proxmox_virtual_environment_vm" "this" {
name = var.hostname
description = "Managed by Terraform"
started = true
on_boot = true
node_name = var.px_node
vm_id = var.px_vmid
cpu {
cores = 1
}
memory {
dedicated = 512
}
agent {
enabled = true
}
disk {
datastore_id = "local-lvm"
file_format = "qcow2"
interface = "scsi0"
file_id = "local:iso/noble-server-cloudimg-amd64.img"
size = "10"
}
initialization {
user_data_file_id = proxmox_virtual_environment_file.this.id
datastore_id = "local-lvm"
}
network_device {
bridge = "vmbr0"
vlan_id = var.px_vlanid
}
}