Skip to content

Commit

Permalink
fix terraform resource paths, use templatefile, update metal version
Browse files Browse the repository at this point in the history
Signed-off-by: Marques Johansson <[email protected]>
  • Loading branch information
displague committed Aug 13, 2021
1 parent 232cf79 commit 1febe6d
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 20 deletions.
63 changes: 63 additions & 0 deletions deploy/terraform/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 14 additions & 20 deletions deploy/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ terraform {
required_providers {
metal = {
source = "equinix/metal"
version = "1.0.0"
version = "3.1.0"
}
null = {
source = "hashicorp/null"
Expand Down Expand Up @@ -35,7 +35,7 @@ resource "metal_device" "tink_provisioner" {
operating_system = "ubuntu_18_04"
billing_cycle = "hourly"
project_id = var.project_id
user_data = file("install_package.sh")
user_data = file("${path.module}/install_package.sh")
}

resource "null_resource" "tink_directory" {
Expand All @@ -52,27 +52,27 @@ resource "null_resource" "tink_directory" {
}

provisioner "file" {
source = "../../setup.sh"
source = "${path.module}/../../setup.sh"
destination = "/root/tink/setup.sh"
}

provisioner "file" {
source = "../../generate-env.sh"
source = "${path.module}/../../generate-env.sh"
destination = "/root/tink/generate-env.sh"
}

provisioner "file" {
source = "../../current_versions.sh"
source = "${path.module}/../../current_versions.sh"
destination = "/root/tink/current_versions.sh"
}

provisioner "file" {
source = "../../deploy"
source = "${path.module}/../../deploy"
destination = "/root/tink"
}

provisioner "file" {
source = "nat_interface"
source = "${path.module}/nat_interface"
destination = "/root/tink/.nat_interface"
}

Expand Down Expand Up @@ -127,18 +127,6 @@ resource "metal_port_vlan_attachment" "worker" {
vlan_vnid = metal_vlan.provisioning_vlan.vxlan
}

data "template_file" "worker_hardware_data" {
count = var.worker_count
template = file("${path.module}/hardware_data.tpl")
vars = {
id = metal_device.tink_worker[count.index].id
facility_code = metal_device.tink_worker[count.index].deployed_facility
plan_slug = metal_device.tink_worker[count.index].plan
address = "192.168.1.${count.index + 5}"
mac = metal_device.tink_worker[count.index].ports[1].mac
}
}

resource "null_resource" "hardware_data" {
count = var.worker_count
depends_on = [null_resource.tink_directory]
Expand All @@ -150,7 +138,13 @@ resource "null_resource" "hardware_data" {
}

provisioner "file" {
content = data.template_file.worker_hardware_data[count.index].rendered
content = templatefile("${path.module}/hardware_data.tpl", {
id = metal_device.tink_worker[count.index].id
facility_code = metal_device.tink_worker[count.index].deployed_facility
plan_slug = metal_device.tink_worker[count.index].plan
address = "192.168.1.${count.index + 5}"
mac = metal_device.tink_worker[count.index].ports[1].mac
})
destination = "/root/tink/deploy/hardware-data-${count.index}.json"
}
}

0 comments on commit 1febe6d

Please sign in to comment.