Compare commits
13 Commits
a6662b7b4a
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| b3afe77bc0 | |||
| ef8ad56273 | |||
| 344cb8a398 | |||
| d2ba0f5b9a | |||
| 440cd09734 | |||
| 92e773faf4 | |||
| da522ad02e | |||
| 768b778c69 | |||
| d534503c54 | |||
| ac3a7b5681 | |||
| 843de2f9a2 | |||
| ec79acd448 | |||
| e824649729 |
32
Notes.txt
Normal file
32
Notes.txt
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#Hey Friends
|
||||||
|
# Starting with installing terraform on my ansible box.
|
||||||
|
wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
|
||||||
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(grep -oP '(?<=UBUNTU_CODENAME=).*' /etc/os-release || lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
|
||||||
|
sudo apt update && sudo apt install terraform
|
||||||
|
|
||||||
|
# I dont want this to be in bash. but oh well
|
||||||
|
|
||||||
|
#starting with this github
|
||||||
|
https://github.com/Telmate/terraform-provider-proxmox/blob/master/docs/index.md
|
||||||
|
|
||||||
|
#I am on Proxmox 8 so starting off there.
|
||||||
|
|
||||||
|
pveum role add TerraformProv -privs "Datastore.AllocateSpace Datastore.AllocateTemplate Datastore.Audit Pool.Allocate Sys.Audit Sys.Console Sys.Modify VM.Allocate VM.Audit VM.Clone VM.Config.CDROM VM.Config.Cloudinit VM.Config.CPU VM.Config.Disk VM.Config.HWType VM.Config.Memory VM.Config.Network VM.Config.Options VM.Monitor VM.Migrate VM.PowerMgmt SDN.Use"
|
||||||
|
pveum user add terraform-prov@pve --password <in 1password>
|
||||||
|
pveum aclmod / -user terraform-prov@pve -role TerraformProv
|
||||||
|
pveum user token add terraform-prov@pve terraform-token --expire $(date -d 2025-10-24T23:59:59 +%s) --privsep false
|
||||||
|
#Nice this worked
|
||||||
|
|
||||||
|
# if update to 9 later
|
||||||
|
pveum role modify TerraformProv -privs "Datastore.AllocateSpace Datastore.AllocateTemplate Datastore.Audit Pool.Allocate Sys.Audit Sys.Console Sys.Modify VM.Allocate VM.Audit VM.Clone VM.Config.CDROM VM.Config.Cloudinit VM.Config.CPU VM.Config.Disk VM.Config.HWType VM.Config.Memory VM.Config.Network VM.Config.Options VM.Migrate VM.PowerMgmt SDN.Use"
|
||||||
|
|
||||||
|
#If I hate this
|
||||||
|
pveum role list
|
||||||
|
pveum role delete <uid>
|
||||||
|
pveum user delete <uid>
|
||||||
|
|
||||||
|
#I had to set the mapall user : root and mapall group : wheel in truenas. but then it worked!
|
||||||
|
|
||||||
|
|
||||||
|
pvesm path "nfs_Vulnerable:vztmpl/debian-13-standard_13.1-2_amd64.tar.zst"
|
||||||
|
|
||||||
1
homelab_pub
Normal file
1
homelab_pub
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJo337iE4+Ry7T65Ey+2QQ9aRaGxP7zzLtMV+hBPyA59 eddsa-key-20250525
|
||||||
4
outputs.tf
Normal file
4
outputs.tf
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
output "proxmox" {
|
||||||
|
description="I am doing my Best"
|
||||||
|
value = basic.id
|
||||||
|
}
|
||||||
30
provider.tf
Normal file
30
provider.tf
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
terraform {
|
||||||
|
required_version = ">= 1.13.0"
|
||||||
|
|
||||||
|
required_providers{
|
||||||
|
proxmox = {
|
||||||
|
source = "telmate/proxmox"
|
||||||
|
}
|
||||||
|
ansible = {
|
||||||
|
source = "ansible/ansible"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "proxmox_api_url" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
variable "proxmox_api_token_id" {
|
||||||
|
type = string
|
||||||
|
sensitive = true
|
||||||
|
}
|
||||||
|
variable "proxmox_api_token_secret" {
|
||||||
|
type = string
|
||||||
|
sensitive = true
|
||||||
|
}
|
||||||
|
|
||||||
|
provider "proxmox" {
|
||||||
|
pm_api_url = var.proxmox_api_url
|
||||||
|
pm_api_token_id = var.proxmox_api_token_id
|
||||||
|
pm_api_token_secret = var.proxmox_api_token_secret
|
||||||
|
}
|
||||||
33
srv-debianlxc.tf
Normal file
33
srv-debianlxc.tf
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
resource "proxmox_lxc" "basic" {
|
||||||
|
target_node = "pve"
|
||||||
|
hostname = "lxc-basic"
|
||||||
|
ostemplate = "nfs_Vulnerable:vztmpl/debian-13-standard_13.1-2_amd64.tar.zst"
|
||||||
|
password = "BasicLXCContainer"
|
||||||
|
unprivileged = true
|
||||||
|
description = "Nice"
|
||||||
|
features {
|
||||||
|
nesting = true
|
||||||
|
}
|
||||||
|
ssh_public_keys = <<-EOT
|
||||||
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJo337iE4+Ry7T65Ey+2QQ9aRaGxP7zzLtMV+hBPyA59 eddsa-key-20250525
|
||||||
|
EOT
|
||||||
|
|
||||||
|
// Terraform will crash without rootfs defined
|
||||||
|
rootfs {
|
||||||
|
storage = "nfs_Protected"
|
||||||
|
size = "8G"
|
||||||
|
}
|
||||||
|
|
||||||
|
network {
|
||||||
|
name = "eth0"
|
||||||
|
bridge = "vmbr0"
|
||||||
|
ip = "dhcp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resource "local_file" "Ans_inv" {
|
||||||
|
content = <<-DOC
|
||||||
|
hostname: ${proxmox_lxc.basic.hostname}
|
||||||
|
id: ${proxmox_lxc.basic.id}
|
||||||
|
DOC
|
||||||
|
filename = "${path.module}/output.txt"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user