iac/terraform/cloud-init.tf

76 lines
2.1 KiB
Terraform
Raw Normal View History

2024-07-12 23:57:29 -04:00
data "local_file" "ssh_public_key" {
2024-10-12 15:37:43 -04:00
filename = "~/.ssh/main_key.pub"
2024-07-12 23:57:29 -04:00
}
data "local_file" "ssh_public_key_2" {
2024-10-12 15:37:43 -04:00
filename = "~/.ssh/id_rsa.pub"
}
2024-07-12 23:57:29 -04:00
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)}
- ${trimspace(data.local_file.ssh_public_key_2.content)}
2024-07-12 23:57:29 -04:00
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
2024-07-20 10:46:20 -04:00
- su - mafyuh -c 'git clone https://git.mafyuh.dev/mafyuh/iac.git /home/mafyuh/iac'
2024-07-31 20:19:27 -04:00
- su - mafyuh -c 'git config --global user.name "Mafyuh"'
- su - mafyuh -c 'git config --global user.email "matt@mafyuh.com"'
2024-07-12 23:57:29 -04:00
- 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)}
- ${trimspace(data.local_file.ssh_public_key_2.content)}
2024-07-12 23:57:29 -04:00
sudo: ALL=(ALL) NOPASSWD:ALL
runcmd:
- apt update
- timedatectl set-timezone America/New_York
- systemctl enable qemu-guest-agent
- systemctl start qemu-guest-agent
- apt upgrade -y
2024-07-20 10:33:58 -04:00
- su - mafyuh -c 'git clone https://git.mafyuh.dev/mafyuh/iac.git /home/mafyuh/iac'
2024-07-12 23:57:29 -04:00
- echo "done" > /tmp/cloud-config.done
EOF
file_name = "cloud-config.yaml"
}
}