diff --git a/deploy/terraform/.terraform.lock.hcl b/deploy/terraform/.terraform.lock.hcl index c655c459..60b41da8 100644 --- a/deploy/terraform/.terraform.lock.hcl +++ b/deploy/terraform/.terraform.lock.hcl @@ -2,23 +2,23 @@ # Manual edits may be lost in future updates. provider "registry.terraform.io/equinix/metal" { - version = "3.1.0" - constraints = "3.1.0" + version = "3.2.0" + constraints = "3.2.0" hashes = [ - "h1:9qdLMOS8tATAqb9IDjP7tfaC0hpWU7dJquvha84Basc=", - "zh:070b77456a3de02b623be29f1752b48c17100533a98661b7c6555ad2b60aeb1b", - "zh:140b4bfb72810b2e977e7fe442a5b69096db93fe3daff6e307574a541079eb42", - "zh:1d9bf5ba1e05b55af6f5d3e37fa9c0dd4c9fed02e0d47112945c16561f10fe38", - "zh:2b380fb077bb21296e1560c37efd051a7bb31fa488fbe525f54a166ace8cccc8", - "zh:5120fd9f3164e06473d813206e4f06d3b330a351ef6f59114546e0170a49f542", - "zh:5b131619662a36af7f0691c9505d24462533965391039b5664855e50b64db7c4", - "zh:7d3b2f2e2d1a0073ae54070e5dee37713726f6401f26d046db8a5cf58c80cebc", - "zh:7d40ec64e8a3f77c272c9e0cfc8bb6fc148e11a130ef0f022291947313798ec1", - "zh:7fe35422891a14ed233080303468221d8a9f98cd74b0fe73688569cbfc19ff4c", - "zh:a9bb9bfe0928bbc15c132004b3ef573983bb14cc59af9fb492b4f59f2d159054", - "zh:bd7000a809e2e96f87ac7ef90c953a05a8813feb220f27cccc50232f1ae02a50", - "zh:c0656d79d71b893fabcc8420774b8c2d5e2c77feb2b7fecd5dfb9be24228d392", - "zh:f1c755853d4c988fc616e8b1cf8407ed425a0e9ef35a441c0e9eb37657aa9907", + "h1:PIotyZNp3/sYe/Zk7yEgHygV5GOtHjAqXr4TJYdtETs=", + "zh:4a53b56d7cab5a75dca16c4a285438f13fe07a37c45967668dae8e4a70b78a85", + "zh:4fa88d43bd2370e420de6238f02f8ad668a0cd9e7f010a24a8bc0a76982ff3bc", + "zh:525b0f6d977437388b7ee7428bccd351e46af39a0883ce08f624b4dd173de8c2", + "zh:5c906ee75fbd1daa63dc40221015bfdcea7cec24ed7aa3687fcc18265556e379", + "zh:6153771a66d1f5058e977a686e706f3ced64cbcb7cd623a9adf7e8ed3f0d08d8", + "zh:79dd26afcc0846864ede59e79ae07fdf6cc084315cd9e50f4e09c700d9d8dfb4", + "zh:992e410067995537565f38ad9f93f4d66fabdc25a8303a1be418aefaf172daae", + "zh:9e52d2d008846cb6db8d0cd0aac7e1c6c635fc65c192b0217b2e673d165def0f", + "zh:c2ca5c36358c03c996d97b8baca6809675f54010c021d5704124bd3815660c86", + "zh:e2d4bfae4489142cfac31fb7939047226335c0fddf59c3544faeb1f3029a36d8", + "zh:e5c6727b6404beb3aa54bbc7eb3145bac29bab8135771f21754e093c178ee23f", + "zh:ecf34c7c8b3eb8cd61b381d8f26ec61b3d8b5d57a87fff97cb24331230286fef", + "zh:fcae7646861ccf3393828ac53d05487ba8547cf9f8a9da13553dcedf8dd2646e", ] } diff --git a/deploy/terraform/cloud-config.cfg b/deploy/terraform/cloud-config.cfg index 67f198c7..b1d51cf5 100644 --- a/deploy/terraform/cloud-config.cfg +++ b/deploy/terraform/cloud-config.cfg @@ -9,4 +9,4 @@ write_files: runcmd: - cd /root/sandbox/compose && unzip /root/compose.zip - cd /root/sandbox/compose && TINKERBELL_CLIENT_MAC=${WORKER_MAC} TINKERBELL_TEMPLATE_MANIFEST=/manifests/template/ubuntu-equinix-metal.yaml TINKERBELL_HARDWARE_MANIFEST=/manifests/hardware/hardware-equinix-metal.json docker-compose up -d -- cd /root/sandbox/compose && bash tls/trust.sh ${PROVISIONER_IP} \ No newline at end of file +- cd /root/sandbox/compose && bash tls/trust.sh $(ip route get 1.2.3.4 | awk '{print $7}') \ No newline at end of file diff --git a/deploy/terraform/main.tf b/deploy/terraform/main.tf index 1e121466..81fc872e 100644 --- a/deploy/terraform/main.tf +++ b/deploy/terraform/main.tf @@ -1,9 +1,9 @@ -# Configure the Packet Provider. +# Configure the Equinix Metal Provider. terraform { required_providers { metal = { source = "equinix/metal" - version = "3.1.0" + version = "3.2.0" } null = { source = "hashicorp/null" @@ -23,7 +23,7 @@ provider "metal" { # Create a new VLAN in datacenter "ewr1" resource "metal_vlan" "provisioning_vlan" { description = "provisioning_vlan" - facility = var.facility + metro = var.metro project_id = var.project_id } @@ -31,7 +31,7 @@ resource "metal_vlan" "provisioning_vlan" { resource "metal_device" "tink_worker" { hostname = "tink-worker" plan = var.device_type - facilities = [var.facility] + metro = var.metro operating_system = "custom_ipxe" ipxe_script_url = "https://boot.netboot.xyz" always_pxe = "true" @@ -39,43 +39,42 @@ resource "metal_device" "tink_worker" { project_id = var.project_id } -resource "metal_device_network_type" "tink_worker_network_type" { - device_id = metal_device.tink_worker.id - type = "layer2-individual" +resource "metal_port" "tink_worker_bond0" { + port_id = [for p in metal_device.tink_worker.ports : p.id if p.name == "bond0"][0] + layer2 = true + bonded = false + # vlan_ids = [metal_vlan.provisioning_vlan.id] + # Can't do this: │ Error: vlan assignment batch could not be created: POST https://api.equinix.com/metal/v1/ports/b0bdf6d8-589e-4988-9000-9f49c97a54e1/vlan-assignments/batches: 422 Can't assign VLANs to port b0bdf6d8-589e-4988-9000-9f49c97a54e1, the port is configured for Layer 3 mode., Port b0bdf6d8-589e-4988-9000-9f49c97a54e1 cannot be assigned to VLANs., Bond disabled } # Attach VLAN to worker -resource "metal_port_vlan_attachment" "worker" { - depends_on = [metal_device_network_type.tink_worker_network_type] - - device_id = metal_device.tink_worker.id - port_name = "eth0" - vlan_vnid = metal_vlan.provisioning_vlan.vxlan +resource "metal_port" "tink_worker_eth0" { + depends_on = [metal_port.tink_worker_bond0] + port_id = [for p in metal_device.tink_worker.ports : p.id if p.name == "eth0"][0] + #layer2 = true + # TODO(displague) the terraform provider is not permitting this, perhaps a bug in the provider validation + # layer2 flag can be set only for bond ports + bonded = false + vlan_ids = [metal_vlan.provisioning_vlan.id] + // vxlan_ids = [1000] } - # Create a device and add it to tf_project_1 resource "metal_device" "tink_provisioner" { hostname = "tink-provisioner" plan = var.device_type - facilities = [var.facility] + metro = var.metro operating_system = "ubuntu_20_04" billing_cycle = "hourly" project_id = var.project_id user_data = data.cloudinit_config.setup.rendered } -resource "metal_device_network_type" "tink_provisioner_network_type" { - device_id = metal_device.tink_provisioner.id - type = "hybrid" -} - -# Attach VLAN to provisioner -resource "metal_port_vlan_attachment" "provisioner" { - depends_on = [metal_device_network_type.tink_provisioner_network_type] - device_id = metal_device.tink_provisioner.id - port_name = "eth1" - vlan_vnid = metal_vlan.provisioning_vlan.vxlan +# Provisioners eth1 (unbonded) is attached to the provisioning VLAN +resource "metal_port" "eth1" { + port_id = [for p in metal_device.tink_provisioner.ports : p.id if p.name == "eth1"][0] + bonded = false + vlan_ids = [metal_vlan.provisioning_vlan.id] } data "archive_file" "compose" { @@ -85,7 +84,7 @@ data "archive_file" "compose" { } locals { - compose_zip = data.archive_file.compose.output_size > 0 ? "" : filebase64("${path.module}/compose.zip") + compose_zip = data.archive_file.compose.output_size > 0 ? filebase64("${path.module}/compose.zip") : "" } data "cloudinit_config" "setup" { @@ -102,9 +101,8 @@ data "cloudinit_config" "setup" { part { content_type = "text/cloud-config" content = templatefile("${path.module}/cloud-config.cfg", { - COMPOSE_ZIP = local.compose_zip - WORKER_MAC = metal_device.tink_worker.ports[1].mac - PROVISIONER_IP = metal_device.tink_provisioner.network[0].address + COMPOSE_ZIP = local.compose_zip + WORKER_MAC = metal_device.tink_worker.ports[1].mac }) } } diff --git a/deploy/terraform/variables.tf b/deploy/terraform/variables.tf index fae5e2a6..b25a036d 100644 --- a/deploy/terraform/variables.tf +++ b/deploy/terraform/variables.tf @@ -8,10 +8,10 @@ variable "project_id" { type = string } -variable "facility" { - description = "Packet facility to provision in" +variable "metro" { + description = "Equinix Metal metr to provision in" type = string - default = "sjc1" + default = "sv" } variable "device_type" { @@ -30,4 +30,4 @@ variable "ssh_private_key" { type = string description = "ssh private key file to use" default = "~/.ssh/id_rsa" -} \ No newline at end of file +}