From a6ca011a076d319613394ebe464e089f2578d2e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Limpinho?= <53994778+TomasLimpinho@users.noreply.github.com> Date: Mon, 25 Aug 2025 18:40:53 +0100 Subject: [PATCH 1/5] dockerfile for runner --- documentation/Dockerfile | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 documentation/Dockerfile diff --git a/documentation/Dockerfile b/documentation/Dockerfile new file mode 100644 index 0000000..74d0492 --- /dev/null +++ b/documentation/Dockerfile @@ -0,0 +1,23 @@ +FROM ghcr.io/opentofu/opentofu:1.9-minimal AS tofu + +FROM ubuntu:24.04 + +# Copy the tofu binary +COPY --from=tofu /usr/local/bin/tofu /usr/local/bin/tofu + +# Install dependencies +RUN apt-get update && apt-get install -y \ + git \ + curl \ + nodejs \ + npm \ + unzip \ + && rm -rf /var/lib/apt/lists/* + +RUN curl -L -o /tmp/bw.zip https://github.com/bitwarden/cli/releases/download/v1.22.1/bw-linux-1.22.1.zip \ + && unzip /tmp/bw.zip -d /usr/local/bin \ + && chmod +x /usr/local/bin/bw \ + && rm /tmp/bw.zip + + +WORKDIR /workspace \ No newline at end of file From d416cda06e5d0a5a54c0bee8e14d0f8beb0c66ba Mon Sep 17 00:00:00 2001 From: fenix-gitea-admin Date: Tue, 26 Aug 2025 11:32:00 +0000 Subject: [PATCH 2/5] Update proxmox.variables.tf --- proxmox.variables.tf | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/proxmox.variables.tf b/proxmox.variables.tf index b4de549..7e4b0ee 100644 --- a/proxmox.variables.tf +++ b/proxmox.variables.tf @@ -32,3 +32,17 @@ variable "proxmox_apikey" { variable "node_name" { default = "fenix" } + +variable "proxmox_VM_username" +{ + description = "Proxmox VM user name" + type = string + sensitive = true +} + +variable "proxmox_VM_password" +{ + description = "Proxmox VM password" + type = string + sensitive = true +} \ No newline at end of file From 777c8cd299b24d8d13022f3ec19dc03783c12faf Mon Sep 17 00:00:00 2001 From: fenix-gitea-admin Date: Tue, 26 Aug 2025 12:20:01 +0000 Subject: [PATCH 3/5] Update proxmox.tf --- proxmox.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proxmox.tf b/proxmox.tf index 3981b89..d120a4f 100644 --- a/proxmox.tf +++ b/proxmox.tf @@ -34,7 +34,7 @@ resource "proxmox_virtual_environment_file" "cloud_init_yaml" { #cloud-config users: - default - - name: testeuser + - name: ${var.proxmox_VM_username} groups: sudo shell: /bin/bash sudo: ALL=(ALL) NOPASSWD:ALL @@ -43,7 +43,7 @@ resource "proxmox_virtual_environment_file" "cloud_init_yaml" { chpasswd: list: | - testeuser:testepassword + ${var.proxmox_VM_username}:${var.proxmox_VM_password} expire: false package_update: true From 4ccb20b3c0d937ef68157abcd3e6264adeff6659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Limpinho?= <53994778+TomasLimpinho@users.noreply.github.com> Date: Tue, 26 Aug 2025 14:17:45 +0100 Subject: [PATCH 4/5] multiple vms --- proxmox.tf | 78 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 70 insertions(+), 8 deletions(-) diff --git a/proxmox.tf b/proxmox.tf index d120a4f..e39e13a 100644 --- a/proxmox.tf +++ b/proxmox.tf @@ -86,11 +86,11 @@ resource "proxmox_virtual_environment_vm" "proxmox-kubernetes-VM-template" { } # Configuração do disco rígido - disk { - datastore_id = "local-lvm" - interface = "scsi1" - size = 64 - } + #disk { + # datastore_id = "local-lvm" + # interface = "scsi1" + # size = 64 + #} disk { datastore_id = "local-lvm" @@ -116,14 +116,76 @@ initialization { } -resource "proxmox_virtual_environment_vm" "VM-Kubernetes-01" { +resource "proxmox_virtual_environment_vm" "k8s_vms" { + for_each = { for vm in var.proxmox_k8s_vms : vm.name => vm } depends_on = [proxmox_virtual_environment_vm.proxmox-kubernetes-VM-template] - name = "VM-Kubernetes-01" - node_name = "fenix" + name = each.value.name + node_name = each.value.node_name + vm_id = each.value.vm_id + + cpu { + cores = each.value.cores + } + + memory { + dedicated = each.value.memory + } + + disk { + datastore_id = each.value.datastore + size = each.value.disk_size + interface = "scsi1" + } clone { vm_id = proxmox_virtual_environment_vm.proxmox-kubernetes-VM-template.id } + + + initialization { + ip_config { + ipv4 { + address = each.value.ip + gateway = each.value.gateway + } + } + + user_data = < 0 ~} + + %{ for u in each.value.extra_users ~} + - name: ${u.name} + groups: [${join(", ", u.groups)}] + shell: /bin/bash + sudo: ALL=(ALL) NOPASSWD:ALL + %{ endfor ~} + + chpasswd: + list: | + %{ for u in each.value.extra_users ~} + ${u.name}:${u.password} + %{ endfor ~} + expire: false + + %{ endif ~} + runcmd: + %{ if length(each.value.extra_runcmd) > 0 ~} + %{ for cmd in each.value.extra_runcmd ~} + - ${cmd} + %{ endfor ~} + %{ endif ~} + EOF + } + + agent { enabled = true } From c8989775c91db8aa2d99ca962fe044778dcd2031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Limpinho?= <53994778+TomasLimpinho@users.noreply.github.com> Date: Tue, 26 Aug 2025 14:19:56 +0100 Subject: [PATCH 5/5] not saved file --- proxmox.variables.tf | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/proxmox.variables.tf b/proxmox.variables.tf index 7e4b0ee..948ad66 100644 --- a/proxmox.variables.tf +++ b/proxmox.variables.tf @@ -33,16 +33,22 @@ variable "node_name" { default = "fenix" } -variable "proxmox_VM_username" -{ - description = "Proxmox VM user name" - type = string - sensitive = true -} - -variable "proxmox_VM_password" -{ - description = "Proxmox VM password" - type = string - sensitive = true +# Lista de VMs (override de valores específicos) +variable "proxmox_k8s_vms" { + type = list(object({ + name = string + vm_id = number + node_name = string + ip = string + cores = optional(number) + memory = optional(number) + disk_size = optional(number) + extra_users = optional(list(object({ + name = string + password = string + groups = list(string) + }))) + extra_packages = optional(list(string)) + extra_runcmd = optional(list(string)) + })) } \ No newline at end of file