Nutanix User and Role Management via CLI

Introduction

Role-based access control (RBAC) is critical in enterprise datacenter security. Nutanix Prism allows fine-grained user and group role mapping, and this can be fully automated using ncli. In this guide, we create, update, and delete Prism users and assign them appropriate roles using Bash scripts.


My Personal Repository on GitHub

Nutanix Repository on GitHub


Diagram: User Management Workflow


Create a User

ncli user create user-name="backupadmin" password="S3cure!" email="backup@example.com" full-name="Backup Automation" role="Viewer"

Delete a User

ncli user delete user-name="olduser"

Modify User Role

ncli user update user-name="appadmin" role="Cluster Admin"

Bash Script: nutanix_user_manage.sh

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

action=$1
user=$2
role=${3:-"Viewer"}
email=${4:-"$user@example.com"}

case "$action" in
create)
ncli user create user-name="$user" password="TempPass123!" email="$email" full-name="$user" role="$role"
;;
update)
ncli user update user-name="$user" role="$role"
;;
delete)
ncli user delete user-name="$user"
;;
*)
echo "Usage: $0 {create|update|delete} username [role] [email]"
exit 1
;;
esac

Bulk User Input: users.csv

username,role,email
devops,Cluster Admin,devops@example.com
viewer01,Viewer,viewer01@example.com
auditor,Auditor,audit@example.com

Optional Loop for Bulk User Provisioning

#!/bin/bash
IFS=","
tail -n +2 users.csv | while read user role email; do
./nutanix_user_manage.sh create "$user" "$role" "$email"
done

Summary

Managing users and roles through the Nutanix CLI enables fast provisioning, secure access control, and policy compliance. Use these scripts to tie into onboarding workflows, audits, or incident response automation.

External Documentation:

Leave a Reply

Discover more from Digital Thought Disruption

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

Continue reading