|
|
@@ -83,12 +83,38 @@ resource "hcloud_server" "vms" { |
|
|
|
for_each = local.hetzner_vm_hosts |
|
|
|
} |
|
|
|
|
|
|
|
#resource "hcloud_server_network" "vms" { |
|
|
|
# server_id = hcloud_server.vms[each.key].id |
|
|
|
# network_id = hcloud_network.internal_network.id |
|
|
|
# |
|
|
|
# for_each = local.hetzner_vm_hosts |
|
|
|
#} |
|
|
|
|
|
|
|
# Volumes |
|
|
|
|
|
|
|
locals { |
|
|
|
hetzner_volumes = { for item in flatten([ |
|
|
|
for hostname, host in local.hetzner_vm_hosts: [ |
|
|
|
for volumename, volume in lookup(host, "volumes", {}): { |
|
|
|
hostname = hostname |
|
|
|
volumename = volumename |
|
|
|
volume = volume |
|
|
|
host = host |
|
|
|
} |
|
|
|
] |
|
|
|
]): "${item.hostname}--${item.volumename}" => merge(item.volume,{hostname=item.hostname}) } |
|
|
|
} |
|
|
|
|
|
|
|
resource "hcloud_volume" "volumes" { |
|
|
|
name = each.key |
|
|
|
|
|
|
|
location = var.hetzner_default_location |
|
|
|
size = each.value.size |
|
|
|
|
|
|
|
for_each = local.hetzner_volumes |
|
|
|
} |
|
|
|
|
|
|
|
resource "hcloud_volume_attachment" "volume_attachments" { |
|
|
|
volume_id = hcloud_volume.volumes[each.key].id |
|
|
|
server_id = hcloud_server.vms[each.value.hostname].id |
|
|
|
#automount = true |
|
|
|
for_each = local.hetzner_volumes |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# Provider Variable |
|
|
|
|
|
|
@@ -100,6 +126,11 @@ locals { |
|
|
|
external_ip = hcloud_server.vms[hostname].ipv4_address |
|
|
|
ansible_host = hcloud_server.vms[hostname].ipv4_address |
|
|
|
#internal_ip = hcloud_server_network.vms[hostname].ip |
|
|
|
volumes = { |
|
|
|
for volumename, volume in lookup(host, "volumes", {}): volumename => merge(volume,{ |
|
|
|
device = hcloud_volume.volumes["${hostname}--${volumename}"].linux_device |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
if host.provider == "hetzner" |
|
|
|
} |
|
|
|