Introduction
Modern IT landscapes demand agility, transparency, and resilience. Traditional disaster recovery (DR) is often static, hard to audit, and slow to adapt. Enter Disaster Recovery as Code—a new paradigm where DR policies are codified, version-controlled, and delivered through repeatable automation.
Leveraging Infrastructure-as-Code (IaC) principles, Nutanix admins, architects, and DevOps teams can bring cloud-native agility to on-premises disaster recovery. In this article, you’ll learn how to transform Nutanix DR with version-controlled policies, CI/CD integration, and real-world implementation examples.
Why Disaster Recovery as Code?
Disaster recovery is no longer a “set and forget” process. As environments evolve, so must DR policies. The IaC approach provides:
- Repeatability: Deploy consistent DR configurations across environments.
- Auditability: Trace every policy change and maintain compliance.
- Agility: Update, test, and redeploy DR plans at the speed of code.
- Collaboration: Enable teams to work together using Git workflows and pull requests.
- Disaster Readiness: Validate DR plans as part of CI/CD pipelines.
Principles of DR-as-Code for Nutanix
| Principle | Traditional DR | DR-as-Code Approach |
|---|---|---|
| Change Management | Manual, error-prone | Git-based, peer-reviewed |
| Configuration Drift | Untracked | Immutable, versioned files |
| Testing | Periodic/manual | Automated, continuous |
| Audit/Compliance | Siloed, scattered | Centralized, traceable |
| Recovery Consistency | Variable | Consistent, repeatable |
Workflow Overview
Below is a high-level view of the DR-as-Code workflow for Nutanix environments.

Key Tools:
- Version Control: GitHub, GitLab, Bitbucket
- CI/CD: Jenkins, GitHub Actions, GitLab CI/CD
- Nutanix APIs: Prism Central v3/v4, Calm, Nutanix Xi Leap (optional)
Authoring DR Policies as Code
1. Define Your DR Policy in YAML or JSON
Nutanix Prism Central supports JSON/YAML for many configuration tasks. Here’s an example of a synthetic DR policy file:
# dr-policy-prod-site.yaml
policy:
name: "Production-Site-DR"
description: "DR policy for mission-critical workloads"
enabled: true
source_cluster: "AHV-Cluster-1"
target_cluster: "AHV-DR-Cluster"
schedule:
frequency: "hourly"
retention: "24h"
vm_groups:
- "prod-app-vms"
- "prod-db-vms"
runbook:
pre_failover_script: "./scripts/backup_check.sh"
post_failover_script: "./scripts/dns_update.sh"
notification:
email: "it-dr-team@example.com"
Tip: Store all DR policies in a dedicated /dr-policies folder in your Git repo.
2. Version Control: Track and Approve Changes
Create a Git repository (e.g., GitHub Example Repo: Nutanix-DR-as-Code):
git init
git add dr-policies/
git commit -m "Initial DR policy for production site"
git push origin main
- Use pull requests for policy changes.
- Require code reviews for compliance.
- Tag releases for DR test cycles.
3. Testing and Validation with CI/CD
Integrate your Git repository with CI/CD tools to automate policy validation and deployment.
Sample GitHub Actions Workflow
name: Nutanix DR Policy CI
on:
push:
paths:
- 'dr-policies/**'
jobs:
validate-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Validate YAML
run: yamllint dr-policies/
- name: Deploy to Nutanix Prism Central
env:
NUTANIX_HOST: ${{ secrets.NUTANIX_HOST }}
NUTANIX_USER: ${{ secrets.NUTANIX_USER }}
NUTANIX_PASS: ${{ secrets.NUTANIX_PASS }}
run: |
python ./scripts/apply_dr_policy.py dr-policies/
Published Example:
Nutanix Disaster Recovery as Code GitHub (synthetic example, for illustration)
4. Automating DR Policy Deployment
Create scripts to push policies to Prism Central. Example Python snippet using Nutanix v3 APIs:
import requests
import json
import os
NUTANIX_HOST = os.getenv('NUTANIX_HOST')
NUTANIX_USER = os.getenv('NUTANIX_USER')
NUTANIX_PASS = os.getenv('NUTANIX_PASS')
def apply_policy(policy_file):
with open(policy_file, 'r') as f:
policy_data = json.load(f)
url = f"https://{NUTANIX_HOST}:9440/api/nutanix/v3/dr_policies"
resp = requests.post(url, json=policy_data, auth=(NUTANIX_USER, NUTANIX_PASS), verify=False)
print(resp.status_code, resp.text)
apply_policy("dr-policies/dr-policy-prod-site.json")
PowerShell/Calm/Ansible can also be used for automation, depending on your stack.
Real-World Scenario: Ransomware Attack Recovery
Background:
Your production AHV cluster is compromised by ransomware at 2 AM. You need to failover to a clean DR cluster.
With DR-as-Code:
- Update Policy:
A critical VM group is added to the DR plan via a pull request. - Automated Validation:
CI pipeline validates and merges the change. - Deployment:
DR policies are automatically deployed to Prism Central. - Failover:
Runbook automation triggers pre-defined scripts, executes failover, updates DNS, and notifies IT.
Benefits:
- All steps are logged and auditable in Git.
- No scrambling to update or validate DR plans during crisis.
- Repeatable, tested recovery process.
Diagram: DR-as-Code Pipeline

Comparison Table: Classic DR vs. DR-as-Code
| Attribute | Classic Nutanix DR | DR-as-Code Approach |
|---|---|---|
| Policy Storage | Manual notes, screenshots | YAML/JSON in version control |
| Policy Updates | GUI/manual edits | Pull requests/code reviews |
| Audit Trail | Limited, scattered logs | Git history, traceable |
| Testing | Periodic, manual | Automated, CI/CD integrated |
| Deployment | Manual apply | Automated pipeline |
| Compliance | Siloed, labor-intensive | Built-in with Git/CI/CD |
Actionable Checklist: Is Your Team DR-as-Code Ready?
- All DR policies are defined as code (YAML/JSON)
- Policies are version-controlled (GitHub, GitLab, Bitbucket)
- Change management uses pull requests and code reviews
- CI/CD pipeline automates validation and deployment
- Regular DR tests are triggered by pipeline jobs
- Policies and scripts are stored in a secure repo
- Audit and compliance logs are exportable on demand
- Staff are trained in both DR and version control basics
Templates
Sample Pull Request Template
## Nutanix DR Policy Change Request
**Change Type:**
- [ ] New Policy
- [ ] Update Policy
- [ ] Remove Policy
**Description:**
[Brief description of change]
**Impact:**
[List any affected VMs, runbooks, or clusters]
**Validation:**
- [ ] YAML/JSON lint passed
- [ ] CI/CD pipeline passed
Further Resources
- Nutanix Official Documentation: DR
- Nutanix Dev GitHub: Example DR as Code
- Nutanix Calm for Runbook Automation
- GitHub Actions Documentation
- Nutanix Prism Central API Reference
Assess Your DR-as-Code Maturity
- How quickly can you update and deploy a DR plan across sites?
- Is every DR policy change documented and reviewable?
- Can you audit and report on your DR plan at any time?
- Are you running simulated failovers as part of CI/CD?
Take your Nutanix disaster recovery to the next level—transform it from static documentation to a living, auditable, and agile codebase.
Disclaimer: The views expressed in this article are those of the author and do not represent the opinions of Nutanix, my employer or any affiliated organization. Always refer to the official Nutanix documentation before production deployment.