This commit is contained in:
Matt Reeves 2024-06-24 17:36:44 -04:00
parent 56d2e90373
commit 7a1ad932bf
5 changed files with 139 additions and 68 deletions

68
arm.tf
View file

@ -1,68 +0,0 @@
resource "proxmox_virtual_environment_vm" "ARM" {
# VM General Settings
node_name = "prox"
vm_id = 8100
name = "ARM"
description = "Ubuntu 24 ARM"
tags = ["tofu", "ubuntu-22", "auto-homelab-repo", "infrastructure"]
bios = "ovmf"
started = false
agent {
enabled = false # read 'Qemu guest agent' section, change to true only when ready
}
# VM Memory Settings
memory {
dedicated = 2048
}
# VM Network Settings
network_device {
bridge = "vmbr0"
vlan_id = 1
}
# VM Disk Settings
disk {
datastore_id = "Fast2Tb"
file_id = proxmox_virtual_environment_download_file.latest_ubuntu_22_arm_jammy_qcow2_img.id
size = 100
interface = "scsi0"
}
efi_disk {
type = "4m"
}
vga {
type = "serial0"
}
initialization {
ip_config {
ipv4 {
address = "dhcp"
}
}
user_account {}
}
lifecycle {
ignore_changes = [
initialization[0].user_account[0].keys,
initialization[0].user_account[0].password,
initialization[0].user_account[0].username,
]
}
}
resource "proxmox_virtual_environment_download_file" "latest_ubuntu_22_arm_jammy_qcow2_img" {
content_type = "iso"
datastore_id = "local"
node_name = "prox"
url = "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-arm64.img"
}

35
cloud-init.tf Normal file
View file

@ -0,0 +1,35 @@
data "local_file" "ssh_public_key" {
filename = "/home/mafyuh/.ssh/main_key.pub"
}
resource "proxmox_virtual_environment_file" "cloud_config" {
content_type = "snippets"
datastore_id = "Slow4tb"
node_name = "prox"
source_raw {
data = <<-EOF
#cloud-config
users:
- default
- name: mafyuh
groups:
- sudo
- docker
shell: /bin/bash
ssh_authorized_keys:
- ${trimspace(data.local_file.ssh_public_key.content)}
sudo: ALL=(ALL) NOPASSWD:ALL
runcmd:
- apt update
- apt install -y qemu-guest-agent net-tools nfs-common
- timedatectl set-timezone America/New_York
- systemctl enable qemu-guest-agent
- systemctl start qemu-guest-agent
- curl -fsSL https://get.docker.com | sudo sh
- echo "done" > /tmp/cloud-config.done
EOF
file_name = "cloud-config.yaml"
}
}

48
ubuntu22-template.tf Normal file
View file

@ -0,0 +1,48 @@
resource "proxmox_virtual_environment_vm" "Ubuntu-22-Template" {
name = "ubuntu-22"
node_name = "prox"
vm_id = 8100
tags = ["tofu", "ubuntu-22"]
template = true
started = false
disk {
datastore_id = "Fast2Tb"
file_id = proxmox_virtual_environment_download_file.ubuntu_cloud_image_22.id
interface = "scsi0"
size = 4
}
agent {
enabled = true
}
initialization {
ip_config {
ipv4 {
address = "dhcp"
}
}
user_data_file_id = proxmox_virtual_environment_file.cloud_config.id
}
serial_device {}
network_device {
bridge = "vmbr0"
}
vga {
type = "serial0"
}
}
resource "proxmox_virtual_environment_download_file" "ubuntu_cloud_image_22" {
content_type = "iso"
datastore_id = "local"
node_name = "prox"
url = "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img"
}

48
ubuntu22-template2.tf Normal file
View file

@ -0,0 +1,48 @@
resource "proxmox_virtual_environment_vm" "Ubuntu-22-Template2" {
name = "ubuntu-22"
node_name = "pve2"
vm_id = 8101
tags = ["tofu", "ubuntu-22"]
template = true
started = false
disk {
datastore_id = "local-lvm"
file_id = proxmox_virtual_environment_download_file.ubuntu_cloud_image_22_2.id
interface = "scsi0"
size = 4
}
agent {
enabled = true
}
initialization {
ip_config {
ipv4 {
address = "dhcp"
}
}
user_data_file_id = proxmox_virtual_environment_file.cloud_config.id
}
serial_device {}
network_device {
bridge = "vmbr0"
}
vga {
type = "serial0"
}
}
resource "proxmox_virtual_environment_download_file" "ubuntu_cloud_image_22_2" {
content_type = "iso"
datastore_id = "local"
node_name = "pve2"
url = "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img"
}

View file

@ -36,4 +36,12 @@ variable "prox_ip_address" {
variable "npm_ip_address" {
type = string
}
variable "init_username" {
type = string
}
variable "init_password" {
type = string
}