output "ansible_inventory" { value = { all = { hosts = { for hostname,host in var.vm_hosts: hostname => {} } children = merge( { for group in local.vm_groups: group => { hosts = { for hostname, host in local.vm_hosts_with_groups: hostname => {} if contains(host.groups,group) } } },{ for providername, provider in local.providers: "provider_${providername}" => { hosts = { for hostname, host in var.vm_hosts: hostname => local.providers[host.provider].hostvars[hostname] if host.provider == providername } } } ) } } }