diff --git a/main.tf b/main.tf index 2289688..7c73fb4 100644 --- a/main.tf +++ b/main.tf @@ -11,9 +11,9 @@ resource "equinix_metal_vlan" "test" { resource "equinix_metal_device" "bastion" { project_id = data.equinix_metal_project.nutanix.id hostname = "bastion" - user_data = templatefile("bastion-userdata.tmpl", { - metal_auth_token = var.metal_auth_token - metal_vlan_description = var.metal_vlan_description + user_data = templatefile("${path.module}/templates/bastion-userdata.tftpl", { + "metal_auth_token": var.metal_auth_token, + "metal_vlan_description": var.metal_vlan_description }) operating_system = "rocky_9" plan = "c3.small.x86" @@ -30,15 +30,15 @@ resource "equinix_metal_port" "bastion_bond0" { resource "equinix_metal_device" "nutanix" { count = 1 project_id = data.equinix_metal_project.nutanix.id - hostname = "nutanix-devrel-test-{count.index}" - user_data = templatefile("nutanix-userdata.tmpl", {}) + hostname = "nutanix-devrel-test-${count.index}" + user_data = templatefile("${path.module}/templates/nutanix-userdata.tftpl", {}) operating_system = "nutanix_lts_6_5" plan = "m3.large.x86" metro = "da" } resource "equinix_metal_port" "nutanix_bond0" { - for_each = equinix_metal_device.nutanix + for_each = { for idx, val in equinix_metal_device.nutanix: idx => val } port_id = [for p in each.value.ports : p.id if p.name == "bond0"][0] layer2 = true bonded = true diff --git a/templates/bastion-userdata.tftpl b/templates/bastion-userdata.tftpl index 8573a76..a0071e2 100644 --- a/templates/bastion-userdata.tftpl +++ b/templates/bastion-userdata.tftpl @@ -1,7 +1,7 @@ #!/bin/bash -export EMAPI_AUTH_TOKEN=${var.metal_auth_token} -export L2GATEWAY_VLAN_DESCRIPTION=${var.metal_vlan_description} +export EMAPI_AUTH_TOKEN=${metal_auth_token} +export L2GATEWAY_VLAN_DESCRIPTION=${metal_vlan_description} curl https://artifacts.platformequinix.com/images/nutanix/misc/scripts/install-l2gateway.sh | sh 2>&1 | tee /root/install-l2gw.log