forked from catalin/fukuops
feat: migrate terraform from https://gitlab.com/fukurokuju/vm-foundation
This commit is contained in:
parent
1cc30ed503
commit
b9d8cd04d4
11 changed files with 230 additions and 0 deletions
13
.gitignore
vendored
13
.gitignore
vendored
|
|
@ -1,3 +1,16 @@
|
|||
**/.terraform/*
|
||||
*.tfstate
|
||||
*.tfstate.*
|
||||
crash.*.log
|
||||
*.tfvars
|
||||
*.tfvars.json
|
||||
override.tf
|
||||
override.tf.json
|
||||
*_override.tf
|
||||
*_override.tf.json
|
||||
.terraformrc
|
||||
terraform.rc
|
||||
*.retry
|
||||
.idea/
|
||||
secrets.yaml
|
||||
.env
|
||||
45
tofu/modules/proxmox-vm/main.tf
Normal file
45
tofu/modules/proxmox-vm/main.tf
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
terraform {
|
||||
required_providers {
|
||||
proxmox = {
|
||||
source = "thegameprofi/proxmox"
|
||||
version = "2.9.15"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "proxmox_vm_qemu" "vm" {
|
||||
name = var.vm_name
|
||||
target_node = var.node_name
|
||||
vmid = var.vm_id
|
||||
clone = var.cloud_init_template
|
||||
os_type = "cloudinit"
|
||||
qemu_os = "other"
|
||||
ipconfig0 = var.ipconfig0
|
||||
cores = var.core_count
|
||||
sockets = 1
|
||||
pool = "k3s"
|
||||
memory = var.memory
|
||||
ciuser = var.ci_username
|
||||
agent = 0
|
||||
serial {
|
||||
id = 0
|
||||
type = "socket"
|
||||
}
|
||||
disk {
|
||||
size = "50G"
|
||||
storage = var.disk_storage_name
|
||||
type = "scsi"
|
||||
}
|
||||
network {
|
||||
bridge = var.network_bridge_name
|
||||
firewall = false
|
||||
link_down = false
|
||||
model = "virtio"
|
||||
mtu = 0
|
||||
queues = 0
|
||||
rate = 0
|
||||
tag = -1
|
||||
}
|
||||
sshkeys = var.ssh_keys
|
||||
nameserver = "192.168.1.7 192.168.1.3"
|
||||
}
|
||||
66
tofu/modules/proxmox-vm/variables.tf
Normal file
66
tofu/modules/proxmox-vm/variables.tf
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
variable "vm_name" {
|
||||
description = "Name of the VM"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "node_name" {
|
||||
description = "Name of the Proxmox node"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "vm_id" {
|
||||
description = "ID of the new VM"
|
||||
type = number
|
||||
}
|
||||
|
||||
variable "cloud_init_template" {
|
||||
description = "Cloud-init enabled template to be cloned"
|
||||
type = string
|
||||
default = "ci-debian12"
|
||||
}
|
||||
|
||||
variable "ipconfig0" {
|
||||
description = "Default inet configuration"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "ci_username" {
|
||||
description = "Cloud-init username"
|
||||
type = string
|
||||
default = "ci"
|
||||
}
|
||||
|
||||
|
||||
variable "memory" {
|
||||
description = "Available RAM, in MB"
|
||||
type = number
|
||||
default = 512
|
||||
}
|
||||
|
||||
variable "core_count" {
|
||||
description = "Available cores per socket"
|
||||
type = number
|
||||
default = 2
|
||||
|
||||
}
|
||||
|
||||
variable "network_bridge_name" {
|
||||
description = "Network bridge name"
|
||||
type = string
|
||||
default = "vmbr0"
|
||||
}
|
||||
|
||||
variable "ssh_keys" {
|
||||
description = "SSH public keys to be provisioned"
|
||||
type = string
|
||||
default = <<EOF
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIL++DKyzE0+zM6A4lpjWTNvntQnmEdA6FoOh6jIdsHMT catalin@jupiter
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGreLVacZyxq2EtgievpXgC/L7czKyJa/kWpgqDoPgnA phireh@GenPhireh
|
||||
EOF
|
||||
}
|
||||
|
||||
variable "disk_storage_name" {
|
||||
description = "Disk storage name"
|
||||
type = string
|
||||
default = "storage"
|
||||
}
|
||||
8
tofu/modules/truenas-vm/main.tf
Normal file
8
tofu/modules/truenas-vm/main.tf
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
terraform {
|
||||
required_providers {
|
||||
truenas = {
|
||||
source = "dariusbakunas/truenas"
|
||||
version = "0.11.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
0
tofu/modules/truenas-vm/variables.tf
Normal file
0
tofu/modules/truenas-vm/variables.tf
Normal file
46
tofu/proxmox/.terraform.lock.hcl
generated
Normal file
46
tofu/proxmox/.terraform.lock.hcl
generated
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
# This file is maintained automatically by "tofu init".
|
||||
# Manual edits may be lost in future updates.
|
||||
|
||||
provider "registry.opentofu.org/telmate/proxmox" {
|
||||
version = "2.9.14"
|
||||
constraints = "2.9.14"
|
||||
hashes = [
|
||||
"h1:H/f+LbVyPOLslHLAYnGuMMRqWFZ65K6E3V+MCYgfAyk=",
|
||||
"zh:0d049d33f705e5b814d30028770c084151218439424e99684ce31d7e26a720b5",
|
||||
"zh:20b1c64ed56d81de95f3f37b82b45b4654c0de26670c0e87a474c5cce13cd015",
|
||||
"zh:2946058abd1d8e50e475b9ec39781eb02576b40dbd80f4653fade4493a4514c6",
|
||||
"zh:29e50a25c456f040ce072f23ac57b5b82ebd3b916ca5ae6688332b5ec62adc4a",
|
||||
"zh:3612932306ce5f08db94868f526cbb8c56d0d3c6ebe1c11a83f92bbf94354296",
|
||||
"zh:42d1699b0abebaac82ea5a19f4393541d8bb2741bde204a8ac1028cdc29d1b14",
|
||||
"zh:5ffd5dc567262eb8aafdf2f6eac63f7f21361da9c5d75a3c36b479638a0001b0",
|
||||
"zh:6692ef323e3b89de99934ad731f6a1850525bf8142916ae28ea4e4048d73a787",
|
||||
"zh:a5afc98e9a4038516bb58e788cb77dea67a60dce780dfcd206d7373c5a56b776",
|
||||
"zh:bf902cded709d84fa27fbf91b589c241f2238a6c4924e4e479eebd74320b93a5",
|
||||
"zh:cab0e1e72c9cebcf669fc6f35ec28cb8ab2dffb0237afc8860aa40d23bf8a49f",
|
||||
"zh:e523b99a48beec83d9bc04b2d336266044f9f53514cefb652fe6768611847196",
|
||||
"zh:f593915e8a24829d322d2eaeedcb153328cf9042f0d84f66040dde1be70ede04",
|
||||
"zh:fba1aff541133e2129dfda0160369635ab48503d5c44b8407ce5922ecc15d0bd",
|
||||
]
|
||||
}
|
||||
|
||||
provider "registry.opentofu.org/thegameprofi/proxmox" {
|
||||
version = "2.9.15"
|
||||
constraints = "2.9.15"
|
||||
hashes = [
|
||||
"h1:PPrRxolUV0bwNvWACdbcW0hVjpOcNQkiPKJJk0kcgoM=",
|
||||
"zh:1ffee851e14bd23547dcd0b72d19f703eb8b4f76dcce7a2c65d2eaaab0dbd104",
|
||||
"zh:295f79973e0d3cfe6b5d8cf43d35b88e934137b1333da90dc16076c90b6e2702",
|
||||
"zh:29fa35ab8b53e02060f0d33dc895a5e866bb02c519d89d32b25d3b6ca7d8617a",
|
||||
"zh:2a487a9ad855cd09caeda77a31102307bc68c4f19a0715c6ed5504f20c6de9db",
|
||||
"zh:2a49c0a041a3e9dbc5145c3ae4bee152c62b2533e9062a6c2cca17d4384a76f8",
|
||||
"zh:3e4fbe4775b1a84fadb96602e514451b1624d772a05f36f06003b202bbb5eed3",
|
||||
"zh:58f79e7ad576c016dc8bd07ed2c768df7a8559573acd039d6710a15958ebf2af",
|
||||
"zh:8827bdfb8b75a8b1ce7e1cfebf2005e0a710e45b6c9300abb87e2e70798004b2",
|
||||
"zh:8a1ca1d3fae360faa15139af1af138363fbf01948f9fdb7fe5e5983ecf63b187",
|
||||
"zh:a36e0d3503d82d422388a5ac085fb57f7bb537a8a1ed9477113dee6f0e7de94d",
|
||||
"zh:b46d114574256938e865b0073f385143a085583a07885317ce51965a6c170dbd",
|
||||
"zh:b7ef63fdccd635d741f76d52c77767cbb9b93027fc7b4fdd968a876909480116",
|
||||
"zh:ba2721389bb5536ec075845c836cc8684c1d562573f41e484dec7624254d6cf4",
|
||||
"zh:f4781adf4ee8ceea7b595df6b481c960371413024c3af90a7d9d82bd03e19e60",
|
||||
]
|
||||
}
|
||||
48
tofu/proxmox/main.tf
Normal file
48
tofu/proxmox/main.tf
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
terraform {
|
||||
backend "s3" {
|
||||
bucket = "fuku-terraform"
|
||||
key = "vm-foundation/terraform"
|
||||
region = "us-east-1"
|
||||
}
|
||||
required_providers {
|
||||
proxmox = {
|
||||
source = "thegameprofi/proxmox"
|
||||
version = "2.9.15"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "proxmox" {
|
||||
pm_debug = true
|
||||
}
|
||||
|
||||
module "master1" {
|
||||
source = "../modules/proxmox-vm"
|
||||
vm_id = 3001
|
||||
vm_name = "master1.ramiel.fuku"
|
||||
node_name = "ramiel"
|
||||
ipconfig0 = "ip=192.168.1.31/24,gw=192.168.1.1"
|
||||
memory = 4096
|
||||
core_count = 2
|
||||
}
|
||||
|
||||
module "master2" {
|
||||
source = "../modules/proxmox-vm"
|
||||
vm_id = 3002
|
||||
vm_name = "master2.ireul.fuku"
|
||||
node_name = "ireul"
|
||||
ipconfig0 = "ip=192.168.1.32/24,gw=192.168.1.1"
|
||||
memory = 4096
|
||||
core_count = 2
|
||||
}
|
||||
|
||||
module "master3" {
|
||||
source = "../modules/proxmox-vm"
|
||||
vm_id = 3003
|
||||
vm_name = "master3.ireul.fuku"
|
||||
node_name = "ireul"
|
||||
ipconfig0 = "ip=192.168.1.33/24,gw=192.168.1.1"
|
||||
disk_storage_name = "local-lvm"
|
||||
memory = 4096
|
||||
core_count = 2
|
||||
}
|
||||
4
tofu/proxmox/sample.env
Normal file
4
tofu/proxmox/sample.env
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
PM_USER=
|
||||
PM_PASS=
|
||||
PM_API_URL=
|
||||
TF_VAR_ci_password=
|
||||
0
tofu/proxmox/vars.tf
Normal file
0
tofu/proxmox/vars.tf
Normal file
0
tofu/truenas/main.tf
Normal file
0
tofu/truenas/main.tf
Normal file
0
tofu/truenas/vars.tf
Normal file
0
tofu/truenas/vars.tf
Normal file
Loading…
Add table
Add a link
Reference in a new issue