Creating Storage Containers with Ansible

Introduction

Storage containers in Nutanix define how data is stored, deduplicated, compressed, and tiered. Automating container creation using Ansible enables consistent configurations across clusters and sites. This article walks through creating storage containers with compression enabled using a reusable playbook.


My Personal Repository on GitHub

Nutanix Repository on GitHub


Diagram: Container Provisioning Workflow

Diagram of Container Provisioning Workflow.

Use Case

  • Create storage containers with compression/dedupe
  • Apply consistent naming standards and policies
  • Integrate into new site builds or disaster recovery workflows

YAML File: container_config.yml

containers:
- name: app-storage
storage_container: "app-container"
storage_pool: "default-storage-pool"
compression_enabled: true
deduplication_enabled: false

- name: db-storage
storage_container: "db-container"
storage_pool: "default-storage-pool"
compression_enabled: false
deduplication_enabled: true

Playbook: create_containers.yml

- name: Create Nutanix storage containers
hosts: localhost
gather_facts: false
collections:
- nutanix.ncp
vars_files:
- nutanix_credentials.yml
- container_config.yml
tasks:

- name: Create container
loop: "{{ containers }}"
loop_control:
loop_var: container
nutanix.ncp.storage_containers:
state: present
name: "{{ container.storage_container }}"
storage_pool_name: "{{ container.storage_pool }}"
compression_enabled: "{{ container.compression_enabled }}"
deduplication_enabled: "{{ container.deduplication_enabled }}"
cluster_name: "prod-cluster"

Run It

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

Optional Enhancements

  • Add advertised_capacity
  • Attach a replication policy or protection domain
  • Use tags for search and metadata

Summary

This playbook makes Nutanix storage provisioning fast, consistent, and scalable. Whether for onboarding new clusters or configuring containers per business unit, Ansible provides a reliable framework for infrastructure-as-code.

External Documentation:

Continue reading

Managing VM Power State with Ansible

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

Leave a Reply

Discover more from Digital Thought Disruption

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

Continue reading