generated from CC/VMServiceTemplate
Compare commits
9 Commits
7324fa464f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 4fb9000f79 | |||
|
|
0d3b95d5ba | ||
|
|
67c0eda7f7 | ||
|
|
1d92ea993c | ||
|
|
7779b0935d | ||
|
|
c612a45b95 | ||
|
|
335e447842 | ||
|
|
605e102f25 | ||
|
|
41146f5676 |
@@ -3,6 +3,6 @@
|
||||
"n8n":
|
||||
"hosts":
|
||||
"n8n-01":
|
||||
"ansible_host": "192.168.10.107"
|
||||
"ansible_host": "192.168.10.106"
|
||||
"vars":
|
||||
"ansible_user": "cloud"
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
terraform {
|
||||
backend "s3" {
|
||||
bucket = "terraform"
|
||||
key = "n8n/terraform.tfstate"
|
||||
access_key = "GK242d456c0692a9d4cc102206"
|
||||
bucket = "terraform"
|
||||
key = "n8n/terraform.tfstate"
|
||||
access_key = "GK242d456c0692a9d4cc102206"
|
||||
secret_key = "1d7e22b7a8892cb11b569017659aa511b37b53287c4d1699c310d9f8ac76df09"
|
||||
region = "garage"
|
||||
endpoints = {
|
||||
s3 = "http://192.168.10.109:3900"
|
||||
}
|
||||
s3 = "http://192.168.10.109:3900"
|
||||
}
|
||||
skip_credentials_validation = true
|
||||
skip_requesting_account_id = true
|
||||
skip_metadata_api_check = true
|
||||
skip_region_validation = true
|
||||
use_path_style = true
|
||||
use_lockfile = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ locals {
|
||||
vm_name = v.vm_name
|
||||
node_name = v.node_name
|
||||
ipv4_address = module.vm-n8n[k].vm_ipv4_address
|
||||
vm_tags = concat(
|
||||
vm_tags = concat(
|
||||
try(v.vm_tags, []),
|
||||
["terraform", "docker", v.service_name, "ip-${replace(module.vm-n8n[k].vm_ipv4_address, ".", "-")}"]
|
||||
)
|
||||
@@ -31,7 +31,7 @@ module "vm-n8n" {
|
||||
vm_size = coalesce(try(each.value.vm_size, null), var.vm_defaults.vm_size)
|
||||
vm_bios = var.vm_defaults.vm_bios
|
||||
vm_machine = var.vm_defaults.vm_machine
|
||||
vm_tags = concat(
|
||||
vm_tags = concat(
|
||||
try(each.value.vm_tags, []),
|
||||
["terraform", "docker", each.value.service_name]
|
||||
)
|
||||
@@ -39,8 +39,8 @@ module "vm-n8n" {
|
||||
}
|
||||
|
||||
module "inventory" {
|
||||
source = "./modules/proxmox_ansible_inventory"
|
||||
filename = "${abspath("${path.root}/..")}/ansible/inventory/inventory.yml"
|
||||
source = "./modules/proxmox_ansible_inventory"
|
||||
filename = "${abspath("${path.root}/..")}/ansible/inventory/inventory.yml"
|
||||
instances = local.vm_created
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ locals {
|
||||
])
|
||||
}
|
||||
|
||||
|
||||
resource "proxmox_virtual_environment_file" "cloud_config" {
|
||||
content_type = "snippets"
|
||||
datastore_id = "local"
|
||||
@@ -31,7 +32,7 @@ resource "proxmox_virtual_environment_file" "cloud_config" {
|
||||
- docker
|
||||
shell: /bin/bash
|
||||
ssh-authorized-keys:
|
||||
- "${var.vm_user_sshkey}" # Inject user's SSH key
|
||||
- "${var.vm_user_sshkey}" # +++ Needs to be put into a variable injected by git actions secrets
|
||||
sudo: ALL=(ALL) NOPASSWD:ALL
|
||||
|
||||
packages:
|
||||
@@ -42,6 +43,7 @@ resource "proxmox_virtual_environment_file" "cloud_config" {
|
||||
- gnupg
|
||||
- lsb-release
|
||||
- unattended-upgrades
|
||||
- rsync
|
||||
|
||||
runcmd:
|
||||
- systemctl enable qemu-guest-agent
|
||||
@@ -58,58 +60,58 @@ resource "proxmox_virtual_environment_file" "cloud_config" {
|
||||
}
|
||||
|
||||
resource "proxmox_virtual_environment_vm" "ubuntu_22_minimal_clone" {
|
||||
name = var.vm_name # VM name
|
||||
node_name = var.node_name # Proxmox node to deploy the VM
|
||||
tags = var.vm_tags # Optional VM tags for categorization
|
||||
name = var.vm_name # VM name
|
||||
node_name = var.node_name # Proxmox node to deploy the VM
|
||||
tags = var.vm_tags # Optional VM tags for categorization
|
||||
|
||||
agent {
|
||||
enabled = true # Enable the QEMU guest agent
|
||||
enabled = true # Enable the QEMU guest agent
|
||||
}
|
||||
|
||||
stop_on_destroy = true # Ensure VM is stopped gracefully when destroyed
|
||||
stop_on_destroy = true # Ensure VM is stopped gracefully when destroyed
|
||||
|
||||
|
||||
clone {
|
||||
vm_id = local.selected_instance.vmid # ID of the source template
|
||||
vm_id = local.selected_instance.vmid # ID of the source template
|
||||
node_name = local.selected_instance.crispy_name # Node of the source template
|
||||
}
|
||||
|
||||
bios = var.vm_bios # BIOS type (e.g., seabios or ovmf)
|
||||
machine = var.vm_machine # Machine type (e.g., q35)
|
||||
bios = var.vm_bios # BIOS type (e.g., seabios or ovmf)
|
||||
machine = var.vm_machine # Machine type (e.g., q35)
|
||||
|
||||
cpu {
|
||||
cores = var.vm_cpu # Number of CPU cores
|
||||
type = "host" # Use host CPU type for best compatibility/performance
|
||||
cores = var.vm_cpu # Number of CPU cores
|
||||
type = "host" # Use host CPU type for best compatibility/performance
|
||||
}
|
||||
|
||||
memory {
|
||||
dedicated = var.vm_ram # RAM in MB
|
||||
dedicated = var.vm_ram # RAM in MB
|
||||
}
|
||||
|
||||
disk {
|
||||
datastore_id = var.node_datastore # Datastore to hold the disk
|
||||
interface = "scsi0" # Primary disk interface
|
||||
size = var.vm_size
|
||||
interface = "scsi0" # Primary disk interface
|
||||
size = var.vm_size
|
||||
}
|
||||
|
||||
|
||||
initialization {
|
||||
user_data_file_id = proxmox_virtual_environment_file.cloud_config.id # Link the cloud-init file
|
||||
datastore_id = var.node_datastore
|
||||
interface = "scsi1" # Separate interface for cloud-init
|
||||
interface = "scsi1" # Separate interface for cloud-init
|
||||
ip_config {
|
||||
ipv4 {
|
||||
address = "dhcp" # Get IP via DHCP
|
||||
address = "dhcp" # Get IP via DHCP
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
network_device {
|
||||
bridge = var.bridge # Use the default bridge
|
||||
bridge = var.bridge # Use the default bridge
|
||||
}
|
||||
|
||||
lifecycle {
|
||||
ignore_changes = [ # Ignore initialization section after first depoloyment for idempotency
|
||||
ignore_changes = [ # Ignore initialization section after first depoloyment for idempotency
|
||||
initialization
|
||||
]
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ terraform {
|
||||
proxmox = {
|
||||
source = "bpg/proxmox"
|
||||
version = "0.106.0"
|
||||
#url = https://registry.terraform.io/providers/bpg/proxmox/latest/docs/guides/clone-vm
|
||||
#url = https://registry.terraform.io/providers/bpg/proxmox/latest/docs/guides/clone-vm
|
||||
}
|
||||
aws = {
|
||||
source = "hashicorp/aws"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
variable "pm_api_url" { default = "https://192.168.10.201:8006/api2/json" }
|
||||
variable "pm_api_token" { default = "terraform@pve!provider=760580c4-5c1f-462b-986a-dd244c6c95f2" }
|
||||
|
||||
variable "storage" { default = "hlst" }
|
||||
variable "bridge" { default = "vmbr0" }
|
||||
variable "storage" { default = "hlst" }
|
||||
variable "bridge" { default = "vmbr0" }
|
||||
|
||||
variable "os_type" {
|
||||
default = "alpine"
|
||||
@@ -11,11 +11,11 @@ variable "os_type" {
|
||||
variable "instance_configs" {
|
||||
type = list(object({
|
||||
crispy_name = string
|
||||
vmid = string
|
||||
vmid = string
|
||||
}))
|
||||
default = [
|
||||
{ crispy_name = "snap", vmid = "9002" },
|
||||
{ crispy_name = "crackle", vmid = "9000" },
|
||||
{ crispy_name = "snap", vmid = "902" },
|
||||
{ crispy_name = "crackle", vmid = "901" },
|
||||
{ crispy_name = "pop", vmid = "900" }
|
||||
]
|
||||
}
|
||||
@@ -25,11 +25,11 @@ variable "clone_count" {
|
||||
default = 1
|
||||
}
|
||||
|
||||
variable "vm_count" { default = 1 }
|
||||
variable "vm_count" { default = 1 }
|
||||
variable "name_prefix" { default = "dev" }
|
||||
variable "vm_ram" { default = 2048 }
|
||||
variable "vm_cpu" { default = 1 }
|
||||
variable "vm_size" { default = 10 }
|
||||
variable "vm_ram" { default = 2048 }
|
||||
variable "vm_cpu" { default = 1 }
|
||||
variable "vm_size" { default = 10 }
|
||||
variable "vm_bios" {
|
||||
description = "Type of BIOS used for the VM"
|
||||
type = string
|
||||
@@ -48,57 +48,57 @@ variable "vm_tags" {
|
||||
default = ["test", "terraform"]
|
||||
}
|
||||
|
||||
variable "ipconfig0" { default = "ip=dhcp" }
|
||||
variable "ipconfig0" { default = "ip=dhcp" }
|
||||
|
||||
variable "access_key" {
|
||||
type = string
|
||||
type = string
|
||||
default = "GK242d456c0692a9d4cc102206"
|
||||
}
|
||||
|
||||
variable "secret_key" {
|
||||
type = string
|
||||
type = string
|
||||
default = "1d7e22b7a8892cb11b569017659aa511b37b53287c4d1699c310d9f8ac76df09"
|
||||
}
|
||||
|
||||
variable "region" {
|
||||
type = string
|
||||
type = string
|
||||
default = "garage"
|
||||
}
|
||||
|
||||
variable "endpoints_s3" {
|
||||
type = string
|
||||
description = "S3 endpoint"
|
||||
default = "http://192.168.10.109:3909"
|
||||
default = "http://192.168.10.109:3909"
|
||||
}
|
||||
|
||||
variable "skip_credentials_validation" {
|
||||
type = bool
|
||||
default = true
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "skip_requesting_account_id" {
|
||||
type = bool
|
||||
default = true
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "skip_metadata_api_check" {
|
||||
type = bool
|
||||
default = true
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "skip_region_validation" {
|
||||
type = bool
|
||||
default = true
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "use_path_style" {
|
||||
type = bool
|
||||
default = true
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "use_lockfile" {
|
||||
type = bool
|
||||
default = true
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "vm_name" {
|
||||
|
||||
@@ -58,21 +58,21 @@ resource "proxmox_virtual_environment_file" "cloud_config" {
|
||||
}
|
||||
|
||||
resource "proxmox_virtual_environment_vm" "ubuntu_22_minimal_template" {
|
||||
name = var.vm_name # VM name
|
||||
node_name = var.node_name # Proxmox node to deploy the VM
|
||||
tags = var.vm_tags # Optional VM tags for categorization
|
||||
name = var.vm_name # VM name
|
||||
node_name = var.node_name # Proxmox node to deploy the VM
|
||||
tags = var.vm_tags # Optional VM tags for categorization
|
||||
|
||||
agent {
|
||||
enabled = true # Enable the QEMU guest agent
|
||||
enabled = true # Enable the QEMU guest agent
|
||||
}
|
||||
|
||||
stop_on_destroy = true # Ensure VM is stopped gracefully when destroyed
|
||||
stop_on_destroy = true # Ensure VM is stopped gracefully when destroyed
|
||||
|
||||
disk {
|
||||
datastore_id = var.node_datastore # Datastore to hold the disk
|
||||
interface = "scsi0" # Primary disk interface
|
||||
size = var.vm_size
|
||||
file_id = "local:iso/ubuntu-22.04-minimal-cloudimg-amd64.img"
|
||||
interface = "scsi0" # Primary disk interface
|
||||
size = var.vm_size
|
||||
file_id = "local:iso/ubuntu-22.04-minimal-cloudimg-amd64.img"
|
||||
}
|
||||
|
||||
efi_disk {
|
||||
@@ -80,39 +80,39 @@ resource "proxmox_virtual_environment_vm" "ubuntu_22_minimal_template" {
|
||||
type = "4m"
|
||||
}
|
||||
|
||||
bios = var.vm_bios # BIOS type (e.g., seabios or ovmf)
|
||||
machine = var.vm_machine # Machine type (e.g., q35)
|
||||
bios = var.vm_bios # BIOS type (e.g., seabios or ovmf)
|
||||
machine = var.vm_machine # Machine type (e.g., q35)
|
||||
|
||||
cpu {
|
||||
cores = var.vm_cpu # Number of CPU cores
|
||||
type = "host" # Use host CPU type for best compatibility/performance
|
||||
cores = var.vm_cpu # Number of CPU cores
|
||||
type = "host" # Use host CPU type for best compatibility/performance
|
||||
}
|
||||
|
||||
memory {
|
||||
dedicated = var.vm_ram # RAM in MB
|
||||
dedicated = var.vm_ram # RAM in MB
|
||||
}
|
||||
|
||||
initialization {
|
||||
user_data_file_id = proxmox_virtual_environment_file.cloud_config.id # Link the cloud-init file
|
||||
datastore_id = var.node_datastore
|
||||
interface = "scsi1" # Separate interface for cloud-init
|
||||
interface = "scsi1" # Separate interface for cloud-init
|
||||
ip_config {
|
||||
ipv4 {
|
||||
address = "dhcp" # Get IP via DHCP
|
||||
address = "dhcp" # Get IP via DHCP
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
network_device {
|
||||
bridge = var.bridge # Use the default bridge
|
||||
bridge = var.bridge # Use the default bridge
|
||||
}
|
||||
|
||||
operating_system {
|
||||
type = "l26" # Linux 2.6+ kernel
|
||||
type = "l26" # Linux 2.6+ kernel
|
||||
}
|
||||
|
||||
lifecycle {
|
||||
ignore_changes = [ # Ignore initialization section after first depoloyment for idempotency
|
||||
ignore_changes = [ # Ignore initialization section after first depoloyment for idempotency
|
||||
initialization
|
||||
]
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ terraform {
|
||||
proxmox = {
|
||||
source = "bpg/proxmox"
|
||||
version = "0.106.0"
|
||||
#url = https://registry.terraform.io/providers/bpg/proxmox/latest/docs/guides/clone-vm
|
||||
#url = https://registry.terraform.io/providers/bpg/proxmox/latest/docs/guides/clone-vm
|
||||
}
|
||||
aws = {
|
||||
source = "hashicorp/aws"
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
variable "pm_api_url" { default = "https://192.168.10.201:8006/api2/json" }
|
||||
variable "pm_api_token" { default = "terraform@pve!provider=760580c4-5c1f-462b-986a-dd244c6c95f2" }
|
||||
|
||||
variable "storage" { default = "hlst" }
|
||||
variable "bridge" { default = "vmbr0" }
|
||||
variable "storage" { default = "hlst" }
|
||||
variable "bridge" { default = "vmbr0" }
|
||||
|
||||
|
||||
variable "instance_configs" {
|
||||
type = list(object({
|
||||
crispy_name = string
|
||||
vmid = string
|
||||
vmid = string
|
||||
}))
|
||||
default = [
|
||||
{ crispy_name = "snap", vmid = "9002" },
|
||||
@@ -22,11 +22,11 @@ variable "clone_count" {
|
||||
default = 1
|
||||
}
|
||||
|
||||
variable "vm_count" { default = 1 }
|
||||
variable "vm_count" { default = 1 }
|
||||
variable "name_prefix" { default = "dev" }
|
||||
variable "vm_ram" { default = 2048 }
|
||||
variable "vm_cpu" { default = 1 }
|
||||
variable "vm_size" { default = 10 }
|
||||
variable "vm_ram" { default = 2048 }
|
||||
variable "vm_cpu" { default = 1 }
|
||||
variable "vm_size" { default = 10 }
|
||||
variable "vm_bios" {
|
||||
description = "Type of BIOS used for the VM"
|
||||
type = string
|
||||
@@ -45,57 +45,57 @@ variable "vm_tags" {
|
||||
default = ["test", "terraform"]
|
||||
}
|
||||
|
||||
variable "ipconfig0" { default = "ip=dhcp" }
|
||||
variable "ipconfig0" { default = "ip=dhcp" }
|
||||
|
||||
variable "access_key" {
|
||||
type = string
|
||||
type = string
|
||||
default = "GK242d456c0692a9d4cc102206"
|
||||
}
|
||||
|
||||
variable "secret_key" {
|
||||
type = string
|
||||
type = string
|
||||
default = "1d7e22b7a8892cb11b569017659aa511b37b53287c4d1699c310d9f8ac76df09"
|
||||
}
|
||||
|
||||
variable "region" {
|
||||
type = string
|
||||
type = string
|
||||
default = "garage"
|
||||
}
|
||||
|
||||
variable "endpoints_s3" {
|
||||
type = string
|
||||
description = "S3 endpoint"
|
||||
default = "http://192.168.10.109:3909"
|
||||
default = "http://192.168.10.109:3909"
|
||||
}
|
||||
|
||||
variable "skip_credentials_validation" {
|
||||
type = bool
|
||||
default = true
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "skip_requesting_account_id" {
|
||||
type = bool
|
||||
default = true
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "skip_metadata_api_check" {
|
||||
type = bool
|
||||
default = true
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "skip_region_validation" {
|
||||
type = bool
|
||||
default = true
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "use_path_style" {
|
||||
type = bool
|
||||
default = true
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "use_lockfile" {
|
||||
type = bool
|
||||
default = true
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "vm_name" {
|
||||
|
||||
@@ -3,7 +3,7 @@ terraform {
|
||||
proxmox = {
|
||||
source = "bpg/proxmox"
|
||||
version = "0.106.0"
|
||||
#url = https://registry.terraform.io/providers/bpg/proxmox/latest/docs/guides/clone-vm
|
||||
#url = https://registry.terraform.io/providers/bpg/proxmox/latest/docs/guides/clone-vm
|
||||
}
|
||||
aws = {
|
||||
source = "hashicorp/aws"
|
||||
@@ -15,12 +15,18 @@ terraform {
|
||||
provider "proxmox" {
|
||||
endpoint = var.pm_api_url
|
||||
api_token = var.pm_api_token
|
||||
insecure = true
|
||||
|
||||
insecure = true
|
||||
# === FIX THIS ===
|
||||
ssh {
|
||||
agent = true
|
||||
username = "root"
|
||||
password = "Ishimaru17"
|
||||
}
|
||||
}
|
||||
|
||||
provider "aws" {
|
||||
region = "garage"
|
||||
access_key = "GK242d456c0692a9d4cc102206"
|
||||
access_key = "GK242d456c0692a9d4cc102206"
|
||||
secret_key = "1d7e22b7a8892cb11b569017659aa511b37b53287c4d1699c310d9f8ac76df09"
|
||||
# shared_credentials_files = ["$HOME/.aws/credentials"]
|
||||
# shared_credentials_files = ["$HOME/.aws/credentials"]
|
||||
}
|
||||
@@ -18,8 +18,8 @@ variable "instance" {
|
||||
vm_size = optional(string)
|
||||
vm_tags = optional(list(string))
|
||||
})
|
||||
default = null
|
||||
nullable = true
|
||||
default = null
|
||||
nullable = true
|
||||
description = "Used only when instance_mode = single."
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
"main":
|
||||
"node_name": "pop"
|
||||
"tags":
|
||||
- "agentic"
|
||||
- "terraform"
|
||||
- "docker"
|
||||
- "n8n"
|
||||
- "ip-192-168-10-106"
|
||||
- "agentic"
|
||||
- "terraform"
|
||||
- "docker"
|
||||
- "n8n"
|
||||
- "ip-192-168-10-106"
|
||||
"vm_name": "n8n-01"
|
||||
|
||||
Reference in New Issue
Block a user