Skip to content

Commit

Permalink
Merge pull request #64 from vasubabu/vk_module_name
Browse files Browse the repository at this point in the history
Add provider equinix and module_name in Equinix Metal TF configs
  • Loading branch information
ctreatma authored May 10, 2023
2 parents 47fe723 + 1574937 commit 1427533
Show file tree
Hide file tree
Showing 15 changed files with 102 additions and 115 deletions.
36 changes: 16 additions & 20 deletions BareMetal.tf
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
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" {
algorithm = "RSA"
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)
}
Expand All @@ -35,20 +35,19 @@ 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"
user = "root"
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 {
Expand All @@ -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"
Expand All @@ -71,47 +70,44 @@ 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"
user = "root"
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"
user = "root"
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"
}
Expand Down
4 changes: 2 additions & 2 deletions DistributeKeys.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down
16 changes: 8 additions & 8 deletions Hostfile.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ 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"
}
}

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"
}
}

Expand All @@ -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"
}
}

Expand All @@ -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"
}
}

Expand All @@ -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
}

Expand All @@ -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
}

Expand All @@ -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
}

Expand All @@ -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
}

Expand Down
20 changes: 10 additions & 10 deletions OpenStackDefaults.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions OpenStackSampleWorkload.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down
Loading

0 comments on commit 1427533

Please sign in to comment.