output "hostvars" { value = { for hostname, host in var.vms: hostname => { 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 }) } } } }