32 Commits

Author SHA1 Message Date
a4b33a570b secrets 2025-10-23 08:50:34 +01:00
c7c1388112 Add secrets/iac.vaultwarden-link 2025-10-23 07:44:00 +00:00
b875d6428b Add secrets/iac.proxmox.ssh.link 2025-10-23 07:43:24 +00:00
e1b0d702c5 Update secrets/proxmox.secrets.tfvars 2025-10-23 07:41:14 +00:00
a7f3b6d7e1 [deploy-opentofu]
[deploy-opentofu]
2025-10-21 19:25:08 +00:00
fcc7c9814a Update proxmox.tf 2025-10-21 19:24:32 +00:00
cc441d8ad8 [deploy-opentofu]
[deploy-opentofu]
2025-10-16 09:52:09 +00:00
e71295794f [deploy-opentofu]
[deploy-opentofu]
2025-10-16 09:24:35 +00:00
7c46db0253 [deploy-opentofu]
[deploy-opentofu]
2025-10-15 21:40:03 +00:00
218ca3fc2f [deploy-opentofu]
[deploy-opentofu]
2025-10-15 21:32:42 +00:00
58d080dadd a 2025-10-15 21:19:39 +00:00
f797aa6d8b [deploy-opentofu] 2025-10-15 21:19:11 +00:00
8b16085acf [deploy-opentofu] 2025-10-15 13:22:39 +00:00
47102e563d [deploy-opentofu] 2025-10-15 13:17:55 +00:00
d9f9620123 [deploy-opentofu] 2025-10-15 12:54:20 +00:00
905b749a09 [deploy-opentofu]
[deploy-opentofu]
2025-10-15 12:24:17 +00:00
992a949b6d [deploy-opentofu]
[deploy-opentofu]
2025-10-15 10:29:20 +00:00
387702c3c3 [deploy-opentofu]
[deploy-opentofu]
2025-10-15 10:24:21 +00:00
1bf18d13a3 [deploy-opentofu]
[deploy-opentofu]
2025-10-15 10:07:32 +00:00
de1ea64e04 [deploy-opentofu]
[deploy-opentofu]
2025-10-15 10:02:47 +00:00
9edc3fe55d [deploy-opentofu]
[deploy-opentofu]
2025-10-14 22:01:28 +00:00
fd0763593f Update vaultwarden.tf 2025-10-12 21:41:12 +00:00
fc5ae6402f [deploy-opentofu]
[deploy-opentofu]
2025-10-12 17:13:27 +00:00
5412e499f2 [deploy-opentofu]
[deploy-opentofu]
2025-10-12 17:08:08 +00:00
fa25d7073b [deploy-opentofu] 2025-10-12 17:02:14 +00:00
2e81ffcdb1 [deploy-opentofu]
[deploy-opentofu]
2025-10-12 16:54:12 +00:00
8d7636a925 Update documentation/Dockerfile 2025-10-12 10:51:57 +00:00
49c5457547 [deploy-opentofu]
[deploy-opentofu]
2025-10-12 09:37:42 +00:00
9b00c6d3f4 [deploy-opentofu]
[deploy-opentofu]
2025-10-12 09:12:36 +00:00
7c1d265e75 [deploy-opentofu]
[deploy-opentofu]
2025-10-12 09:08:10 +00:00
b6c3b5e80f [deploy-opentofu]
[deploy-opentofu]
2025-10-12 09:03:21 +00:00
1f41c3dd53 [deploy-opentofu]
[deploy-opentofu]
2025-10-12 08:59:28 +00:00
10 changed files with 59 additions and 29 deletions

View File

@ -65,7 +65,8 @@ jobs:
- name: Install dante-server - name: Install dante-server
run: | run: |
apt-get install -y dante-server openssl libssl1.1 apt-get install -y dante-server openssl
#libssl1.1
- name: Configure dante-server - name: Configure dante-server
@ -92,6 +93,7 @@ jobs:
- name: vaultwarden urls as secrets - name: vaultwarden urls as secrets
run: | run: |
echo "config" echo "config"
echo "$VAULTWARDEN_LINK"
bw config server $VAULTWARDEN_LINK bw config server $VAULTWARDEN_LINK
echo "login" echo "login"
bw login --apikey bw login --apikey
@ -99,6 +101,7 @@ jobs:
BW_SESSION=$(bw unlock "$BW_PASSWORD" --raw) BW_SESSION=$(bw unlock "$BW_PASSWORD" --raw)
echo "$BW_SESSION" echo "$BW_SESSION"
echo "getting item" echo "getting item"
bw get item "iac.proxmox.ssh.link" --session "$BW_SESSION"
bw get item "iac.proxmox.ssh.link" --session "$BW_SESSION" | jq -r '.notes' > "proxmox-ssh-link.txt" bw get item "iac.proxmox.ssh.link" --session "$BW_SESSION" | jq -r '.notes' > "proxmox-ssh-link.txt"
- name: Start cloudflared Access TCP -> SOCKS5 (background) - name: Start cloudflared Access TCP -> SOCKS5 (background)
@ -165,7 +168,7 @@ jobs:
elif [ "$type" == "note" ]; then elif [ "$type" == "note" ]; then
echo "note get" echo "note get"
bw get item "$name" --session "$BW_SESSION" | jq -r '.notes' > "$output" bw get item "$name" --session "$BW_SESSION" | jq -r '.notes' > "$output"
cat $output #cat $output
fi fi
done done

View File

@ -1,23 +1,31 @@
FROM ghcr.io/opentofu/opentofu:1.9-minimal AS tofu FROM ghcr.io/opentofu/opentofu:1.9-minimal AS tofu
FROM ubuntu:24.04 FROM ubuntu:24.04
# Copy the tofu binary # Copy the tofu binary
COPY --from=tofu /usr/local/bin/tofu /usr/local/bin/tofu COPY --from=tofu /usr/local/bin/tofu /usr/local/bin/tofu
# Install dependencies
# Atualizar pacotes e instalar dependências básicas
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
git \
curl \ curl \
nodejs \ git \
npm \
unzip \ unzip \
&& rm -rf /var/lib/apt/lists/* jq \
gnupg \
ca-certificates \
&& 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 \ # Instalar Node.js 18 via NodeSource
&& unzip /tmp/bw.zip -d /usr/local/bin \ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
&& chmod +x /usr/local/bin/bw \ apt-get install -y nodejs
&& rm /tmp/bw.zip
# Verificar versões (opcional para debug)
RUN node -v && npm -v
RUN npm install -g @bitwarden/cli
WORKDIR /workspace WORKDIR /workspace

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from ruamel.yaml import YAML from ruamel.yaml import YAML
import sys import sys
import json import json
from collections.abc import Mapping from collections.abc import Mapping

View File

@ -120,7 +120,7 @@ resource "proxmox_virtual_environment_vm" "proxmox-kubernetes-VM-template" {
# Configuração da interface de rede # Configuração da interface de rede
network_device { network_device {
bridge = "vmbr0" bridge = "vmbr0" # rede de gestão para comunicação com Cluster A
} }
initialization { initialization {
@ -132,6 +132,7 @@ initialization {
address = "dhcp" address = "dhcp"
} }
} }
user_data_file_id = proxmox_virtual_environment_file.cloud_init_yaml.id user_data_file_id = proxmox_virtual_environment_file.cloud_init_yaml.id
} }
} }

View File

@ -40,6 +40,8 @@ variable "proxmox_k8s_vms" {
vm_id = number vm_id = number
node_name = string node_name = string
ip = string ip = string
ip2 = string
ip3 = string
cores = optional(number) cores = optional(number)
memory = optional(number) memory = optional(number)
data_store = optional(string) data_store = optional(string)

View File

@ -0,0 +1,13 @@
[master]
master1 ansible_host=192.168.1.99 ansible_user=user ansible_ssh_pass=pass ansible_ssh_common_args='-o StrictHostKeyChecking=no'
[workers]
worker-192-168-1-101 ansible_host=192.168.1.101 ansible_user=user ansible_ssh_pass=pass ansible_ssh_common_args='-o StrictHostKeyChecking=no'

View File

@ -0,0 +1 @@
proxmox-ssh.example.com

View File

@ -0,0 +1 @@
https://vaultwarden.example.com

View File

@ -1,6 +1,6 @@
proxmox_server = "proxmox.example.com" #proxmox_server = "proxmox.example.com"
PM_API_TOKEN_ID = "tokenid" #PM_API_TOKEN_ID = "tokenid"
PM_API_TOKEN_SECRET = "tokensecret" #PM_API_TOKEN_SECRET = "tokensecret"
# tokenid is read automatically from PM_API_TOKEN_ID # tokenid is read automatically from PM_API_TOKEN_ID
# token is read automatically from PM_API_TOKEN_SECRET # token is read automatically from PM_API_TOKEN_SECRET
@ -20,6 +20,7 @@ proxmox_k8s_vms = [
vm_id = 3001 vm_id = 3001
node_name = "node" node_name = "node"
ip = "192.168.1.99/24" ip = "192.168.1.99/24"
ip3 = "192.168.1.199/24"
cores = 2 cores = 2
memory = 2000 memory = 2000
disk_size = 32 disk_size = 32
@ -33,13 +34,14 @@ proxmox_k8s_vms = [
} }
] ]
extra_packages = [] extra_packages = []
extra_runcmd = [] extra_runcmd = ["sudo ip addr add 192.168.1.199/24 dev eth0"]
}, },
{ {
name = "k8s-worker-01" name = "k8s-worker-01"
vm_id = 3002 vm_id = 3002
node_name = "node" node_name = "node"
ip = "192.168.1.101/24" ip = "192.168.1.101/24"
ip3 = "192.168.1.201/24"
cores = 1 cores = 1
memory = 2000 memory = 2000
disk_size = 32 disk_size = 32
@ -53,6 +55,6 @@ proxmox_k8s_vms = [
} }
] ]
extra_packages = [] extra_packages = []
extra_runcmd = [] extra_runcmd = ["sudo ip addr add 192.168.1.201/24 dev eth0"]
}, },
] ]

View File

@ -16,6 +16,13 @@ resource "vaultwarden_account_register" "vaultwarden-acount-fenix" {
password = var.vaultwarden_master_password password = var.vaultwarden_master_password
} }
resource "bitwarden_item_login" "administrative-user" {
name = "teste"
username = "teste"
password = "teste"
collection_ids = [vaultwarden_organization_collection.vaultwarden-collection-iac.id]
}
resource "vaultwarden_organization" "vaultwarden-organization-fenix-iac" { resource "vaultwarden_organization" "vaultwarden-organization-fenix-iac" {
name = "fenix-iac" name = "fenix-iac"
} }
@ -25,13 +32,6 @@ resource "vaultwarden_organization_collection" "vaultwarden-collection-iac" {
name = "iac-collection" name = "iac-collection"
} }
resource "bitwarden_item_login" "administrative-user" {
name = "teste"
username = "teste"
password = "teste"
collection_ids = [vaultwarden_organization_collection.vaultwarden-collection-iac.id]
}
resource "bitwarden_item_secure_note" "hosts-ini" { resource "bitwarden_item_secure_note" "hosts-ini" {
name = "iac.ansible.hosts.ini" name = "iac.ansible.hosts.ini"
@ -44,16 +44,15 @@ EOT
} }
locals{ locals{
hosts_ini = <<EOT hosts_ini = <<EOT
[master] [master]
master ansible_host=${var.proxmox_k8s_vms[0].ip} ansible_user=${var.proxmox_k8s_vms[0].extra_users[0].name} ansible_ssh_pass=${var.proxmox_k8s_vms[0].extra_users[0].password} master1 ansible_host=${split("/", var.proxmox_k8s_vms[0].ip)[0]} ansible_user=${var.proxmox_k8s_vms[0].extra_users[0].name} ansible_ssh_pass=${var.proxmox_k8s_vms[0].extra_users[0].password} ansible_ssh_common_args='-o StrictHostKeyChecking=no'
[workers] [workers]
%{ for i, vm in var.proxmox_k8s_vms ~} %{ for i, vm in var.proxmox_k8s_vms ~}
%{ if i != 0 } %{ if i != 0 }
worker-${replace(vm.ip, ".", "-")} ansible_host=${vm.ip} ansible_user=${vm.extra_users[0].name} ansible_ssh_pass=${vm.extra_users[0].password} worker-${replace(split("/", vm.ip)[0], ".", "-")} ansible_host=${split("/", vm.ip)[0]} ansible_user=${vm.extra_users[0].name} ansible_ssh_pass=${vm.extra_users[0].password} ansible_ssh_common_args='-o StrictHostKeyChecking=no'
%{ endif } %{ endif }
%{ endfor } %{ endfor }