Skip to content

Commit

Permalink
generate-terraform-docs: automated action
Browse files Browse the repository at this point in the history
Signed-off-by: GitHub <[email protected]>
  • Loading branch information
displague committed Jul 19, 2024
1 parent 8c7804d commit 91648a2
Show file tree
Hide file tree
Showing 7 changed files with 230 additions and 97 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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: <https://github.com/equinix-labs/terraform-equinix-metal-nutanix-cluster/issues/new>.

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.
Expand Down
172 changes: 159 additions & 13 deletions examples/nutanix-clusters/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,38 +50,94 @@ 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 [email protected]"
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 [email protected]"
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 [email protected]"
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 [email protected]"
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"
```

## Manual Steps

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 [email protected]
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:
Expand All @@ -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 [email protected]
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 [email protected]
ssh [email protected]
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 [email protected]
ssh [email protected]
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
```

Expand Down Expand Up @@ -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)
<!-- TEMPLATE: The following block has been generated by terraform-docs util: https://github.com/terraform-docs/terraform-docs -->
<!-- BEGIN_TF_DOCS -->
## Requirements
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_equinix"></a> [equinix](#requirement\_equinix) | >= 1.30 |
| <a name="requirement_local"></a> [local](#requirement\_local) | >= 2.5 |
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 3 |
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 3 |
## Providers
| Name | Version |
|------|---------|
| <a name="provider_equinix"></a> [equinix](#provider\_equinix) | >= 1.30 |
| <a name="provider_random"></a> [random](#provider\_random) | >= 3 |
## Modules
| Name | Source | Version |
|------|--------|---------|
| <a name="module_nutanix_cluster1"></a> [nutanix\_cluster1](#module\_nutanix\_cluster1) | equinix-labs/metal-nutanix-cluster/equinix | 0.4.0 |
| <a name="module_nutanix_cluster2"></a> [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 |
|------|-------------|------|---------|:--------:|
| <a name="input_metal_auth_token"></a> [metal\_auth\_token](#input\_metal\_auth\_token) | Equinix Metal API token. | `string` | n/a | yes |
| <a name="input_metal_metro"></a> [metal\_metro](#input\_metal\_metro) | The metro to create the cluster in. | `string` | n/a | yes |
| <a name="input_cluster_subnet"></a> [cluster\_subnet](#input\_cluster\_subnet) | nutanix cluster subnet | `string` | `"192.168.100.0/22"` | no |
| <a name="input_create_project"></a> [create\_project](#input\_create\_project) | (Optional) to use an existing project matching `metal_project_name`, set this to false. | `bool` | `true` | no |
| <a name="input_create_vlan"></a> [create\_vlan](#input\_create\_vlan) | Whether to create a new VLAN for this project. | `bool` | `true` | no |
| <a name="input_create_vrf"></a> [create\_vrf](#input\_create\_vrf) | Whether to create a new VRF for this project. | `bool` | `true` | no |
| <a name="input_metal_bastion_plan"></a> [metal\_bastion\_plan](#input\_metal\_bastion\_plan) | The plan to use for the bastion host. | `string` | `"t3.small.x86"` | no |
| <a name="input_metal_nutanix_os"></a> [metal\_nutanix\_os](#input\_metal\_nutanix\_os) | The operating system to use for the Nutanix nodes. | `string` | `"ubuntu_20_04"` | no |
| <a name="input_metal_nutanix_plan"></a> [metal\_nutanix\_plan](#input\_metal\_nutanix\_plan) | The plan to use for the Nutanix nodes. | `string` | `"c3.small.x86"` | no |
| <a name="input_metal_organization_id"></a> [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 |
| <a name="input_metal_project_id"></a> [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<br> you do not specify a project name, the project will be looked up by ID. One (and only one) of<br> `metal_project_name` or `metal_project_id` is required or `metal_project_id` must be set. | `string` | `""` | no |
| <a name="input_metal_project_name"></a> [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<br>you do not specify a project ID, the project will be looked up by name. One (and only one) of<br>`metal_project_name` or `metal_project_id` is required or `metal_project_id` must be set.<br>Required if `create_project` is true. | `string` | `""` | no |
| <a name="input_metal_subnet"></a> [metal\_subnet](#input\_metal\_subnet) | Nutanix cluster subnet. | `string` | `"192.168.96.0/21"` | no |
| <a name="input_metal_vlan_description"></a> [metal\_vlan\_description](#input\_metal\_vlan\_description) | Description to add to created VLAN. | `string` | `"ntnx-demo"` | no |
| <a name="input_metal_vlan_id"></a> [metal\_vlan\_id](#input\_metal\_vlan\_id) | ID of the VLAN you wish to use. | `number` | `null` | no |
| <a name="input_nutanix_node_count"></a> [nutanix\_node\_count](#input\_nutanix\_node\_count) | The number of Nutanix nodes to create. | `number` | `2` | no |
| <a name="input_skip_cluster_creation"></a> [skip\_cluster\_creation](#input\_skip\_cluster\_creation) | Skip the creation of the Nutanix cluster. | `bool` | `false` | no |
| <a name="input_vrf_id"></a> [vrf\_id](#input\_vrf\_id) | ID of the VRF you wish to use. | `string` | `null` | no |
## Outputs
| Name | Description |
|------|-------------|
| <a name="output_nutanix_cluster1_bastion_public_ip"></a> [nutanix\_cluster1\_bastion\_public\_ip](#output\_nutanix\_cluster1\_bastion\_public\_ip) | The public IP address of the bastion host |
| <a name="output_nutanix_cluster1_cluster_gateway"></a> [nutanix\_cluster1\_cluster\_gateway](#output\_nutanix\_cluster1\_cluster\_gateway) | The Nutanix cluster gateway IP |
| <a name="output_nutanix_cluster1_cvim_ip_address"></a> [nutanix\_cluster1\_cvim\_ip\_address](#output\_nutanix\_cluster1\_cvim\_ip\_address) | The IP address of the CVM |
| <a name="output_nutanix_cluster1_iscsi_data_services_ip"></a> [nutanix\_cluster1\_iscsi\_data\_services\_ip](#output\_nutanix\_cluster1\_iscsi\_data\_services\_ip) | Reserved IP for cluster ISCSI Data Services IP |
| <a name="output_nutanix_cluster1_prism_central_ip_address"></a> [nutanix\_cluster1\_prism\_central\_ip\_address](#output\_nutanix\_cluster1\_prism\_central\_ip\_address) | Reserved IP for Prism Central VM |
| <a name="output_nutanix_cluster1_ssh_forward_command"></a> [nutanix\_cluster1\_ssh\_forward\_command](#output\_nutanix\_cluster1\_ssh\_forward\_command) | SSH port forward command to use to connect to the Prism GUI |
| <a name="output_nutanix_cluster1_ssh_private_key"></a> [nutanix\_cluster1\_ssh\_private\_key](#output\_nutanix\_cluster1\_ssh\_private\_key) | The SSH keypair's private key for cluster1 |
| <a name="output_nutanix_cluster1_virtual_ip_address"></a> [nutanix\_cluster1\_virtual\_ip\_address](#output\_nutanix\_cluster1\_virtual\_ip\_address) | Reserved IP for cluster virtal IP |
| <a name="output_nutanix_cluster2_bastion_public_ip"></a> [nutanix\_cluster2\_bastion\_public\_ip](#output\_nutanix\_cluster2\_bastion\_public\_ip) | The public IP address of the bastion host |
| <a name="output_nutanix_cluster2_cluster_gateway"></a> [nutanix\_cluster2\_cluster\_gateway](#output\_nutanix\_cluster2\_cluster\_gateway) | The Nutanix cluster gateway IP |
| <a name="output_nutanix_cluster2_cvim_ip_address"></a> [nutanix\_cluster2\_cvim\_ip\_address](#output\_nutanix\_cluster2\_cvim\_ip\_address) | The IP address of the CVM |
| <a name="output_nutanix_cluster2_iscsi_data_services_ip"></a> [nutanix\_cluster2\_iscsi\_data\_services\_ip](#output\_nutanix\_cluster2\_iscsi\_data\_services\_ip) | Reserved IP for cluster ISCSI Data Services IP |
| <a name="output_nutanix_cluster2_prism_central_ip_address"></a> [nutanix\_cluster2\_prism\_central\_ip\_address](#output\_nutanix\_cluster2\_prism\_central\_ip\_address) | Reserved IP for Prism Central VM |
| <a name="output_nutanix_cluster2_ssh_forward_command"></a> [nutanix\_cluster2\_ssh\_forward\_command](#output\_nutanix\_cluster2\_ssh\_forward\_command) | SSH port forward command to use to connect to the Prism GUI |
| <a name="output_nutanix_cluster2_ssh_private_key"></a> [nutanix\_cluster2\_ssh\_private\_key](#output\_nutanix\_cluster2\_ssh\_private\_key) | The SSH keypair's private key for cluster1 |
| <a name="output_nutanix_cluster2_virtual_ip_address"></a> [nutanix\_cluster2\_virtual\_ip\_address](#output\_nutanix\_cluster2\_virtual\_ip\_address) | Reserved IP for cluster virtal IP |
<!-- END_TF_DOCS -->
Binary file not shown.
56 changes: 31 additions & 25 deletions examples/nutanix-clusters/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

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

0 comments on commit 91648a2

Please sign in to comment.