mirror of
https://gitea.fenix-dev.com/fenix-gitea-admin/iac-opentofu-private.git
synced 2026-03-22 20:49:51 +00:00
Compare commits
46 Commits
8d7636a925
...
fenix-admi
| Author | SHA1 | Date | |
|---|---|---|---|
| 705c5df1f5 | |||
| 88de7affda | |||
| 4934c33104 | |||
| d2241e2dfa | |||
| 6fc1890c1c | |||
| 3e49c091f5 | |||
| 39cb2a6c20 | |||
| c11f2e3c25 | |||
| badfc5fa24 | |||
| d3db951dfa | |||
| 7a32716a23 | |||
| 1a8f746bbd | |||
| c70b254a84 | |||
| fb1f46a27d | |||
| 3a6706b9bc | |||
| a9ad0e9330 | |||
| 0e904c0366 | |||
| 8097582377 | |||
| a56cd76a0b | |||
| 5559b61530 | |||
| a4b33a570b | |||
| c7c1388112 | |||
| b875d6428b | |||
| e1b0d702c5 | |||
| a7f3b6d7e1 | |||
| fcc7c9814a | |||
| cc441d8ad8 | |||
| e71295794f | |||
| 7c46db0253 | |||
| 218ca3fc2f | |||
| 58d080dadd | |||
| f797aa6d8b | |||
| 8b16085acf | |||
| 47102e563d | |||
| d9f9620123 | |||
| 905b749a09 | |||
| 992a949b6d | |||
| 387702c3c3 | |||
| 1bf18d13a3 | |||
| de1ea64e04 | |||
| 9edc3fe55d | |||
| fd0763593f | |||
| fc5ae6402f | |||
| 5412e499f2 | |||
| fa25d7073b | |||
| 2e81ffcdb1 |
19
proxmox.tf
19
proxmox.tf
@ -19,7 +19,7 @@ resource "proxmox_virtual_environment_download_file" "latest_ubunto_cloud_img" {
|
|||||||
content_type = "iso"
|
content_type = "iso"
|
||||||
datastore_id = "local"
|
datastore_id = "local"
|
||||||
node_name = "fenix"
|
node_name = "fenix"
|
||||||
url = "https://cloud-images.ubuntu.com/jammy/20250725/jammy-server-cloudimg-amd64.img"
|
url = "https://cloud-images.ubuntu.com/jammy/20251206/jammy-server-cloudimg-amd64.img"
|
||||||
file_name = "jammyservercloudimgamd64.img"
|
file_name = "jammyservercloudimgamd64.img"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,6 +105,7 @@ resource "proxmox_virtual_environment_vm" "proxmox-kubernetes-VM-template" {
|
|||||||
|
|
||||||
cpu {
|
cpu {
|
||||||
cores = 2
|
cores = 2
|
||||||
|
type = "host"
|
||||||
}
|
}
|
||||||
|
|
||||||
memory {
|
memory {
|
||||||
@ -116,11 +117,12 @@ resource "proxmox_virtual_environment_vm" "proxmox-kubernetes-VM-template" {
|
|||||||
file_id = proxmox_virtual_environment_download_file.latest_ubunto_cloud_img.id
|
file_id = proxmox_virtual_environment_download_file.latest_ubunto_cloud_img.id
|
||||||
interface = "scsi0"
|
interface = "scsi0"
|
||||||
file_format = "qcow2"
|
file_format = "qcow2"
|
||||||
|
size = 64
|
||||||
}
|
}
|
||||||
|
|
||||||
# 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 B
|
||||||
}
|
}
|
||||||
|
|
||||||
initialization {
|
initialization {
|
||||||
@ -132,6 +134,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,10 +149,12 @@ resource "proxmox_virtual_environment_vm" "k8s_vms" {
|
|||||||
|
|
||||||
clone {
|
clone {
|
||||||
vm_id = proxmox_virtual_environment_vm.proxmox-kubernetes-VM-template.id
|
vm_id = proxmox_virtual_environment_vm.proxmox-kubernetes-VM-template.id
|
||||||
|
full = true
|
||||||
}
|
}
|
||||||
|
|
||||||
cpu {
|
cpu {
|
||||||
cores = each.value.cores
|
cores = each.value.cores
|
||||||
|
type = "host"
|
||||||
}
|
}
|
||||||
|
|
||||||
memory {
|
memory {
|
||||||
@ -162,6 +167,16 @@ resource "proxmox_virtual_environment_vm" "k8s_vms" {
|
|||||||
interface = "scsi1"
|
interface = "scsi1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Bloco dinâmico para lista de hostpci
|
||||||
|
dynamic "hostpci" {
|
||||||
|
for_each = try(each.value.hostpci, [])
|
||||||
|
content {
|
||||||
|
device = hostpci.value.device
|
||||||
|
pcie = try(hostpci.value.pcie, true)
|
||||||
|
mapping = hostpci.value.mapping
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
initialization {
|
initialization {
|
||||||
ip_config {
|
ip_config {
|
||||||
ipv4 {
|
ipv4 {
|
||||||
|
|||||||
@ -40,6 +40,13 @@ variable "proxmox_k8s_vms" {
|
|||||||
vm_id = number
|
vm_id = number
|
||||||
node_name = string
|
node_name = string
|
||||||
ip = string
|
ip = string
|
||||||
|
ip2 = string
|
||||||
|
ip3 = string
|
||||||
|
hostpci = optional(list(object({
|
||||||
|
pcie = bool
|
||||||
|
device = string
|
||||||
|
mapping = string
|
||||||
|
})))
|
||||||
cores = optional(number)
|
cores = optional(number)
|
||||||
memory = optional(number)
|
memory = optional(number)
|
||||||
data_store = optional(string)
|
data_store = optional(string)
|
||||||
|
|||||||
13
secrets-output/iac.ansible.hosts.ini
Normal file
13
secrets-output/iac.ansible.hosts.ini
Normal 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'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
1
secrets/iac.proxmox.ssh.link
Normal file
1
secrets/iac.proxmox.ssh.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
proxmox-ssh.example.com
|
||||||
1
secrets/iac.vaultwarden-link
Normal file
1
secrets/iac.vaultwarden-link
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://vaultwarden.example.com
|
||||||
@ -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"]
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@ -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 }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user