From 1574937ff812c2b7da257bc99b35d7a237477892 Mon Sep 17 00:00:00 2001 From: vasubabu Date: Thu, 11 May 2023 00:33:26 +0530 Subject: [PATCH] Add provider equinix and module_name in Equinix Metal TF configs --- BareMetal.tf | 36 ++++++++++++++++-------------------- DistributeKeys.tf | 4 ++-- Hostfile.tf | 16 ++++++++-------- OpenStackDefaults.tf | 20 ++++++++++---------- OpenStackSampleWorkload.tf | 6 +++--- ProviderNetwork.tf | 30 ++++++++++++++---------------- RemoveLocalhostHostfile.tf | 8 ++++---- main.tf | 34 +++++++++++++++++----------------- outputs.tf | 26 +++++++++++++------------- sample-arm.terraform.tfvars | 1 - sample-gen2.terraform.tfvars | 1 - sample-gen3.terraform.tfvars | 1 - sample.terraform.tfvars | 1 - variables.tf | 24 +++++++++--------------- versions.tf | 9 ++++++--- 15 files changed, 102 insertions(+), 115 deletions(-) diff --git a/BareMetal.tf b/BareMetal.tf index 4b5d20a..9d1c0c8 100644 --- a/BareMetal.tf +++ b/BareMetal.tf @@ -1,16 +1,16 @@ -resource "metal_project" "new_project" { - count = var.metal_create_project ? 1 : 0 - name = (var.metal_project_name != "") ? var.metal_project_name : format("openstack-%s", random_id.cloud.b64_url) - organization_id = var.metal_organization_id +resource "equinix_metal_project" "new_project" { + count = var.equinix_metal_create_project ? 1 : 0 + name = (var.equinix_metal_project_name != "") ? var.equinix_metal_project_name : format("openstack-%s", random_id.cloud.b64_url) + organization_id = var.equinix_metal_organization_id } -provider "metal" { - auth_token = var.metal_auth_token +provider "equinix" { + auth_token = var.equinix_metal_auth_token } locals { ssh_key_name = "metal-key" - metal_project_id = var.metal_create_project ? metal_project.new_project[0].id : var.metal_project_id + metal_project_id = var.equinix_metal_create_project ? equinix_metal_project.new_project[0].id : var.equinix_metal_project_id } resource "tls_private_key" "ssh_key_pair" { @@ -18,7 +18,7 @@ resource "tls_private_key" "ssh_key_pair" { rsa_bits = 4096 } -resource "metal_ssh_key" "ssh_pub_key" { +resource "equinix_metal_ssh_key" "ssh_pub_key" { name = random_id.cloud.b64_url public_key = chomp(tls_private_key.ssh_key_pair.public_key_openssh) } @@ -35,12 +35,12 @@ resource "local_file" "cluster_public_key" { file_permission = "0600" } -resource "metal_device" "controller" { +resource "equinix_metal_device" "controller" { hostname = "controller" tags = ["openstack-${random_id.cloud.b64_url}"] operating_system = "ubuntu_18_04" - plan = var.metal_controller_type + plan = var.equinix_metal_controller_type connection { host = self.access_public_ipv4 type = "ssh" @@ -48,7 +48,6 @@ resource "metal_device" "controller" { private_key = local_file.cluster_private_key_pem.content } user_data = "#cloud-config\n\nssh_authorized_keys:\n - \"${local_file.cluster_public_key.content}\"" - facilities = var.metal_facilities project_id = local.metal_project_id billing_cycle = "hourly" # ip_address { @@ -57,12 +56,12 @@ resource "metal_device" "controller" { # } } -resource "metal_device" "dashboard" { +resource "equinix_metal_device" "dashboard" { hostname = "dashboard" tags = ["openstack-${random_id.cloud.hex} "] operating_system = "ubuntu_18_04" - plan = var.metal_dashboard_type + plan = var.equinix_metal_dashboard_type connection { host = self.access_public_ipv4 type = "ssh" @@ -71,19 +70,18 @@ resource "metal_device" "dashboard" { } user_data = "#cloud-config\n\nssh_authorized_keys:\n - \"${local_file.cluster_public_key.content}\"" - facilities = var.metal_facilities project_id = local.metal_project_id billing_cycle = "hourly" } -resource "metal_device" "compute-x86" { +resource "equinix_metal_device" "compute-x86" { hostname = format("compute-x86-%02d", count.index) tags = ["openstack-${random_id.cloud.hex} "] count = var.openstack_compute-x86_count operating_system = "ubuntu_18_04" - plan = var.metal_compute-x86_type + plan = var.equinix_metal_compute-x86_type connection { host = self.access_public_ipv4 type = "ssh" @@ -91,19 +89,18 @@ resource "metal_device" "compute-x86" { private_key = file(local_file.cluster_private_key_pem) } user_data = "#cloud-config\n\nssh_authorized_keys:\n - \"${local_file.cluster_public_key.content}\"" - facilities = var.metal_facilities project_id = local.metal_project_id billing_cycle = "hourly" } -resource "metal_device" "compute-arm" { +resource "equinix_metal_device" "compute-arm" { hostname = format("compute-arm-%02d", count.index) tags = ["openstack-${random_id.cloud.hex} "] count = var.openstack_compute-arm_count operating_system = "ubuntu_18_04" - plan = var.metal_compute-arm_type + plan = var.equinix_metal_compute-arm_type connection { host = self.access_public_ipv4 type = "ssh" @@ -111,7 +108,6 @@ resource "metal_device" "compute-arm" { private_key = file(local_file.cluster_private_key_pem) } user_data = "#cloud-config\n\nssh_authorized_keys:\n - \"${local_file.cluster_public_key.content}\"" - facilities = var.metal_facilities project_id = local.metal_project_id billing_cycle = "hourly" } diff --git a/DistributeKeys.tf b/DistributeKeys.tf index ad8dd30..e076f7e 100644 --- a/DistributeKeys.tf +++ b/DistributeKeys.tf @@ -4,7 +4,7 @@ resource "null_resource" "controller-distribute-keys" { connection { - host = metal_device.controller.access_public_ipv4 + host = equinix_metal_device.controller.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } @@ -23,7 +23,7 @@ resource "null_resource" "controller-distribute-keys" { resource "null_resource" "dashboard-distribute-keys" { connection { - host = metal_device.dashboard.access_public_ipv4 + host = equinix_metal_device.dashboard.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } diff --git a/Hostfile.tf b/Hostfile.tf index 6ec455d..c63f934 100644 --- a/Hostfile.tf +++ b/Hostfile.tf @@ -15,7 +15,7 @@ resource "null_resource" "controller-generate-hostfile" { depends_on = [null_resource.blank-hostfile] provisioner "local-exec" { - command = "echo ${metal_device.controller.access_private_ipv4} ${metal_device.controller.hostname} >> ${path.module}/assets/hostfile" + command = "echo ${equinix_metal_device.controller.access_private_ipv4} ${equinix_metal_device.controller.hostname} >> ${path.module}/assets/hostfile" } } @@ -23,7 +23,7 @@ resource "null_resource" "dashboard-generate-hostfile" { depends_on = [null_resource.blank-hostfile] provisioner "local-exec" { - command = "echo ${metal_device.dashboard.access_private_ipv4} ${metal_device.dashboard.hostname} >> ${path.module}/assets/hostfile" + command = "echo ${equinix_metal_device.dashboard.access_private_ipv4} ${equinix_metal_device.dashboard.hostname} >> ${path.module}/assets/hostfile" } } @@ -33,7 +33,7 @@ resource "null_resource" "compute-x86-generate-hostfile" { count = var.openstack_compute-x86_count provisioner "local-exec" { - command = "echo ${element(metal_device.compute-x86.*.access_private_ipv4, count.index)} ${element(metal_device.compute-x86.*.hostname, count.index)} >> ${path.module}/assets/hostfile" + command = "echo ${element(equinix_metal_device.compute-x86.*.access_private_ipv4, count.index)} ${element(equinix_metal_device.compute-x86.*.hostname, count.index)} >> ${path.module}/assets/hostfile" } } @@ -43,7 +43,7 @@ resource "null_resource" "compute-arm-generate-hostfile" { count = var.openstack_compute-arm_count provisioner "local-exec" { - command = "echo ${element(metal_device.compute-arm.*.access_private_ipv4, count.index)} ${element(metal_device.compute-arm.*.hostname, count.index)} >> ${path.module}/assets/hostfile" + command = "echo ${element(equinix_metal_device.compute-arm.*.access_private_ipv4, count.index)} ${element(equinix_metal_device.compute-arm.*.hostname, count.index)} >> ${path.module}/assets/hostfile" } } @@ -66,7 +66,7 @@ resource "null_resource" "controller-write-hostfile" { depends_on = [null_resource.hostfile-generated] connection { - host = metal_device.controller.access_public_ipv4 + host = equinix_metal_device.controller.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } @@ -86,7 +86,7 @@ resource "null_resource" "dashboard-write-hostfile" { depends_on = [null_resource.hostfile-generated] connection { - host = metal_device.dashboard.access_public_ipv4 + host = equinix_metal_device.dashboard.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } @@ -108,7 +108,7 @@ resource "null_resource" "compute-x86-write-hostfile" { count = var.openstack_compute-x86_count connection { - host = element(metal_device.compute-x86.*.access_public_ipv4, count.index) + host = element(equinix_metal_device.compute-x86.*.access_public_ipv4, count.index) private_key = local_file.cluster_private_key_pem.content } @@ -130,7 +130,7 @@ resource "null_resource" "compute-arm-write-hostfile" { count = var.openstack_compute-arm_count connection { - host = element(metal_device.compute-arm.*.access_public_ipv4, count.index) + host = element(equinix_metal_device.compute-arm.*.access_public_ipv4, count.index) private_key = local_file.cluster_private_key_pem.content } diff --git a/OpenStackDefaults.tf b/OpenStackDefaults.tf index 3996538..1bb2cb7 100644 --- a/OpenStackDefaults.tf +++ b/OpenStackDefaults.tf @@ -15,7 +15,7 @@ resource "null_resource" "openstack-image-CentOS-8-ARM" { count = var.openstack_compute-arm_count == 0 ? 0 : 1 connection { - host = metal_device.controller.access_public_ipv4 + host = equinix_metal_device.controller.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } @@ -45,7 +45,7 @@ resource "null_resource" "openstack-image-CentOS-8-x86" { count = var.openstack_compute-x86_count == 0 ? 0 : 1 connection { - host = metal_device.controller.access_public_ipv4 + host = equinix_metal_device.controller.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } @@ -75,7 +75,7 @@ resource "null_resource" "openstack-image-Fedora-ARM" { count = var.openstack_compute-arm_count == 0 ? 0 : 1 connection { - host = metal_device.controller.access_public_ipv4 + host = equinix_metal_device.controller.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } @@ -105,7 +105,7 @@ resource "null_resource" "openstack-image-Cirros-x86" { count = var.openstack_compute-x86_count == 0 ? 0 : 1 connection { - host = metal_device.controller.access_public_ipv4 + host = equinix_metal_device.controller.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } @@ -135,7 +135,7 @@ resource "null_resource" "openstack-image-Bionic-18_04-ARM" { count = var.openstack_compute-arm_count == 0 ? 0 : 1 connection { - host = metal_device.controller.access_public_ipv4 + host = equinix_metal_device.controller.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } @@ -166,7 +166,7 @@ resource "null_resource" "openstack-image-Bionic-18_04-x86" { count = var.openstack_compute-x86_count == 0 ? 0 : 1 connection { - host = metal_device.controller.access_public_ipv4 + host = equinix_metal_device.controller.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } @@ -196,7 +196,7 @@ resource "null_resource" "openstack-image-Trusty-14_04-ARM" { count = var.openstack_compute-arm_count == 0 ? 0 : 1 connection { - host = metal_device.controller.access_public_ipv4 + host = equinix_metal_device.controller.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } @@ -226,7 +226,7 @@ resource "null_resource" "openstack-image-Xenial-16_04-ARM" { count = var.openstack_compute-arm_count == 0 ? 0 : 1 connection { - host = metal_device.controller.access_public_ipv4 + host = equinix_metal_device.controller.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } @@ -256,7 +256,7 @@ resource "null_resource" "openstack-image-Cirros-ARM" { count = var.openstack_compute-arm_count == 0 ? 0 : 1 connection { - host = metal_device.controller.access_public_ipv4 + host = equinix_metal_device.controller.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } @@ -285,7 +285,7 @@ resource "null_resource" "openstack-flavors" { null_resource.controller-neutron] connection { - host = metal_device.controller.access_public_ipv4 + host = equinix_metal_device.controller.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } diff --git a/OpenStackSampleWorkload.tf b/OpenStackSampleWorkload.tf index 1906b14..b70b692 100644 --- a/OpenStackSampleWorkload.tf +++ b/OpenStackSampleWorkload.tf @@ -19,7 +19,7 @@ resource "null_resource" "openstack-sample-workload-common" { ] connection { - host = metal_device.controller.access_public_ipv4 + host = equinix_metal_device.controller.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } @@ -64,7 +64,7 @@ resource "null_resource" "openstack-sample-workload-arm" { count = var.openstack_compute-arm_count == 0 ? 0 : 1 connection { - host = metal_device.controller.access_public_ipv4 + host = equinix_metal_device.controller.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } @@ -102,7 +102,7 @@ resource "null_resource" "openstack-sample-workload-x86" { count = var.openstack_compute-x86_count == 0 ? 0 : 1 connection { - host = metal_device.controller.access_public_ipv4 + host = equinix_metal_device.controller.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } diff --git a/ProviderNetwork.tf b/ProviderNetwork.tf index 1970218..ab7a37b 100644 --- a/ProviderNetwork.tf +++ b/ProviderNetwork.tf @@ -3,9 +3,8 @@ # # use private IPv4 addresses to save precious Internet resources -data "metal_precreated_ip_block" "private_ipv4" { +data "equinix_metal_precreated_ip_block" "private_ipv4" { - facility = metal_device.controller.deployed_facility project_id = local.metal_project_id address_family = 4 public = false @@ -13,27 +12,26 @@ data "metal_precreated_ip_block" "private_ipv4" { } # /28 provides 16 IPs -resource "metal_ip_attachment" "controller_private_ipv4" { +resource "equinix_metal_ip_attachment" "controller_private_ipv4" { - device_id = metal_device.controller.id - cidr_notation = cidrsubnet(data.metal_precreated_ip_block.private_ipv4.cidr_notation, 3, 1) + device_id = equinix_metal_device.controller.id + cidr_notation = cidrsubnet(data.equinix_metal_precreated_ip_block.private_ipv4.cidr_notation, 3, 1) } # ipv6 is free so let's go crazy -data "metal_precreated_ip_block" "public_ipv6" { +data "equinix_metal_precreated_ip_block" "public_ipv6" { - facility = metal_device.controller.deployed_facility project_id = local.metal_project_id address_family = 6 public = true } -resource "metal_ip_attachment" "controller_public_ipv6" { +resource "equinix_metal_ip_attachment" "controller_public_ipv6" { - device_id = metal_device.controller.id - cidr_notation = cidrsubnet(data.metal_precreated_ip_block.public_ipv6.cidr_notation, 8, 1) + device_id = equinix_metal_device.controller.id + cidr_notation = cidrsubnet(data.equinix_metal_precreated_ip_block.public_ipv6.cidr_notation, 8, 1) } @@ -43,8 +41,8 @@ data "template_file" "network-interfaces-br-public" { vars = { # Use the first IP in each subnet for gateway - provider_ipv4_cidr = join("/", [cidrhost(metal_ip_attachment.controller_private_ipv4.cidr_notation, 1), metal_ip_attachment.controller_private_ipv4.cidr]) - provider_ipv6_cidr = join("/", [cidrhost(metal_ip_attachment.controller_public_ipv6.cidr_notation, 1), metal_ip_attachment.controller_public_ipv6.cidr]) + provider_ipv4_cidr = join("/", [cidrhost(equinix_metal_ip_attachment.controller_private_ipv4.cidr_notation, 1), equinix_metal_ip_attachment.controller_private_ipv4.cidr]) + provider_ipv6_cidr = join("/", [cidrhost(equinix_metal_ip_attachment.controller_public_ipv6.cidr_notation, 1), equinix_metal_ip_attachment.controller_public_ipv6.cidr]) } } @@ -52,7 +50,7 @@ resource "null_resource" "enable-br-public" { depends_on = [null_resource.controller-keystone] connection { - host = metal_device.controller.access_public_ipv4 + host = equinix_metal_device.controller.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } @@ -77,8 +75,8 @@ data "template_file" "provider-networks" { vars = { ADMIN_PASS = random_password.os_admin_password.result - provider_ipv4_cidr = metal_ip_attachment.controller_private_ipv4.cidr_notation - provider_ipv6_cidr = metal_ip_attachment.controller_public_ipv6.cidr_notation + provider_ipv4_cidr = equinix_metal_ip_attachment.controller_private_ipv4.cidr_notation + provider_ipv6_cidr = equinix_metal_ip_attachment.controller_public_ipv6.cidr_notation } } @@ -87,7 +85,7 @@ resource "null_resource" "controller-provider-networks" { null_resource.openstack-sample-workload-common] connection { - host = metal_device.controller.access_public_ipv4 + host = equinix_metal_device.controller.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } diff --git a/RemoveLocalhostHostfile.tf b/RemoveLocalhostHostfile.tf index a88a00c..89e2424 100644 --- a/RemoveLocalhostHostfile.tf +++ b/RemoveLocalhostHostfile.tf @@ -4,7 +4,7 @@ resource "null_resource" "controller-removelocalhost-hostfile" { connection { - host = metal_device.controller.access_public_ipv4 + host = equinix_metal_device.controller.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } @@ -22,7 +22,7 @@ resource "null_resource" "controller-removelocalhost-hostfile" { resource "null_resource" "dashboard-removelocalhost-hostfile" { connection { - host = metal_device.dashboard.access_public_ipv4 + host = equinix_metal_device.dashboard.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } @@ -37,7 +37,7 @@ resource "null_resource" "compute-x86-removelocalhost-hostfile" { count = var.openstack_compute-x86_count connection { - host = element(metal_device.compute-x86.*.access_public_ipv4, count.index) + host = element(equinix_metal_device.compute-x86.*.access_public_ipv4, count.index) private_key = local_file.cluster_private_key_pem.content } @@ -52,7 +52,7 @@ resource "null_resource" "compute-arm-removelocalhost-hostfile" { count = var.openstack_compute-arm_count connection { - host = element(metal_device.compute-arm.*.access_public_ipv4, count.index) + host = element(equinix_metal_device.compute-arm.*.access_public_ipv4, count.index) private_key = local_file.cluster_private_key_pem.content } diff --git a/main.tf b/main.tf index 62ce5be..9d98779 100644 --- a/main.tf +++ b/main.tf @@ -23,7 +23,7 @@ resource "null_resource" "controller-keystone" { depends_on = [null_resource.hostfile-distributed] connection { - host = metal_device.controller.access_public_ipv4 + host = equinix_metal_device.controller.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } @@ -58,7 +58,7 @@ resource "null_resource" "controller-glance" { depends_on = [null_resource.controller-keystone] connection { - host = metal_device.controller.access_public_ipv4 + host = equinix_metal_device.controller.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } @@ -86,7 +86,7 @@ resource "null_resource" "controller-nova" { depends_on = [null_resource.controller-glance] connection { - host = metal_device.controller.access_public_ipv4 + host = equinix_metal_device.controller.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } @@ -97,7 +97,7 @@ resource "null_resource" "controller-nova" { provisioner "remote-exec" { inline = [ - "bash ControllerNova.sh ${metal_device.controller.access_public_ipv4} ${metal_device.controller.access_private_ipv4} > ControllerNova.out", + "bash ControllerNova.sh ${equinix_metal_device.controller.access_public_ipv4} ${equinix_metal_device.controller.access_private_ipv4} > ControllerNova.out", ] } } @@ -115,7 +115,7 @@ resource "null_resource" "controller-neutron" { null_resource.enable-br-public] connection { - host = metal_device.controller.access_public_ipv4 + host = equinix_metal_device.controller.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } @@ -126,7 +126,7 @@ resource "null_resource" "controller-neutron" { provisioner "remote-exec" { inline = [ - "bash ControllerNeutron.sh ${metal_device.controller.access_public_ipv4} ${metal_device.controller.access_private_ipv4} > ControllerNeutron.out", + "bash ControllerNeutron.sh ${equinix_metal_device.controller.access_public_ipv4} ${equinix_metal_device.controller.access_private_ipv4} > ControllerNeutron.out", ] } } @@ -135,7 +135,7 @@ resource "null_resource" "dashboard-install" { depends_on = [null_resource.hostfile-distributed] connection { - host = metal_device.dashboard.access_public_ipv4 + host = equinix_metal_device.dashboard.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } @@ -161,7 +161,7 @@ resource "null_resource" "dashboard-config" { depends_on = [null_resource.dashboard-install] connection { - host = metal_device.dashboard.access_public_ipv4 + host = equinix_metal_device.dashboard.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } @@ -193,7 +193,7 @@ resource "null_resource" "compute-x86-common" { count = var.openstack_compute-x86_count connection { - host = element(metal_device.compute-x86.*.access_public_ipv4, count.index) + host = element(equinix_metal_device.compute-x86.*.access_public_ipv4, count.index) private_key = local_file.cluster_private_key_pem.content } @@ -231,7 +231,7 @@ resource "null_resource" "compute-x86-openstack" { count = var.openstack_compute-x86_count connection { - host = element(metal_device.compute-x86.*.access_public_ipv4, count.index) + host = element(equinix_metal_device.compute-x86.*.access_public_ipv4, count.index) private_key = local_file.cluster_private_key_pem.content } @@ -247,8 +247,8 @@ resource "null_resource" "compute-x86-openstack" { provisioner "remote-exec" { inline = [ - "bash ComputeNova.sh ${metal_device.controller.access_public_ipv4} ${metal_device.controller.access_private_ipv4} > ComputeNova.out", - "bash ComputeNeutron.sh ${metal_device.controller.access_public_ipv4} ${metal_device.controller.access_private_ipv4} > ComputeNeutron.out", + "bash ComputeNova.sh ${equinix_metal_device.controller.access_public_ipv4} ${equinix_metal_device.controller.access_private_ipv4} > ComputeNova.out", + "bash ComputeNeutron.sh ${equinix_metal_device.controller.access_public_ipv4} ${equinix_metal_device.controller.access_private_ipv4} > ComputeNeutron.out", ] } } @@ -259,7 +259,7 @@ resource "null_resource" "compute-arm-common" { count = var.openstack_compute-arm_count connection { - host = element(metal_device.compute-arm.*.access_public_ipv4, count.index) + host = element(equinix_metal_device.compute-arm.*.access_public_ipv4, count.index) private_key = local_file.cluster_private_key_pem.content } @@ -281,7 +281,7 @@ resource "null_resource" "compute-arm-openstack" { count = var.openstack_compute-arm_count connection { - host = element(metal_device.compute-arm.*.access_public_ipv4, count.index) + host = element(equinix_metal_device.compute-arm.*.access_public_ipv4, count.index) private_key = local_file.cluster_private_key_pem.content } @@ -297,8 +297,8 @@ resource "null_resource" "compute-arm-openstack" { provisioner "remote-exec" { inline = [ - "bash ComputeNova.sh ${metal_device.controller.access_public_ipv4} ${metal_device.controller.access_private_ipv4} > ComputeNova.out", - "bash ComputeNeutron.sh ${metal_device.controller.access_public_ipv4} ${metal_device.controller.access_private_ipv4} > ComputeNeutron.out", + "bash ComputeNova.sh ${equinix_metal_device.controller.access_public_ipv4} ${equinix_metal_device.controller.access_private_ipv4} > ComputeNova.out", + "bash ComputeNeutron.sh ${equinix_metal_device.controller.access_public_ipv4} ${equinix_metal_device.controller.access_private_ipv4} > ComputeNeutron.out", ] } } @@ -314,7 +314,7 @@ resource "null_resource" "controller-register-compute-hosts" { null_resource.controller-nova] connection { - host = metal_device.controller.access_public_ipv4 + host = equinix_metal_device.controller.access_public_ipv4 private_key = local_file.cluster_private_key_pem.content } diff --git a/outputs.tf b/outputs.tf index bc803ab..b2de6a6 100644 --- a/outputs.tf +++ b/outputs.tf @@ -5,37 +5,37 @@ output "Cloud_ID_Tag" { output "Controller_Type" { description = "Controller Node Plan" - value = metal_device.controller.plan + value = equinix_metal_device.controller.plan } output "Compute_x86_Type" { description = "x86 Compute Node Plan" - value = metal_device.compute-x86.*.plan + value = equinix_metal_device.compute-x86.*.plan } output "Compute_ARM_Type" { description = "ARM Compute Node Plan" - value = metal_device.compute-arm.*.plan + value = equinix_metal_device.compute-arm.*.plan } output "Compute_x86_IPs" { description = "x86 Compute Node Addresses" - value = metal_device.compute-x86.*.access_public_ipv4 + value = equinix_metal_device.compute-x86.*.access_public_ipv4 } output "Compute_ARM_IPs" { description = "ARM Compute Node Addresses" - value = metal_device.compute-arm.*.access_public_ipv4 + value = equinix_metal_device.compute-arm.*.access_public_ipv4 } output "OpenStack_API_Endpoint" { description = "OpenStack IPv4 API Endpoint" - value = "http://${metal_device.controller.access_public_ipv4}:5000/v3" + value = "http://${equinix_metal_device.controller.access_public_ipv4}:5000/v3" } output "OpenStack_API_Endpoint_ipv6" { description = "OpenStack IPv6 API Endpoint" - value = "http://[${metal_device.controller.access_public_ipv6}]:5000/v3" + value = "http://[${equinix_metal_device.controller.access_public_ipv6}]:5000/v3" } output "OpenStack_admin_pass" { @@ -46,32 +46,32 @@ output "OpenStack_admin_pass" { output "Horizon_dashboard_via_IP" { description = "Access OpenStack Dashboard over IPv4" - value = "http://${metal_device.dashboard.access_public_ipv4}/horizon/ default/admin/${random_password.os_admin_password.result}" + value = "http://${equinix_metal_device.dashboard.access_public_ipv4}/horizon/ default/admin/${random_password.os_admin_password.result}" } output "Horizon_dashboard_via_IP6" { description = "Access OpenStack Dashboard over IPv6" - value = "http://[${metal_device.dashboard.access_public_ipv6}]/horizon/ default/admin/${random_password.os_admin_password.result}" + value = "http://[${equinix_metal_device.dashboard.access_public_ipv6}]/horizon/ default/admin/${random_password.os_admin_password.result}" } output "Controller_SSH" { description = "SSH command to access OpenStack controller instance over IPv4" - value = "ssh root@${metal_device.controller.access_public_ipv4} -i ${local_file.cluster_private_key_pem.filename}" + value = "ssh root@${equinix_metal_device.controller.access_public_ipv4} -i ${local_file.cluster_private_key_pem.filename}" } output "Controller_SSH6" { description = "SSH command to access OpenStack controller instance over IPv6" - value = "ssh root@${metal_device.controller.access_public_ipv6} -i ${local_file.cluster_private_key_pem.filename}" + value = "ssh root@${equinix_metal_device.controller.access_public_ipv6} -i ${local_file.cluster_private_key_pem.filename}" } output "Controller_Provider_Private_IPv4" { description = "OpenStack Contoller IPv4 Address" - value = metal_ip_attachment.controller_private_ipv4.cidr_notation + value = equinix_metal_ip_attachment.controller_private_ipv4.cidr_notation } output "Controller_Provider_Public_IPv6" { description = "OpenStack Contoller IPv6 Address" - value = metal_ip_attachment.controller_public_ipv6.cidr_notation + value = equinix_metal_ip_attachment.controller_public_ipv6.cidr_notation } #output "Horizon dashboard via DNS" { diff --git a/sample-arm.terraform.tfvars b/sample-arm.terraform.tfvars index 6248602..962bccd 100644 --- a/sample-arm.terraform.tfvars +++ b/sample-arm.terraform.tfvars @@ -11,7 +11,6 @@ metal_compute-arm_type = "c2.large.arm" openstack_compute-arm_count = 1 openstack_compute-x86_count = 0 -metal_facilities = ["ewr1"] # Use an existing project: # metal_create_project = false diff --git a/sample-gen2.terraform.tfvars b/sample-gen2.terraform.tfvars index 55f6255..b4858f4 100644 --- a/sample-gen2.terraform.tfvars +++ b/sample-gen2.terraform.tfvars @@ -12,5 +12,4 @@ metal_compute-x86_type = "n2.xlarge.x86" openstack_compute-arm_count = 1 openstack_compute-x86_count = 1 -metal_facilities = ["dfw2"] diff --git a/sample-gen3.terraform.tfvars b/sample-gen3.terraform.tfvars index 01949f4..fc2f1b0 100644 --- a/sample-gen3.terraform.tfvars +++ b/sample-gen3.terraform.tfvars @@ -11,7 +11,6 @@ metal_compute-x86_type = "s3.xlarge.x86" openstack_compute-arm_count = 1 openstack_compute-x86_count = 1 -metal_facilities = ["dfw2"] # Use an existing project: # metal_create_project = false diff --git a/sample.terraform.tfvars b/sample.terraform.tfvars index 11a5191..cd915b0 100644 --- a/sample.terraform.tfvars +++ b/sample.terraform.tfvars @@ -14,7 +14,6 @@ metal_compute-x86_type = "n2.xlarge.x86" openstack_compute-arm_count = 1 openstack_compute-x86_count = 1 -metal_facilities = ["sjc1"] # Use an existing project: # metal_create_project = false diff --git a/variables.tf b/variables.tf index 2a929c2..bc91a3e 100644 --- a/variables.tf +++ b/variables.tf @@ -1,48 +1,42 @@ -variable "metal_auth_token" { +variable "equinix_metal_auth_token" { description = "Your metal API key" } -# for best results deploy all hosts in the same facility - list a single facility -variable "metal_facilities" { - description = "Metal facilities: US East(ewr1), US West(sjc1), Tokyo (nrt1) or EU(ams1). Default: ewr1" - default = ["sjc1"] -} - -variable "metal_project_id" { +variable "equinix_metal_project_id" { type = string default = "null" description = "Equinix Metal Project ID" } -variable "metal_organization_id" { +variable "equinix_metal_organization_id" { type = string default = "null" description = "Equinix Metal Organization ID" } -variable "metal_create_project" { +variable "equinix_metal_create_project" { type = bool default = true description = "Create a Metal Project if this is 'true'. Else use provided 'metal_project_id'" } -variable "metal_project_name" { +variable "equinix_metal_project_name" { type = string default = "terraform-metal-openstack" description = "The name of the Metal project if 'create_project' is 'true'." } -variable "metal_controller_type" { +variable "equinix_metal_controller_type" { description = "Instance type of OpenStack controller" default = "c3.medium.x86" } -variable "metal_dashboard_type" { +variable "equinix_metal_dashboard_type" { description = "Instance type of OpenStack dashboard" default = "c3.medium.x86" } -variable "metal_compute-x86_type" { +variable "equinix_metal_compute-x86_type" { description = "Instance type of OpenStack x86 compute nodes" default = "c3.medium.x86" } @@ -52,7 +46,7 @@ variable "openstack_compute-x86_count" { default = 1 } -variable "metal_compute-arm_type" { +variable "equinix_metal_compute-arm_type" { description = "Instance type of OpenStack ARM compute nodes" default = "c2.large.arm" } diff --git a/versions.tf b/versions.tf index 4ca09b4..a193a3e 100644 --- a/versions.tf +++ b/versions.tf @@ -5,9 +5,9 @@ terraform { null = { source = "hashicorp/null" } - metal = { - source = "equinix/metal" - version = "1.0.0" + equinix = { + source = "equinix/equinix" + version = "~> 1.14" } random = { source = "hashicorp/random" @@ -16,4 +16,7 @@ terraform { source = "hashicorp/template" } } + provider_meta "equinix" { + module_name = "equinix-metal-openstack" + } }