Nutanix Cluster Expansion with CLI and Bash

Introduction

As workloads grow, Nutanix clusters must scale to meet demand. While Prism simplifies node addition, using ncli and Bash provides automation for site builds, disaster recovery scenarios, and DevOps pipelines. This guide outlines how to script and repeatably expand your Nutanix cluster using CLI tools.


My Personal Repository on GitHub

Nutanix Repository on GitHub


Diagram: Cluster Expansion Automation Flow

Diagram of Cluster Expansion Automation Flow.

Requirements


YAML Example: nodes.yaml

nodes:
- ip: 10.10.10.101
hostname: ntx-node04
rackable_unit_serial: NX123456789
- ip: 10.10.10.102
hostname: ntx-node05
rackable_unit_serial: NX123456790

Bash Script: nutanix_cluster_expand.sh

#!/usr/bin/env bash
set -euo pipefail

spec="nodes.yaml"
log="/var/log/nutanix_cluster_expand.log"

for i in $(yq e '.nodes | keys | .[]' "$spec"); do
ip=$(yq e ".nodes[$i].ip" "$spec")
host=$(yq e ".nodes[$i].hostname" "$spec")
serial=$(yq e ".nodes[$i].rackable_unit_serial" "$spec")

echo "[$(date)] Adding node $host ($ip) Serial: $serial" | tee -a "$log"
ncli host add-node external-ip-address="$ip" rackable-unit-serial-number="$serial" hostname="$host"
done

Monitor Progress

Use this command to view cluster state post-expansion:

ncli host list

Optional: Validate Foundation Completion

Ensure that host imaging and cluster pre-checks are done before running this script.


Summary

Automating Nutanix cluster growth allows you to expand rapidly and consistently. Whether building out a new rack, standing up a DR region, or scaling edge deployments, ncli and Bash provide robust tools to script every step.

External Documentation:

Continue reading

Nutanix Credentials Rotation Script with Bash

Explore another guide in this topic and build on what you have just read. Read the article

Leave a Comment

Discover more from Digital Thought Disruption

Subscribe now to keep reading and get access to the full archive.

Continue reading