diff --git a/README.md b/README.md index 6593dfc..fe29638 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,7 @@ The Nutanix devices have `sshd` configured with `MaxSessions 1`. In most cases t Error messages that match this problem: - `Error chmodding script file to 0777 in remote machine: ssh: rejected: administratively prohibited (open failed)` +- `Failed to upload script: ssh: rejected: administratively prohibited (open failed)` ### VLAN Cleanup Failure @@ -168,6 +169,10 @@ terraform destroy This POC project has not ironed out all potential networking and provisioning timing hiccups that can occur. In many situations, running `terraform apply` again will progress the deployment to the next step. If you do not see progress after 3 attempts, open an issue on GitHub: . +Error messages that match this problem: + +- `timeout while waiting for state to become 'active, failed' (last state: 'provisioning', timeout:` + ## Examples To view examples for how you can leverage this module, please see the [examples](examples/) directory. diff --git a/examples/nutanix-clusters/README.md b/examples/nutanix-clusters/README.md index 53f2a1c..9510193 100644 --- a/examples/nutanix-clusters/README.md +++ b/examples/nutanix-clusters/README.md @@ -50,27 +50,65 @@ This example demonstrates how to create two Nutanix clusters and set up a protec ``` 1.4. Network Topology: - ![Network Topology](assets/NutanixClusterTopology.jpg) + + ```mermaid + graph TD + Internet[Internet 🌐] + + A[Common VRF: 192.168.96.0/21] + + subgraph ClusterA["Cluster A"] + direction TB + A1[VLAN A] + A2[VRF IP Reservation: 192.168.96.0/22] + A3[Gateway A] + A4[Bastion A <DHCP,NTP,NAT>] + A5[Nutanix Nodes A] + end + + subgraph ClusterB["Cluster B"] + direction TB + B1[VLAN B] + B2[VRF IP Reservation: 192.168.100.0/22] + B3[Gateway B] + B4[Bastion B <DHCP,NTP,NAT>] + B5[Nutanix Nodes B] + end + + A -->|192.168.96.0/22| A1 + A1 --> A2 + A2 --> A3 + A3 --> A4 + A4 --> A5 + A -->|192.168.100.0/22| B1 + B1 --> B2 + B2 --> B3 + B3 --> B4 + B4 --> B5 + + Internet --> A4 + Internet --> B4 + ``` 1.5. After a successful run, the expected output is: - ``` + ```console Outputs: nutanix_cluster1_bastion_public_ip = "145.40.91.33" nutanix_cluster1_cvim_ip_address = "192.168.97.57" nutanix_cluster1_iscsi_data_services_ip = "192.168.99.253" nutanix_cluster1_prism_central_ip_address = "192.168.99.252" - nutanix_cluster1_ssh_forward_command = "ssh -L 9440:192.168.97.57:9440 -L 19440:192.168.99.252:9440 -i /Users/vasubabu/Equinix/terraform-equinix-metal-nutanix-cluster/examples/nutanix-clusters/ssh-key-qh0f2 root@145.40.91.33" - nutanix_cluster1_ssh_private_key = "/Users/vasubabu/Equinix/terraform-equinix-metal-nutanix-cluster/examples/nutanix-clusters/ssh-key-qh0f2" + nutanix_cluster1_ssh_forward_command = "ssh -L 9440:192.168.97.57:9440 -L 19440:192.168.99.252:9440 -i /Users/username/terraform-equinix-metal-nutanix-cluster/examples/nutanix-clusters/ssh-key-qh0f2 root@145.40.91.33" + nutanix_cluster1_ssh_private_key = "/Users/example/terraform-equinix-metal-nutanix-cluster/examples/nutanix-clusters/ssh-key-qh0f2" nutanix_cluster1_virtual_ip_address = "192.168.99.254" nutanix_cluster2_bastion_public_ip = "145.40.91.141" nutanix_cluster2_cvim_ip_address = "192.168.102.176" nutanix_cluster2_iscsi_data_services_ip = "192.168.103.253" nutanix_cluster2_prism_central_ip_address = "192.168.103.252" - nutanix_cluster2_ssh_forward_command = "ssh -L 9442:192.168.102.176:9440 -L 19442:192.168.103.252:9440 -i /Users/vasubabu/Equinix/terraform-equinix-metal-nutanix-cluster/examples/nutanix-clusters/ssh-key-lha20 root@145.40.91.141" - nutanix_cluster2_ssh_private_key = "/Users/vasubabu/Equinix/terraform-equinix-metal-nutanix-cluster/examples/nutanix-clusters/ssh-key-lha20" + nutanix_cluster2_ssh_forward_command = "ssh -L 9442:192.168.102.176:9440 -L 19442:192.168.103.252:9440 -i /Users/example/Equinix/terraform-equinix-metal-nutanix-cluster/examples/nutanix-clusters/ssh-key-lha20 root@145.40.91.141" + nutanix_cluster2_ssh_private_key = "/Users/example/Equinix/terraform-equinix-metal-nutanix-cluster/examples/nutanix-clusters/ssh-key-lha20" nutanix_cluster2_virtual_ip_address = "192.168.103.254" ``` @@ -78,10 +116,28 @@ This example demonstrates how to create two Nutanix clusters and set up a protec 1. **Set up network resources to connect the clusters** + Let's start by simplifying how we access the Terraform outputs from the previous step. We'll make heavy use of these outputs as variables in the following steps. + + ```sh + terraform output | wc -l + grep -c output\ \" outputs.tf + ``` + + If you didn't reach a successful deployment in the previous steps, you will be missing variables needed in the following steps. If the following command doesn't show the same number twice, please check the known issues before moving ahead. + + Now export the outputs to their own shell environment variables. Keep in mind, these variables are only available where you ran Terraform, not within the bastion or Nutanix nodes. + + ```sh + eval $(terraform output | sed 's/ = /=/') + ``` + 1.1. Access Cluster 1: ```sh - ssh -L 9440:192.168.97.57:9440 -L 19440:192.168.99.252:9440 -i /Users/vasubabu/Equinix/terraform-equinix-metal-nutanix-cluster/examples/nutanix-clusters/ssh-key-qh0f2 root@145.40.91.33 + ssh -L 9440:$nutanix_cluster1_cvim_ip_address:9440 \ + -L 19440:$nutanix_cluster1_cvim_ip_address:9440 \ + -i $nutanix_cluster1_ssh_private_key \ + root@$nutanix_cluster1_bastion_public_ip ``` 1.2. Follow the instructions to change the password of Cluster 1: @@ -90,27 +146,36 @@ This example demonstrates how to create two Nutanix clusters and set up a protec 1.3. Access Cluster 2: ```sh - ssh -L 9442:192.168.102.176:9440 -L 19442:192.168.103.252:9440 -i /Users/vasubabu/Equinix/terraform-equinix-metal-nutanix-cluster/examples/nutanix-clusters/ssh-key-lha20 root@145.40.91.141 + ssh -L 9440:$nutanix_cluster2_cvim_ip_address:9440 \ + -L 19440:$nutanix_cluster2_cvim_ip_address:9440 \ + -i $nutanix_cluster2_ssh_private_key \ + root@$nutanix_cluster2_bastion_public_ip ``` 1.4. Follow the instructions to change the password of Cluster 2: [Nutanix Metal Workshop - Access Prism UI](https://equinix-labs.github.io/nutanix-on-equinix-metal-workshop/parts/3-access_prism_ui/) - 1.5. Run the firewall rules to establish connectivity between the two clusters: + 1.5. Add a route to establish connectivity between the two clusters: 1.5.1. On Cluster 1: ```sh - ssh -L 9440:192.168.97.57:9440 -L 19440:192.168.99.252:9440 -i /Users/vasubabu/Equinix/terraform-equinix-metal-nutanix-cluster/examples/nutanix-clusters/ssh-key-qh0f2 root@145.40.91.33 - ssh admin@192.168.97.57 + ssh -L 9440:$nutanix_cluster1_cvim_ip_address:9440 \ + -L 19440:$nutanix_cluster1_cvim_ip_address:9440 \ + -i $nutanix_cluster1_ssh_private_key \ + -J root@$nutanix_cluster1_bastion_public_ip \ + admin@$nutanix_cluster1_cvim_ip_address sudo ip route add 192.168.100.0/22 via 192.168.96.1 ``` 1.5.2. On Cluster 2: ```sh - ssh -L 9442:192.168.102.176:9440 -L 19442:192.168.103.252:9440 -i /Users/vasubabu/Equinix/terraform-equinix-metal-nutanix-cluster/examples/nutanix-clusters/ssh-key-lha20 root@145.40.91.141 - ssh admin@192.168.102.176 + ssh -L 9440:$nutanix_cluster2_cvim_ip_address:9440 \ + -L 19440:$nutanix_cluster2_cvim_ip_address:9440 \ + -i $nutanix_cluster2_ssh_private_key \ + -J root@$nutanix_cluster2_bastion_public_ip \ + admin@$nutanix_cluster2_cvim_ip_address sudo ip route add 192.168.96.0/22 via 192.168.100.1 ``` @@ -167,3 +232,84 @@ This example demonstrates how to create two Nutanix clusters and set up a protec After migration is initiated, it will take a while. You can see the progress in recent tasks. ![Migrate Progress](assets/MigrateProgress.jpg) ![Migrate Success](assets/MigrateSuccess.jpg) + + + +## Requirements + +| Name | Version | +|------|---------| +| [terraform](#requirement\_terraform) | >= 1.0 | +| [equinix](#requirement\_equinix) | >= 1.30 | +| [local](#requirement\_local) | >= 2.5 | +| [null](#requirement\_null) | >= 3 | +| [random](#requirement\_random) | >= 3 | + +## Providers + +| Name | Version | +|------|---------| +| [equinix](#provider\_equinix) | >= 1.30 | +| [random](#provider\_random) | >= 3 | + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [nutanix\_cluster1](#module\_nutanix\_cluster1) | equinix-labs/metal-nutanix-cluster/equinix | 0.4.0 | +| [nutanix\_cluster2](#module\_nutanix\_cluster2) | equinix-labs/metal-nutanix-cluster/equinix | 0.4.0 | + +## Resources + +| Name | Type | +|------|------| +| [equinix_metal_project.nutanix](https://registry.terraform.io/providers/equinix/equinix/latest/docs/resources/metal_project) | resource | +| [equinix_metal_vrf.nutanix](https://registry.terraform.io/providers/equinix/equinix/latest/docs/resources/metal_vrf) | resource | +| [random_string.vrf_name_suffix](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) | resource | +| [equinix_metal_project.nutanix](https://registry.terraform.io/providers/equinix/equinix/latest/docs/data-sources/metal_project) | data source | +| [equinix_metal_vrf.nutanix](https://registry.terraform.io/providers/equinix/equinix/latest/docs/data-sources/metal_vrf) | data source | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [metal\_auth\_token](#input\_metal\_auth\_token) | Equinix Metal API token. | `string` | n/a | yes | +| [metal\_metro](#input\_metal\_metro) | The metro to create the cluster in. | `string` | n/a | yes | +| [cluster\_subnet](#input\_cluster\_subnet) | nutanix cluster subnet | `string` | `"192.168.100.0/22"` | no | +| [create\_project](#input\_create\_project) | (Optional) to use an existing project matching `metal_project_name`, set this to false. | `bool` | `true` | no | +| [create\_vlan](#input\_create\_vlan) | Whether to create a new VLAN for this project. | `bool` | `true` | no | +| [create\_vrf](#input\_create\_vrf) | Whether to create a new VRF for this project. | `bool` | `true` | no | +| [metal\_bastion\_plan](#input\_metal\_bastion\_plan) | The plan to use for the bastion host. | `string` | `"t3.small.x86"` | no | +| [metal\_nutanix\_os](#input\_metal\_nutanix\_os) | The operating system to use for the Nutanix nodes. | `string` | `"ubuntu_20_04"` | no | +| [metal\_nutanix\_plan](#input\_metal\_nutanix\_plan) | The plan to use for the Nutanix nodes. | `string` | `"c3.small.x86"` | no | +| [metal\_organization\_id](#input\_metal\_organization\_id) | The ID of the Metal organization in which to create the project if `create_project` is true. | `string` | `null` | no | +| [metal\_project\_id](#input\_metal\_project\_id) | The ID of the Metal project in which to deploy to cluster. If `create_project` is false and
you do not specify a project name, the project will be looked up by ID. One (and only one) of
`metal_project_name` or `metal_project_id` is required or `metal_project_id` must be set. | `string` | `""` | no | +| [metal\_project\_name](#input\_metal\_project\_name) | The name of the Metal project in which to deploy the cluster. If `create_project` is false and
you do not specify a project ID, the project will be looked up by name. One (and only one) of
`metal_project_name` or `metal_project_id` is required or `metal_project_id` must be set.
Required if `create_project` is true. | `string` | `""` | no | +| [metal\_subnet](#input\_metal\_subnet) | Nutanix cluster subnet. | `string` | `"192.168.96.0/21"` | no | +| [metal\_vlan\_description](#input\_metal\_vlan\_description) | Description to add to created VLAN. | `string` | `"ntnx-demo"` | no | +| [metal\_vlan\_id](#input\_metal\_vlan\_id) | ID of the VLAN you wish to use. | `number` | `null` | no | +| [nutanix\_node\_count](#input\_nutanix\_node\_count) | The number of Nutanix nodes to create. | `number` | `2` | no | +| [skip\_cluster\_creation](#input\_skip\_cluster\_creation) | Skip the creation of the Nutanix cluster. | `bool` | `false` | no | +| [vrf\_id](#input\_vrf\_id) | ID of the VRF you wish to use. | `string` | `null` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [nutanix\_cluster1\_bastion\_public\_ip](#output\_nutanix\_cluster1\_bastion\_public\_ip) | The public IP address of the bastion host | +| [nutanix\_cluster1\_cluster\_gateway](#output\_nutanix\_cluster1\_cluster\_gateway) | The Nutanix cluster gateway IP | +| [nutanix\_cluster1\_cvim\_ip\_address](#output\_nutanix\_cluster1\_cvim\_ip\_address) | The IP address of the CVM | +| [nutanix\_cluster1\_iscsi\_data\_services\_ip](#output\_nutanix\_cluster1\_iscsi\_data\_services\_ip) | Reserved IP for cluster ISCSI Data Services IP | +| [nutanix\_cluster1\_prism\_central\_ip\_address](#output\_nutanix\_cluster1\_prism\_central\_ip\_address) | Reserved IP for Prism Central VM | +| [nutanix\_cluster1\_ssh\_forward\_command](#output\_nutanix\_cluster1\_ssh\_forward\_command) | SSH port forward command to use to connect to the Prism GUI | +| [nutanix\_cluster1\_ssh\_private\_key](#output\_nutanix\_cluster1\_ssh\_private\_key) | The SSH keypair's private key for cluster1 | +| [nutanix\_cluster1\_virtual\_ip\_address](#output\_nutanix\_cluster1\_virtual\_ip\_address) | Reserved IP for cluster virtal IP | +| [nutanix\_cluster2\_bastion\_public\_ip](#output\_nutanix\_cluster2\_bastion\_public\_ip) | The public IP address of the bastion host | +| [nutanix\_cluster2\_cluster\_gateway](#output\_nutanix\_cluster2\_cluster\_gateway) | The Nutanix cluster gateway IP | +| [nutanix\_cluster2\_cvim\_ip\_address](#output\_nutanix\_cluster2\_cvim\_ip\_address) | The IP address of the CVM | +| [nutanix\_cluster2\_iscsi\_data\_services\_ip](#output\_nutanix\_cluster2\_iscsi\_data\_services\_ip) | Reserved IP for cluster ISCSI Data Services IP | +| [nutanix\_cluster2\_prism\_central\_ip\_address](#output\_nutanix\_cluster2\_prism\_central\_ip\_address) | Reserved IP for Prism Central VM | +| [nutanix\_cluster2\_ssh\_forward\_command](#output\_nutanix\_cluster2\_ssh\_forward\_command) | SSH port forward command to use to connect to the Prism GUI | +| [nutanix\_cluster2\_ssh\_private\_key](#output\_nutanix\_cluster2\_ssh\_private\_key) | The SSH keypair's private key for cluster1 | +| [nutanix\_cluster2\_virtual\_ip\_address](#output\_nutanix\_cluster2\_virtual\_ip\_address) | Reserved IP for cluster virtal IP | + diff --git a/examples/nutanix-clusters/assets/NutanixClusterTopology.jpg b/examples/nutanix-clusters/assets/NutanixClusterTopology.jpg deleted file mode 100644 index c2c7a73..0000000 Binary files a/examples/nutanix-clusters/assets/NutanixClusterTopology.jpg and /dev/null differ diff --git a/examples/nutanix-clusters/main.tf b/examples/nutanix-clusters/main.tf index 6fa7303..e37f46b 100644 --- a/examples/nutanix-clusters/main.tf +++ b/examples/nutanix-clusters/main.tf @@ -2,7 +2,7 @@ terraform { required_version = ">= 1.0" provider_meta "equinix" { - module_name = "equinix-metal-nutanix-cluster" + module_name = "equinix-metal-nutanix-cluster/examples/migration" } required_providers { @@ -58,11 +58,11 @@ resource "random_string" "vrf_name_suffix" { resource "equinix_metal_vrf" "nutanix" { count = var.create_vrf ? 1 : 0 - description = "VRF with ASN 65000 and a pool of address space that includes 192.168.96.0/21" + description = "VRF with ASN 65000 and a pool to cover two Nutanix Clusters. Deployed with Terraform module terraform-equinix-metal-nutanix-cluster." name = "nutanix-vrf-${random_string.vrf_name_suffix.result}" metro = var.metal_metro local_asn = "65000" - ip_ranges = [var.cluster_subnet] + ip_ranges = [var.metal_subnet] project_id = local.project_id } @@ -72,29 +72,35 @@ data "equinix_metal_vrf" "nutanix" { } module "nutanix_cluster1" { - source = "equinix-labs/metal-nutanix-cluster/equinix" - version = "0.4.0" - metal_auth_token = var.metal_auth_token - metal_metro = var.metal_metro - create_project = false - nutanix_node_count = var.nutanix_node_count - metal_project_id = local.project_id - cluster_subnet = "192.168.96.0/22" - vrf_id = local.vrf_id - create_vrf = false - create_vlan = true + source = "../.." + #source = "equinix-labs/metal-nutanix-cluster/equinix" + #version = "0.4.0" + cluster_name = "nutanix-a" + metal_vlan_description = "nutanix-a" + metal_auth_token = var.metal_auth_token + metal_metro = var.metal_metro + create_project = false + nutanix_node_count = var.nutanix_node_count + metal_project_id = local.project_id + cluster_subnet = cidrsubnet(var.metal_subnet, 1, 0) # "192.168.96.0/22" + vrf_id = local.vrf_id + create_vrf = false + create_vlan = true } module "nutanix_cluster2" { - source = "equinix-labs/metal-nutanix-cluster/equinix" - version = "0.4.0" - metal_auth_token = var.metal_auth_token - metal_metro = var.metal_metro - create_project = false - nutanix_node_count = var.nutanix_node_count - metal_project_id = local.project_id - cluster_subnet = "192.168.100.0/22" - vrf_id = local.vrf_id - create_vrf = false - create_vlan = true + source = "../.." + #source = "equinix-labs/metal-nutanix-cluster/equinix" + #version = "0.4.0" + cluster_name = "nutanix-b" + metal_vlan_description = "nutanix-b" + metal_auth_token = var.metal_auth_token + metal_metro = var.metal_metro + create_project = false + nutanix_node_count = var.nutanix_node_count + metal_project_id = local.project_id + cluster_subnet = cidrsubnet(var.metal_subnet, 1, 1) # "192.168.100.0/22" + vrf_id = local.vrf_id + create_vrf = false + create_vlan = true } diff --git a/examples/nutanix-clusters/variables.tf b/examples/nutanix-clusters/variables.tf index 4be5944..f81e9af 100644 --- a/examples/nutanix-clusters/variables.tf +++ b/examples/nutanix-clusters/variables.tf @@ -59,17 +59,11 @@ variable "metal_organization_id" { default = null description = "The ID of the Metal organization in which to create the project if `create_project` is true." } -# tflint-ignore: terraform_unused_declarations + variable "metal_subnet" { type = string default = "192.168.96.0/21" - description = "Nutanix cluster subnet." -} -# tflint-ignore: terraform_unused_declarations -variable "metal_vlan_description" { - type = string - default = "ntnx-demo" - description = "Description to add to created VLAN." + description = "IP pool for all Nutanix Clusters in the example. One bit will be appended to the end and divided between example clusters. (192.168.96.0/21 will result in clusters with ranges 192.168.96.0/22 and 192.168.100.0/22)" } variable "create_vrf" { @@ -83,33 +77,3 @@ variable "vrf_id" { default = null description = "ID of the VRF you wish to use." } -# tflint-ignore: terraform_unused_declarations -variable "metal_nutanix_plan" { - type = string - default = "c3.small.x86" - description = "The plan to use for the Nutanix nodes." -} -# tflint-ignore: terraform_unused_declarations -variable "skip_cluster_creation" { - type = bool - default = false - description = "Skip the creation of the Nutanix cluster." -} -# tflint-ignore: terraform_unused_declarations -variable "metal_bastion_plan" { - type = string - default = "t3.small.x86" - description = "The plan to use for the bastion host." -} -# tflint-ignore: terraform_unused_declarations -variable "metal_nutanix_os" { - type = string - default = "ubuntu_20_04" - description = "The operating system to use for the Nutanix nodes." -} -# tflint-ignore: terraform_unused_declarations -variable "cluster_subnet" { - type = string - default = "192.168.100.0/22" - description = "nutanix cluster subnet" -} diff --git a/main.tf b/main.tf index 46d6230..26b00c8 100644 --- a/main.tf +++ b/main.tf @@ -25,8 +25,10 @@ resource "terraform_data" "input_validation" { } resource "equinix_metal_project" "nutanix" { - count = var.create_project ? 1 : 0 - name = var.metal_project_name + count = var.create_project ? 1 : 0 + name = var.metal_project_name + # TODO: See https://github.com/equinix/terraform-provider-equinix/issues/732 + # description = "Nutanix cluster proof-of-concept project. See https://deploy.equinix.com/labs/terraform-equinix-metal-nutanix-cluster/ for more information." organization_id = var.metal_organization_id } @@ -55,9 +57,10 @@ data "equinix_metal_vlan" "nutanix" { } resource "equinix_metal_device" "bastion" { - project_id = local.project_id - hostname = "bastion" - + project_id = local.project_id + hostname = "${var.cluster_name}-bastion" + description = "${var.cluster_name} bastion to access Nutanix nodes and VMs on ${var.cluster_subnet}. Provides NTP, DHCP, and NAT for these nodes and VMs. Deployed with Terraform module terraform-equinix-metal-nutanix-cluster." + tags = [var.cluster_name] user_data = templatefile("${path.module}/templates/bastion-userdata.tmpl", { metal_vlan_id = local.vxlan, address = cidrhost(var.cluster_subnet, 2), @@ -79,10 +82,11 @@ resource "equinix_metal_device" "bastion" { } resource "equinix_metal_port" "bastion_bond0" { - port_id = [for p in equinix_metal_device.bastion.ports : p.id if p.name == "bond0"][0] - layer2 = false - bonded = true - vlan_ids = [local.vlan_id] + port_id = [for p in equinix_metal_device.bastion.ports : p.id if p.name == "bond0"][0] + layer2 = false + bonded = true + vlan_ids = [local.vlan_id] + reset_on_delete = true } # This generates a random suffix to avoid VRF name @@ -95,8 +99,8 @@ resource "random_string" "vrf_name_suffix" { resource "equinix_metal_vrf" "nutanix" { count = var.create_vrf ? 1 : 0 - description = "VRF with ASN 65000 and a pool of address space that includes 192.168.100.0/25" - name = "nutanix-vrf-${random_string.vrf_name_suffix.result}" + description = "VRF with ASN 65000 and a pool of address space that includes ${var.cluster_subnet}. Deployed with Terraform module terraform-equinix-metal-nutanix-cluster." + name = "${var.cluster_name}-vrf-${random_string.vrf_name_suffix.result}" metro = var.metal_metro local_asn = "65000" ip_ranges = [var.cluster_subnet] @@ -109,7 +113,8 @@ data "equinix_metal_vrf" "nutanix" { } resource "equinix_metal_reserved_ip_block" "nutanix" { - description = "Reserved IP block (${var.cluster_subnet}) taken from on of the ranges in the VRF's pool of address space." + description = "${var.cluster_name} VRF Reserved IP block (${var.cluster_subnet}). Deployed with Terraform module terraform-equinix-metal-nutanix-cluster." + tags = [var.cluster_name] project_id = local.project_id metro = var.metal_metro type = "vrf" @@ -127,7 +132,8 @@ resource "equinix_metal_gateway" "gateway" { resource "equinix_metal_device" "nutanix" { count = var.nutanix_node_count project_id = local.project_id - hostname = "nutanix-devrel-test-${count.index}" + hostname = "${var.cluster_name}-node-${count.index + 1}" + description = "${var.cluster_name} node ${count.index + 1}/${var.nutanix_node_count}. Deployed with Terraform module terraform-equinix-metal-nutanix-cluster." operating_system = var.metal_nutanix_os plan = var.metal_nutanix_plan metro = var.metal_metro @@ -162,13 +168,13 @@ resource "null_resource" "wait_for_firstboot" { } resource "equinix_metal_port" "nutanix" { - depends_on = [null_resource.wait_for_firstboot] - count = var.nutanix_node_count - port_id = [for p in equinix_metal_device.nutanix[count.index].ports : p.id if p.name == "bond0"][0] - layer2 = true - bonded = true - vlan_ids = [local.vlan_id] - + depends_on = [null_resource.wait_for_firstboot] + count = var.nutanix_node_count + port_id = [for p in equinix_metal_device.nutanix[count.index].ports : p.id if p.name == "bond0"][0] + layer2 = true + bonded = true + vlan_ids = [local.vlan_id] + reset_on_delete = true } resource "null_resource" "reboot_nutanix" { diff --git a/variables.tf b/variables.tf index b0587ee..309dbe2 100644 --- a/variables.tf +++ b/variables.tf @@ -6,7 +6,7 @@ variable "metal_auth_token" { variable "metal_vlan_description" { type = string - default = "ntnx-demo" + default = "ntnx-demo. Deployed with Terraform module terraform-equinix-metal-nutanix-cluster." description = "Description to add to created VLAN." } @@ -31,6 +31,12 @@ variable "metal_project_id" { EOT } +variable "cluster_name" { + type = string + default = "nutanix" + description = "The name of the Nutanix cluster, used as a prefix for resources." +} + variable "cluster_subnet" { type = string default = "192.168.100.0/22"