homelab/tf/resources.tf

57 lines
1.2 KiB
HCL

resource "proxmox_virtual_environment_file" "common_cloud_init" {
content_type = "snippets"
datastore_id = var.proxmox_image_storage
node_name = "pve"
source_raw {
data = <<EOF
#cloud-config
chpasswd:
list: |
ubuntu:ubuntu
${var.username}:${var.username}
expire: false
packages:
- qemu-guest-agent
- nfs-common
- avahi-daemon
timezone: America/Vancouver
users:
- default
- name: ubuntu
groups: sudo
shell: /bin/bash
ssh-authorized-keys:
- ${trimspace(file(var.ssh_public_key_file))}
sudo: ALL=(ALL) NOPASSWD:ALL
- name: ${var.username}
groups: sudo
shell: /bin/bash
ssh_import_id:
- ${var.ssh_import_id}
sudo: ALL=(ALL) NOPASSWD:ALL
power_state:
delay: now
mode: reboot
message: Rebooting after cloud-init completion
condition: true
EOF
file_name = "common-cloud-init.cloud-config.yaml"
}
}
resource "proxmox_virtual_environment_file" "ubuntu_cloud_image" {
content_type = "iso"
datastore_id = var.proxmox_image_storage
node_name = "pve"
source_file {
path = "https://cloud-images.ubuntu.com/noble/20250122/noble-server-cloudimg-amd64.img"
checksum = "482244b83f49a97ee61fb9b8520d6e8b9c2e3c28648de461ba7e17681ddbd1c9"
}
}