diff --git a/infrastructure/create-resources/hcloud.tf b/infrastructure/create-resources/hcloud.tf index 2e50d44..b8d159c 100644 --- a/infrastructure/create-resources/hcloud.tf +++ b/infrastructure/create-resources/hcloud.tf @@ -6,10 +6,6 @@ variable "serverctl_node_count" { default = 2 } -variable "serverctl_mesh_count" { - default = 0 -} - resource "hcloud_placement_group" "serverctl_master" { name = "serverctl_master_group" type = "spread" @@ -74,44 +70,11 @@ resource "hcloud_server" "serverctl_node" { } } -resource "hcloud_placement_group" "serverctl_mesh" { - name = "serverctl_mesh_group" - type = "spread" -} - -resource "hcloud_server" "serverctl_mesh" { - count = var.serverctl_mesh_count - name = "serverctl-mesh-${count.index}" - image = "debian-11" - server_type = "cx11" - ssh_keys = [ - var.hcloud_serverctl_ssh_key_id - ] - placement_group_id = hcloud_placement_group.serverctl_mesh.id - - - lifecycle { - create_before_destroy = true - } - - provisioner "remote-exec" { - inline = ["sudo apt update", "sudo apt install python3 -y", "echo Done!"] - - connection { - host = self.ipv4_address - type = "ssh" - user = "root" - private_key = file(var.pvt_key) - } - } -} - resource "local_file" "hosts_cfg" { content = templatefile("${path.module}/templates/hosts.tftpl", { serverctl_masters = hcloud_server.serverctl_master.*.ipv4_address serverctl_nodes = hcloud_server.serverctl_node.*.ipv4_address - serverctl_mesh_nodes = hcloud_server.serverctl_mesh.*.ipv4_address } ) filename = "ansible/inventory/hosts.cfg" diff --git a/infrastructure/create-resources/templates/hosts.tftpl b/infrastructure/create-resources/templates/hosts.tftpl index cfbe8ad..23a6cb6 100644 --- a/infrastructure/create-resources/templates/hosts.tftpl +++ b/infrastructure/create-resources/templates/hosts.tftpl @@ -1,23 +1,18 @@ [serverctl_master_hosts] %{ for ip in serverctl_masters ~} -${ip} +${ip} ansible_host=${ip} wireguard_ip=${cidrhost("192.168.0.0/24", index(serverctl_mesh_nodes, ip) + 1)} %{ endfor ~} [serverctl_node_hosts] %{ for ip in serverctl_nodes ~} -${ip} -%{ endfor ~} - -[serverctl_mesh_nodes] -%{ for ip in serverctl_mesh_nodes ~} ${ip} ansible_host=${ip} wireguard_ip=${cidrhost("192.168.0.0/24", index(serverctl_mesh_nodes, ip) + 1)} %{ endfor ~} -[serverctl_mesh_nodes:vars] -pipelining=true -ansible_ssh_user=root -ansible_ssh_port=22 - [serverctl_cluster:children] serverctl_master_hosts serverctl_node_hosts + +[serverctl_cluster:vars] +pipelining=true +ansible_ssh_user=root +ansible_ssh_port=22