mirror of
https://github.com/batonogov/learn-devops.git
synced 2025-11-29 08:43:01 +00:00
patroni-postgresql-cluster (#13)
* Описана инфрастуктура кластера * Добавлена роль etcd * Добавлена роль haproxy * Добавлена роль keepalived * Добавлена роль ntp_install * Добавлена роль patroni * Добавлена групповые переменные --------- Co-authored-by: Fedor Batonogov <f.batonogov@yandex.ru>
This commit is contained in:
committed by
GitHub
parent
5b7920bdca
commit
f8fe304cd9
99
opentofu/patroni-postgresql/patroni-postgresql.tf
Normal file
99
opentofu/patroni-postgresql/patroni-postgresql.tf
Normal file
@@ -0,0 +1,99 @@
|
||||
variable "patroni_vms" {
|
||||
type = list(object({
|
||||
name = string
|
||||
address = string
|
||||
node_name = string
|
||||
}))
|
||||
default = [
|
||||
{
|
||||
name = "patroni-postgresql-01"
|
||||
address = "10.0.75.111/24"
|
||||
node_name = "pve-01"
|
||||
},
|
||||
{
|
||||
name = "patroni-postgresql-02"
|
||||
address = "10.0.75.112/24"
|
||||
node_name = "pve-02"
|
||||
},
|
||||
{
|
||||
name = "patroni-postgresql-03" # Исправлено имя
|
||||
address = "10.0.75.113/24"
|
||||
node_name = "pve-02"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
# Создание виртуальных машин
|
||||
resource "proxmox_virtual_environment_vm" "patroni" {
|
||||
for_each = { for vm in var.patroni_vms : vm.name => vm }
|
||||
|
||||
name = each.value.name
|
||||
migrate = true
|
||||
description = "Managed by OpenTofu"
|
||||
tags = ["patroni", "postgresql"]
|
||||
on_boot = true
|
||||
node_name = each.value.node_name
|
||||
|
||||
clone {
|
||||
vm_id = "2404"
|
||||
node_name = "pve-01"
|
||||
retries = 3
|
||||
}
|
||||
|
||||
agent {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
operating_system {
|
||||
type = "l26"
|
||||
}
|
||||
|
||||
cpu {
|
||||
cores = 2
|
||||
type = "host"
|
||||
numa = true
|
||||
}
|
||||
|
||||
memory {
|
||||
dedicated = 2048
|
||||
}
|
||||
|
||||
vga {
|
||||
memory = 4
|
||||
type = "serial0"
|
||||
}
|
||||
|
||||
disk {
|
||||
size = "20"
|
||||
interface = "virtio0"
|
||||
datastore_id = "proxmox-data-01"
|
||||
file_format = "raw"
|
||||
}
|
||||
|
||||
network_device {
|
||||
bridge = "vmbr0"
|
||||
model = "virtio"
|
||||
}
|
||||
|
||||
initialization {
|
||||
datastore_id = "proxmox-data-01"
|
||||
ip_config {
|
||||
ipv4 {
|
||||
address = each.value.address
|
||||
gateway = "10.0.75.1"
|
||||
}
|
||||
}
|
||||
dns {
|
||||
servers = [
|
||||
"10.0.75.65",
|
||||
"10.0.75.66"
|
||||
]
|
||||
}
|
||||
user_account {
|
||||
username = "infra"
|
||||
keys = [
|
||||
var.ssh_public_key
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user