inventory.tf (746B)
1 resource "null_resource" "update_inventory" { 2 triggers = { 3 # when a host id changes 4 host_ids = join(" ", concat(values(libvirt_domain.host)[*].id, values(libvirt_domain.hosts_type2)[*].id)) 5 } 6 provisioner "local-exec" { 7 # recreate ansible inventory 8 command = "echo '${templatefile("${path.module}/templates/inventory.tpl", { hosts = merge(libvirt_domain.host, libvirt_domain.hosts_type2) })}' > ../ansible/inventory" 9 } 10 provisioner "local-exec" { 11 # recreate mapping of qemu VM id to hostnames 12 command = "echo '${templatefile("${path.module}/templates/qemu-config.yml.tpl", { hosts = merge(libvirt_domain.host, libvirt_domain.hosts_type2) })}' > ../ansible/qemu-config.yml" 13 } 14 }