From 3c884e609087abd1d3bb576a8673037e0a3166a9 Mon Sep 17 00:00:00 2001 From: Gitea Actions Date: Tue, 27 May 2025 08:22:41 +0000 Subject: [PATCH] Auto-update blog content from Obsidian: 2025-05-27 08:22:41 --- content/post/terraform-create-vm-proxmox.md | 35 +++++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/content/post/terraform-create-vm-proxmox.md b/content/post/terraform-create-vm-proxmox.md index 3117c3f..9ee3d0c 100644 --- a/content/post/terraform-create-vm-proxmox.md +++ b/content/post/terraform-create-vm-proxmox.md @@ -42,12 +42,39 @@ I chose the `bpg/proxmox` provider because it’s better maintained at the time ### Install Terraform +For the Terraform installation, I followed the [documentation](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli) to install it into my LXC container. + +```bash +# Ensure that your system is up to date and you have installed the `gnupg`, `software-properties-common`, and `curl` packages installed. You will use these packages to verify HashiCorp's GPG signature and install HashiCorp's Debian package repository. +apt-get update && apt-get install -y gnupg software-properties-common + +# Install the HashiCorp [GPG key](https://apt.releases.hashicorp.com/gpg). + +wget -O- | gpg --dearmor | tee /usr/share/keyrings/hashicorp-archive-keyring.gpg > /dev/null + +# Verify the key's fingerprint. + +gpg --no-default-keyring --keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg --fingerprint + +# Add the official HashiCorp repository to your system. The `lsb_release -cs` command finds the distribution release codename for your current system, such as `buster`, `groovy`, or `sid`. + +echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/hashicorp.list + +# Download the package information from HashiCorp. + +apt update + +# Install Terraform from the new repository. + +apt-get install terraform +``` + ### Create a Dedicated Terraform User on Proxmox Before Terraform can interact with your Proxmox cluster, you want to create a dedicated user with limited privileges. You could use the `root@pam` but I wouldn't recommended it for security perspectives. -From any of your Proxmox node, log into the console as priviledged user, `root` in that case. -1. **Create the Role `TerraformUser`**: +From any of your Proxmox nodes, log into the console as priviledged user, `root` in that case. +1. **Create the Role `TerraformUser`** ```bash pveum role add TerraformUser -privs "\ Datastore.Allocate \ @@ -75,7 +102,7 @@ pveum role add TerraformUser -privs "\ SDN.Use" ``` -2. **Create the User `terraformer`**: +2. **Create the User `terraformer`** ```bash pveum user add terraformer@pve --password ``` @@ -94,6 +121,8 @@ pveum user token add terraformer@pve terraform -expire 0 -privsep 0 -comment "Te ### Install SSH Keys on Proxmox Nodes + + --- ## Deploy your First VM Show the code I used and explain each blocks