From d80cce8bfb13f91243f4c31592b9b4afc710d271 Mon Sep 17 00:00:00 2001 From: Matt Reeves Date: Mon, 24 Jun 2024 19:47:57 -0400 Subject: [PATCH] adding cloud init plus windows --- cloud-init.tf | 36 ++++++++++++++++++++++++++++++++++++ ubuntu22-template2.tf | 2 +- windows.tf | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 windows.tf diff --git a/cloud-init.tf b/cloud-init.tf index 948f676..9923e19 100644 --- a/cloud-init.tf +++ b/cloud-init.tf @@ -27,6 +27,42 @@ resource "proxmox_virtual_environment_file" "cloud_config" { - systemctl enable qemu-guest-agent - systemctl start qemu-guest-agent - curl -fsSL https://get.docker.com | sudo sh + - su - mafyuh -c 'git clone https://git.mafyuh.dev/mafyuh/IaC-Homelab.git /home/mafyuh/IaC-Homelab' + - su - mafyuh -c 'git clone https://git.mafyuh.dev/mafyuh/Auto-Homelab.git /home/mafyuh/Auto-Homelab' + - echo "done" > /tmp/cloud-config.done + EOF + + file_name = "cloud-config.yaml" + } +} + +resource "proxmox_virtual_environment_file" "cloud_config2" { + content_type = "snippets" + datastore_id = "Fast500Gb" + node_name = "pve2" + + 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 + - su - mafyuh -c 'git clone https://git.mafyuh.dev/mafyuh/IaC-Homelab.git /home/mafyuh/IaC-Homelab' + - su - mafyuh -c 'git clone https://git.mafyuh.dev/mafyuh/Auto-Homelab.git /home/mafyuh/Auto-Homelab' - echo "done" > /tmp/cloud-config.done EOF diff --git a/ubuntu22-template2.tf b/ubuntu22-template2.tf index 4164b70..49bf81a 100644 --- a/ubuntu22-template2.tf +++ b/ubuntu22-template2.tf @@ -24,7 +24,7 @@ resource "proxmox_virtual_environment_vm" "Ubuntu-22-Template2" { } } - user_data_file_id = proxmox_virtual_environment_file.cloud_config.id + user_data_file_id = proxmox_virtual_environment_file.cloud_config2.id } serial_device {} diff --git a/windows.tf b/windows.tf new file mode 100644 index 0000000..50573c2 --- /dev/null +++ b/windows.tf @@ -0,0 +1,43 @@ +resource "proxmox_virtual_environment_vm" "Windows11" { + name = "windows" + node_name = "pve2" + vm_id = 250 + tags = ["tofu"] + started = false + bios = "ovmf" + machine = "q35" + + disk { + datastore_id = "Fast500Gb" + interface = "scsi0" + size = 450 + } + + cpu { + cores = 2 + type = "host" + architecture = "x86_64" + } + + memory { + dedicated = 8192 + } + + efi_disk { + type = "4m" + } + + network_device { + bridge = "vmbr0" + vlan_id = 1 + } + + tpm_state { + datastore_id = "Fast500Gb" + version = "v2.0" +} + + operating_system { + type = "win11" +} +}