- This commit introduces the Terraform configuration to provision a production environment on Hetzner Cloud, building on the existing test setup. - Key improvements and new features include: * **Multi-node clusters:** Scaling to 3-node Swarm application and database clusters for improved resilience. * **High availability:** Utilizing a Hetzner Floating IP for the application entry point and `spread` placement groups for fault tolerance across physical hosts. * **Enhanced network security:** Internal management services (RabbitMQ, APISIX, Prometheus, Grafana) are restricted to the application subnet, expected to be accessed via an internal reverse proxy (SWAG). * **Internal database replication:** New firewall rules enable PostgreSQL replication and MongoDB replica set traffic within the database subnet. * **Refined test environment:** Updates to align `test` configuration with the new `prod` structure, including a dedicated floating IP and adjusted firewall rules. * **Configuration standardization:** Environment-specific details moved to `locals.tf` for clarity, with upgraded server types and migration to Rocky Linux as the base image. - Updates were also made to the latest version of Terraform to ensure consistency in the documentation
53 lines
1.4 KiB
HCL
53 lines
1.4 KiB
HCL
output "ansible_inventory_yaml" {
|
|
description = "Ansible inventory in YAML format — write to ansible/inventory/generated/prod.yml"
|
|
sensitive = false
|
|
value = yamlencode({
|
|
all = {
|
|
children = {
|
|
swarm = {
|
|
hosts = {
|
|
for name, server in hcloud_server.swarm : name => {
|
|
ansible_host = server.ipv4_address
|
|
private_ip = local.swarm_private_ips[name]
|
|
ansible_user = "root"
|
|
}
|
|
}
|
|
}
|
|
db = {
|
|
hosts = {
|
|
for name, server in hcloud_server.db : name => {
|
|
ansible_host = server.ipv4_address
|
|
private_ip = local.db_private_ips[name]
|
|
ansible_user = "root"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
output "prod_private_ips" {
|
|
description = "Private IPs assigned to prod nodes"
|
|
sensitive = false
|
|
value = {
|
|
swarm = local.swarm_private_ips
|
|
db = local.db_private_ips
|
|
}
|
|
}
|
|
|
|
output "prod_public_ips" {
|
|
description = "Public IPv4 addresses of prod nodes"
|
|
sensitive = false
|
|
value = {
|
|
swarm = { for name, server in hcloud_server.swarm : name => server.ipv4_address }
|
|
db = { for name, server in hcloud_server.db : name => server.ipv4_address }
|
|
}
|
|
}
|
|
|
|
output "prod_floating_ip" {
|
|
description = "Floating IP for prod swarm entry point — point DNS A records here"
|
|
sensitive = false
|
|
value = hcloud_floating_ip.app.ip_address
|
|
}
|