mirror of
https://gitea.fenix-dev.com/fenix-gitea-admin/iac-opentofu-private.git
synced 2025-10-27 15:53:06 +00:00
Compare commits
31 Commits
fenix-admi
...
827bac16cb
| Author | SHA1 | Date | |
|---|---|---|---|
| 827bac16cb | |||
| 75e02c447f | |||
| 5545341bd5 | |||
| de26dbe2f0 | |||
| ac61fdff12 | |||
| 3e00706c93 | |||
| 2fc7391161 | |||
| d279104aea | |||
| c75c4869e9 | |||
| 13872af0ac | |||
| 196b851e42 | |||
| 8d96b54738 | |||
| adbf69fefe | |||
| 5772fb36d2 | |||
| 99afd901dc | |||
| 8a5c2ce64c | |||
| 453ff5202e | |||
| d24306ce8c | |||
| b2533ac7cb | |||
| 00239da11c | |||
| 9911825872 | |||
| 1e0110fe1a | |||
| 5a24f06fd8 | |||
| 11e8997be8 | |||
| d4811cbcfe | |||
| 6258d9e279 | |||
| eaadf11a99 | |||
| 50e52fb839 | |||
| 43bd8914aa | |||
| c457178d48 | |||
| 01d40d4120 |
@ -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
|
||||||
|
|||||||
39
proxmox.tf
39
proxmox.tf
@ -122,6 +122,9 @@ resource "proxmox_virtual_environment_vm" "proxmox-kubernetes-VM-template" {
|
|||||||
network_device {
|
network_device {
|
||||||
bridge = "vmbr0" # rede de gestão para comunicação com Cluster A
|
bridge = "vmbr0" # rede de gestão para comunicação com Cluster A
|
||||||
}
|
}
|
||||||
|
network_device {
|
||||||
|
bridge = "vmbr2"
|
||||||
|
}
|
||||||
|
|
||||||
initialization {
|
initialization {
|
||||||
dns {
|
dns {
|
||||||
@ -133,6 +136,11 @@ initialization {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ip_config {
|
||||||
|
ipv4 {
|
||||||
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,6 +178,12 @@ resource "proxmox_virtual_environment_vm" "k8s_vms" {
|
|||||||
gateway = each.value.gateway
|
gateway = each.value.gateway
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ip_config {
|
||||||
|
ipv4 {
|
||||||
|
address = each.value.ip2
|
||||||
|
gateway = each.value.gateway
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
user_data_file_id = proxmox_virtual_environment_file.vm_user_data[each.key].id
|
user_data_file_id = proxmox_virtual_environment_file.vm_user_data[each.key].id
|
||||||
}
|
}
|
||||||
@ -178,3 +192,28 @@ resource "proxmox_virtual_environment_vm" "k8s_vms" {
|
|||||||
enabled = true
|
enabled = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "null_resource" "add_api_ip" {
|
||||||
|
for_each = {
|
||||||
|
for vm in var.proxmox_k8s_vms : vm.name => vm
|
||||||
|
}
|
||||||
|
|
||||||
|
triggers = {
|
||||||
|
vm_id = each.value.vm_id
|
||||||
|
}
|
||||||
|
|
||||||
|
provisioner "remote-exec" {
|
||||||
|
inline = [
|
||||||
|
"sudo ip addr add ${each.value.ip3} dev eth0"
|
||||||
|
]
|
||||||
|
|
||||||
|
connection {
|
||||||
|
type = "ssh"
|
||||||
|
host = split("/", each.value.ip)[0] // remove a máscara para conectar
|
||||||
|
user = each.value.extra_users[0].name
|
||||||
|
password = each.value.extra_users[0].password
|
||||||
|
timeout = "4m"
|
||||||
|
agent = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,13 +0,0 @@
|
|||||||
|
|
||||||
[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 +0,0 @@
|
|||||||
proxmox-ssh.example.com
|
|
||||||
@ -1 +0,0 @@
|
|||||||
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,7 +20,6 @@ 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
|
||||||
@ -34,14 +33,13 @@ proxmox_k8s_vms = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
extra_packages = []
|
extra_packages = []
|
||||||
extra_runcmd = ["sudo ip addr add 192.168.1.199/24 dev eth0"]
|
extra_runcmd = []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
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
|
||||||
@ -55,6 +53,6 @@ proxmox_k8s_vms = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
extra_packages = []
|
extra_packages = []
|
||||||
extra_runcmd = ["sudo ip addr add 192.168.1.201/24 dev eth0"]
|
extra_runcmd = []
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
Reference in New Issue
Block a user