Updates plan to use Metal provider, updates outputs accordingly (#51)

## Description

Updates [Packet Terraform](https://docs.tinkerbell.org/setup/packet-terraform/) plan to use the Equinix Metal provider. 

## Why is this needed

Consistent with rebranding efforts across the organization.

Fixes: #

## How Has This Been Tested?

This plan validates, and applies as expected (and has previously) with the renamed resources, and updates outputs.


## How are existing users impacted? What migration steps/scripts do we need?

Existing users may need to reinitialize their Terraform environment, but existing resources in state can be imported. 

## Checklist:

I have:

- [ ] updated the documentation and/or roadmap (if required)
- [ ] added unit or e2e tests
- [ ] provided instructions on how to upgrade
This commit is contained in:
mergify[bot] 2021-02-09 17:51:03 +00:00 committed by GitHub
commit 4f64f1656d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 32 deletions

View File

@ -1,9 +1,9 @@
# Configure the Packet Provider. # Configure the Packet Provider.
terraform { terraform {
required_providers { required_providers {
packet = { metal = {
source = "packethost/packet" source = "equinix/metal"
version = "~> 3.0.1" version = "1.0.0"
} }
null = { null = {
source = "hashicorp/null" source = "hashicorp/null"
@ -16,19 +16,19 @@ terraform {
} }
} }
provider "packet" { provider "metal" {
auth_token = var.packet_api_token auth_token = var.metal_api_token
} }
# Create a new VLAN in datacenter "ewr1" # Create a new VLAN in datacenter "ewr1"
resource "packet_vlan" "provisioning_vlan" { resource "metal_vlan" "provisioning_vlan" {
description = "provisioning_vlan" description = "provisioning_vlan"
facility = var.facility facility = var.facility
project_id = var.project_id project_id = var.project_id
} }
# Create a device and add it to tf_project_1 # Create a device and add it to tf_project_1
resource "packet_device" "tink_provisioner" { resource "metal_device" "tink_provisioner" {
hostname = "tink-provisioner" hostname = "tink-provisioner"
plan = var.device_type plan = var.device_type
facilities = [var.facility] facilities = [var.facility]
@ -42,7 +42,7 @@ resource "null_resource" "tink_directory" {
connection { connection {
type = "ssh" type = "ssh"
user = var.ssh_user user = var.ssh_user
host = packet_device.tink_provisioner.network[0].address host = metal_device.tink_provisioner.network[0].address
} }
provisioner "remote-exec" { provisioner "remote-exec" {
@ -81,13 +81,13 @@ resource "null_resource" "tink_directory" {
} }
} }
resource "packet_device_network_type" "tink_provisioner_network_type" { resource "metal_device_network_type" "tink_provisioner_network_type" {
device_id = packet_device.tink_provisioner.id device_id = metal_device.tink_provisioner.id
type = "hybrid" type = "hybrid"
} }
# Create a device and add it to tf_project_1 # Create a device and add it to tf_project_1
resource "packet_device" "tink_worker" { resource "metal_device" "tink_worker" {
count = var.worker_count count = var.worker_count
hostname = "tink-worker-${count.index}" hostname = "tink-worker-${count.index}"
@ -100,40 +100,40 @@ resource "packet_device" "tink_worker" {
project_id = var.project_id project_id = var.project_id
} }
resource "packet_device_network_type" "tink_worker_network_type" { resource "metal_device_network_type" "tink_worker_network_type" {
count = var.worker_count count = var.worker_count
device_id = packet_device.tink_worker[count.index].id device_id = metal_device.tink_worker[count.index].id
type = "layer2-individual" type = "layer2-individual"
} }
# Attach VLAN to provisioner # Attach VLAN to provisioner
resource "packet_port_vlan_attachment" "provisioner" { resource "metal_port_vlan_attachment" "provisioner" {
depends_on = [packet_device_network_type.tink_provisioner_network_type] depends_on = [metal_device_network_type.tink_provisioner_network_type]
device_id = packet_device.tink_provisioner.id device_id = metal_device.tink_provisioner.id
port_name = "eth1" port_name = "eth1"
vlan_vnid = packet_vlan.provisioning_vlan.vxlan vlan_vnid = metal_vlan.provisioning_vlan.vxlan
} }
# Attach VLAN to worker # Attach VLAN to worker
resource "packet_port_vlan_attachment" "worker" { resource "metal_port_vlan_attachment" "worker" {
count = var.worker_count count = var.worker_count
depends_on = [packet_device_network_type.tink_worker_network_type] depends_on = [metal_device_network_type.tink_worker_network_type]
device_id = packet_device.tink_worker[count.index].id device_id = metal_device.tink_worker[count.index].id
port_name = "eth0" port_name = "eth0"
vlan_vnid = packet_vlan.provisioning_vlan.vxlan vlan_vnid = metal_vlan.provisioning_vlan.vxlan
} }
data "template_file" "worker_hardware_data" { data "template_file" "worker_hardware_data" {
count = var.worker_count count = var.worker_count
template = file("${path.module}/hardware_data.tpl") template = file("${path.module}/hardware_data.tpl")
vars = { vars = {
id = packet_device.tink_worker[count.index].id id = metal_device.tink_worker[count.index].id
facility_code = packet_device.tink_worker[count.index].deployed_facility facility_code = metal_device.tink_worker[count.index].deployed_facility
plan_slug = packet_device.tink_worker[count.index].plan plan_slug = metal_device.tink_worker[count.index].plan
address = "192.168.1.${count.index + 5}" address = "192.168.1.${count.index + 5}"
mac = packet_device.tink_worker[count.index].ports[1].mac mac = metal_device.tink_worker[count.index].ports[1].mac
} }
} }
@ -144,7 +144,7 @@ resource "null_resource" "hardware_data" {
connection { connection {
type = "ssh" type = "ssh"
user = var.ssh_user user = var.ssh_user
host = packet_device.tink_provisioner.network[0].address host = metal_device.tink_provisioner.network[0].address
} }
provisioner "file" { provisioner "file" {

View File

@ -1,15 +1,15 @@
output "provisioner_dns_name" { output "provisioner_dns_name" {
value = "${split("-", packet_device.tink_provisioner.id)[0]}.packethost.net" value = "${split("-", metal_device.tink_provisioner.id)[0]}.packethost.net"
} }
output "provisioner_ip" { output "provisioner_ip" {
value = packet_device.tink_provisioner.network[0].address value = metal_device.tink_provisioner.network[0].address
} }
output "worker_mac_addr" { output "worker_mac_addr" {
value = formatlist("%s", packet_device.tink_worker[*].ports[1].mac) value = formatlist("%s", metal_device.tink_worker[*].ports[1].mac)
} }
output "worker_sos" { output "worker_sos" {
value = formatlist("%s@sos.%s.packet.net", packet_device.tink_worker[*].id, packet_device.tink_worker[*].deployed_facility) value = formatlist("%s@sos.%s.platformequinix.com", metal_device.tink_worker[*].id, metal_device.tink_worker[*].deployed_facility)
} }

View File

@ -1,5 +1,5 @@
variable "packet_api_token" { variable "metal_api_token" {
description = "Packet user api token" description = "Equinix Metal user api token"
type = string type = string
} }