You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
814B

  1. output "vms_by_provider" {
  2. value = {
  3. }
  4. }
  5. output "ansible_inventory" {
  6. value = {
  7. all = {
  8. hosts = {
  9. for hostname,host in var.vms: hostname => {}
  10. }
  11. children = merge(
  12. {
  13. for group in local.vm_groups: group => {
  14. hosts = {
  15. for hostname, host in local.vms_with_groups:
  16. hostname => {}
  17. if contains(host.groups,group)
  18. }
  19. }
  20. },{
  21. for providername in local.vm_providers: "provider_${providername}" => {
  22. hosts = {
  23. for hostname, host in local.vms_with_provider:
  24. hostname => var.providers_hostvars[host.provider].hostvars[hostname]
  25. if host.provider == providername
  26. }
  27. }
  28. }
  29. )
  30. }
  31. }
  32. }