Manage several clusters from one configuration¶
When you finish, one Terraform configuration applies the same NFS settings to two clusters, and bringing in a third cluster takes one map entry.
Before you start¶
- Two Qumulo clusters, each with a REST API on port 8000 that you can reach from this machine
- An admin account on each cluster
- Terraform 1.11 or later
1. Copy the configuration¶
Save this as main.tf in an empty directory.
terraform {
required_version = ">= 1.11"
required_providers {
qumulo = {
source = "qumulo-terraform-registry.s3.us-east-1.amazonaws.com/qumulo/qumulo"
version = "~> 1.0"
}
}
}
locals {
clusters = {
prod = {
endpoint = "https://prod.example.com:8000" # <-- Replace with this cluster's REST API endpoint
password = "ProdPassword123!" # <-- Replace with this cluster's admin password
}
dr = {
endpoint = "https://dr.example.com:8000" # <-- Replace with this cluster's REST API endpoint
password = "DrPassword123!" # <-- Replace with this cluster's admin password
}
}
}
provider "qumulo" {
connection_profiles = [
for name, cluster in local.clusters : {
name = name
endpoint = cluster.endpoint
username = "admin"
password = cluster.password
insecure_skip_verify = true
}
]
}
resource "qumulo_nfs_settings" "all" {
for_each = local.clusters
connection_profile = each.key
v4_enabled = true
auth_sys_enabled = true
}
Replace the four values marked <-- Replace, and leave the rest as written. Delete insecure_skip_verify if every cluster's certificate is signed by a CA your machine trusts.
local.clusters holds one entry per cluster. The provider builds a connection profile named after each entry, and for_each gives qumulo_nfs_settings.all one instance per entry, pointed at the profile of the same name.
2. Apply¶
The plan ends with Plan: 2 to add, 0 to change, 0 to destroy. The apply ends with Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
3. Check the clusters¶
Run terraform state list. It prints qumulo_nfs_settings.all["dr"] and qumulo_nfs_settings.all["prod"], one instance per cluster.
4. Add a cluster¶
Add an entry to local.clusters.
test = {
endpoint = "https://test.example.com:8000" # <-- Replace with this cluster's REST API endpoint
password = "TestPassword123!" # <-- Replace with this cluster's admin password
}
Run terraform apply. The plan ends with Plan: 1 to add, 0 to change, 0 to destroy.
5. Remove a cluster¶
Destroy the cluster's instances while its entry still exists, since the entry also supplies the connection profile Terraform needs to reach the cluster.
The destroy ends with Destroy complete! Resources: 1 destroyed. Then delete the entry from local.clusters, and terraform plan reports No changes.
Next¶
Any cluster resource follows the same pattern. Add for_each = local.clusters and connection_profile = each.key to its block, and put any value that differs per cluster into that cluster's entry for each.value to read.
Try it on Export directories over NFS or Send audit logs to syslog and CloudWatch, and see the provider reference for every connection profile attribute.