Skip to content

Commit

Permalink
fix templating and iteration
Browse files Browse the repository at this point in the history
Signed-off-by: Marques Johansson <[email protected]>
  • Loading branch information
displague committed Mar 15, 2024
1 parent e7eaf1e commit 1277dce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions templates/bastion-userdata.tftpl
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 1277dce

Please sign in to comment.