|
|
@@ -1,3 +1,23 @@ |
|
|
|
variable "vm_hosts" { |
|
|
|
default = { |
|
|
|
#"hostname.example.com" = { |
|
|
|
# provider = "hetzner" |
|
|
|
# groups = [ "testgroup" ] |
|
|
|
# volumes = { |
|
|
|
# data = { size = 32 } |
|
|
|
# } |
|
|
|
#} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
variable "groups" { |
|
|
|
default = { |
|
|
|
#testgroup = { |
|
|
|
# testvar1 = "bla" |
|
|
|
#} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
variable "ansible_inventory_filename" { |
|
|
|
type = string |
|
|
|
default = "inventory.json" |
|
|
@@ -28,7 +48,7 @@ locals { |
|
|
|
},{ |
|
|
|
for providername, provider in local.providers: "provider_${providername}" => { |
|
|
|
hosts = { |
|
|
|
for hostname, host in local.vm_hosts_with_groups: |
|
|
|
for hostname, host in var.vm_hosts: |
|
|
|
hostname => local.providers[host.provider].hostvars[hostname] |
|
|
|
if host.provider == providername |
|
|
|
} |
|
|
@@ -43,7 +63,7 @@ output "ansible_inventory" { |
|
|
|
value = local.ansible_inventory |
|
|
|
} |
|
|
|
|
|
|
|
resource "local_file" "foo" { |
|
|
|
resource "local_file" "ansible_inventory" { |
|
|
|
content = jsonencode(local.ansible_inventory) |
|
|
|
filename = var.ansible_inventory_filename |
|
|
|
file_permission = "0644" |