Auto-Generate Nutanix Reports with Ansible and Email Integration

Introduction

Nutanix operations teams benefit from having a consolidated daily snapshot of cluster health, VM status, and storage capacity. With Ansible, you can automate report generation and email delivery. This post shows how to create a consolidated Nutanix infrastructure report and send it to your team each morning.


My Personal Repository on GitHub

Nutanix Repository on GitHub


Diagram: Reporting Automation Flow


Use Case

  • Daily executive or operations summary
  • Cluster monitoring for NOC or MSPs
  • Detect VMs that are powered off or oversized

Playbook: daily_nutanix_report.yml

- name: Generate Daily Nutanix Infrastructure Report
hosts: localhost
gather_facts: false
collections:
- nutanix.ncp
vars_files:
- nutanix_credentials.yml
vars:
cluster: "prod-cluster"
report_file: "/tmp/nutanix_report_{{ ansible_date_time.date }}.log"
mail_to: "ops@example.com"
tasks:

- name: Start report log
copy:
content: "Nutanix Daily Report - {{ ansible_date_time.date }}\n\n"
dest: "{{ report_file }}"

- name: Append Cluster Summary
shell: |
echo "=== Cluster Summary ===" >> {{ report_file }}
ncli cluster get-summary >> {{ report_file }}
environment:
PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

- name: Append VM Inventory
shell: |
echo "\n=== VM Summary ===" >> {{ report_file }}
ncli vm list name power-state | grep -v '^--' >> {{ report_file }}

- name: Append Container Info
shell: |
echo "\n=== Storage Containers ===" >> {{ report_file }}
ncli container list name usage-capacity | grep -v '^--' >> {{ report_file }}

- name: Email Report
shell: |
mailx -s "Nutanix Daily Report - {{ ansible_date_time.date }}" {{ mail_to }} < {{ report_file }}
when: ansible_virtualization_role == 'host' # example condition to limit where it runs

Run the Playbook

ansible-playbook daily_nutanix_report.yml --ask-vault-pass -i inventory.yml

Schedule It

0 6 * * * /usr/local/bin/ansible-playbook /opt/playbooks/daily_nutanix_report.yml

Optional Enhancements

  • Use template module for better formatting
  • Include LCM updates or certificate expiry
  • Send as HTML with mutt or mailx -a options

Sample Output (Text Email)

Nutanix Daily Report - 2025-07-23

=== Cluster Summary ===
Cluster Name: prod-cluster
State: NORMAL
Nodes: 6
Uptime: 132 days

=== VM Summary ===
web01 ON
db01 OFF
api01 ON

=== Storage Containers ===
default-container 78% used
backup-container 55% used

Summary

Ansible makes it easy to convert Nutanix cluster data into a structured daily report. With built-in CLI modules and email delivery, teams can stay informed without logging into Prism or building custom dashboards.

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