Deploying a PowerFlex cluster using a CSV Topology File
This guide explains how to use a CSV file as input for an Cluster Resource.
Example
Note: In input the CSV files, provide Cluster Node-related and Storage Pool related seperately as shown in the example below:
cluster_node.csv
IPs,Password,Operating System,Is MDM/TB,Is SDS,SDS Storage Device List,Is SDC
10.76.60.1,Password1,linux,Primary,Yes,/dev/sdb,Yes
10.76.60.2,Password1,linux,Secondary,Yes,/dev/sdb,Yes
10.76.60.3,Password1,linux,TB,Yes,/dev/sdb,Yes
sp_data.csv
ProtectionDomain,StoragePool,Media Type,Replication journal capacity percentage
domain_1,pool1,HDD,50
To perform SDC operations with a CSV file, use the following configuration:
locals {
cluste_node_data = csvdecode(file("cluster_node.csv"))
sp_data = csvdecode(file("sp_data.csv"))
}
resource "powerflex_cluster" "test" {
# Security Related Fields
mdm_password = "Password"
lia_password = "Password"
# Advance Security Configuration
allow_non_secure_communication_with_lia = false
allow_non_secure_communication_with_mdm = false
disable_non_mgmt_components_auth = false
# Cluster Configuration related fields
cluster = [
for row in local.cluste_node_data : {
ips = row.IPs
username = row.Username
password = row.Password
operating_system = row["Operating System"]
is_mdm_or_tb = row["Is MDM/TB"]
is_sds = row["Is SDS"]
sdc_name = row["SDS Name"]
perf_profile_for_sdc = row.perfProfileForSDC
is_rfcache = row["RFcache"]
is_sdr = row["Is SDR"]
}
if row["Is MDM/TB"] != ""
]
storage_pools = [
for row in local.sp_data : {
media_type = row["Media Type"]
protection_domain = row["ProtectionDomain"]
storage_pool = row["StoragePool"]
replication_journal_capacity_percentage = tonumber(row["Replication journal capacity percentage"])
}
]
}
This Terraform configuration sets up a PowerFlex cluster by defining its configuration, including security settings, node information, and storage pool details. The data for this configuration is read from two CSV files using the csvdecode function and organized into the required format for the resource.
The example defines two local variables, cluster_node_data and sp_data, using the csvdecode function. These variables read data from two CSV files, “cluster_node.csv” and “sp_data.csv.”
locals: This section defines local variables within the Terraform configuration. These variables are used to store data or perform calculations within your configuration.
cluster_node_data: Reads and decodes the CSV file “cluster_node.csv” into a list of maps. This file appears to contain information about cluster nodes.
sp_data: Reads and decodes the CSV file “sp_data.csv” into a list of maps. This file seems to contain information about storage pools.
cluster: Uses a list comprehension to iterate over the decoded rows from “cluster_node.csv” to configure cluster details.
storage_pools: Similar list comprehension for iterating over the decoded rows from “sp_data.csv” to configure storage pools.
The fields inside the object (e.g., ip, password, operating_system, etc.) are populated with values from the CSV file. You can also apply some conditions in the if statement to filter out rows where IPs and Password are not empty and not equal to “null.”