Skip to main content

Automation

Ansible NetApp Volume Provisioning Example With Validation Guardrails

Automation guide — Storage KnowHow

Why the Example Needs Guardrails

Most storage automation examples show how to create a volume. Production automation needs more than that. It needs to reject unsafe input, apply approved defaults, produce evidence, and make the change easy to review later.

This example is intentionally shaped like a runbook. You can adapt it into a change workflow, CI job, or self-service request pipeline.

Request Variables

Start with a simple request file. Keep platform facts and request data separate so the same playbook can run in dev, test, and production with different inventory variables.

- name: Record volume provisioning evidence
  ansible.builtin.copy:
    dest: "evidence/{{ ticket }}-{{ volume_name }}.txt"
    content: |
      ticket={{ ticket }}
      volume={{ volume_name }}
      svm={{ svm }}
      size_gb={{ size_gb }}
      aggregate={{ aggregate_name }}
      junction_path={{ junction_path }}
      snapshot_policy={{ snapshot_policy }}
      tiering_policy={{ tiering_policy }}
      owner={{ owner }}

Current Module Requirements

The current Ansible community documentation lists netapp.ontap.na_ontap_volume as part of the netapp.ontap collection. It is not included in ansible-core; install it with:

- name: Record volume provisioning evidence
  ansible.builtin.copy:
    dest: "evidence/{{ ticket }}-{{ volume_name }}.txt"
    content: |
      ticket={{ ticket }}
      volume={{ volume_name }}
      svm={{ svm }}
      size_gb={{ size_gb }}
      aggregate={{ aggregate_name }}
      junction_path={{ junction_path }}
      snapshot_policy={{ snapshot_policy }}
      tiering_policy={{ tiering_policy }}
      owner={{ owner }}

The module documentation currently lists Ansible 2.9 or later as required and recommends Ansible 2.12 or later. Pin and record the collection version in your automation environment so a future collection upgrade does not silently change behavior.

Validation Tasks

Validate inputs before touching ONTAP.

- name: Record volume provisioning evidence
  ansible.builtin.copy:
    dest: "evidence/{{ ticket }}-{{ volume_name }}.txt"
    content: |
      ticket={{ ticket }}
      volume={{ volume_name }}
      svm={{ svm }}
      size_gb={{ size_gb }}
      aggregate={{ aggregate_name }}
      junction_path={{ junction_path }}
      snapshot_policy={{ snapshot_policy }}
      tiering_policy={{ tiering_policy }}
      owner={{ owner }}

The exact standards should come from your environment. The important part is that validation happens before the storage change.

Preflight Capacity and Duplicate Checks

Before creating the volume, check that the target aggregate exists, the volume does not already exist unexpectedly, and the requested size is within your free-space guardrail. The exact information-gathering module depends on your collection version, but the pattern is the same:

- name: Record volume provisioning evidence
  ansible.builtin.copy:
    dest: "evidence/{{ ticket }}-{{ volume_name }}.txt"
    content: |
      ticket={{ ticket }}
      volume={{ volume_name }}
      svm={{ svm }}
      size_gb={{ size_gb }}
      aggregate={{ aggregate_name }}
      junction_path={{ junction_path }}
      snapshot_policy={{ snapshot_policy }}
      tiering_policy={{ tiering_policy }}
      owner={{ owner }}

In production, fail the run when the target already exists unless the workflow explicitly supports modification. Idempotency should be deliberate, not accidental.

Provisioning Shape

- name: Record volume provisioning evidence
  ansible.builtin.copy:
    dest: "evidence/{{ ticket }}-{{ volume_name }}.txt"
    content: |
      ticket={{ ticket }}
      volume={{ volume_name }}
      svm={{ svm }}
      size_gb={{ size_gb }}
      aggregate={{ aggregate_name }}
      junction_path={{ junction_path }}
      snapshot_policy={{ snapshot_policy }}
      tiering_policy={{ tiering_policy }}
      owner={{ owner }}

Use a dedicated service account and store credentials in a vault or external secret store. Do not hard-code passwords in the playbook.

Optional Autosize Standard

If your operational standard allows autogrow, configure it deliberately instead of leaving it as an undocumented manual follow-up. Current ONTAP CLI documentation says new flexible volumes default autosize to off, except data protection mirrors.

Example policy shape:

- name: Record volume provisioning evidence
  ansible.builtin.copy:
    dest: "evidence/{{ ticket }}-{{ volume_name }}.txt"
    content: |
      ticket={{ ticket }}
      volume={{ volume_name }}
      svm={{ svm }}
      size_gb={{ size_gb }}
      aggregate={{ aggregate_name }}
      junction_path={{ junction_path }}
      snapshot_policy={{ snapshot_policy }}
      tiering_policy={{ tiering_policy }}
      owner={{ owner }}

Then apply it with the collection module your environment standardizes on, or with a controlled CLI/API task if your collection version does not expose every autosize setting you need.

Post-Change Evidence

After provisioning, query the result and store the evidence with the change record.

- name: Record volume provisioning evidence
  ansible.builtin.copy:
    dest: "evidence/{{ ticket }}-{{ volume_name }}.txt"
    content: |
      ticket={{ ticket }}
      volume={{ volume_name }}
      svm={{ svm }}
      size_gb={{ size_gb }}
      aggregate={{ aggregate_name }}
      junction_path={{ junction_path }}
      snapshot_policy={{ snapshot_policy }}
      tiering_policy={{ tiering_policy }}
      owner={{ owner }}

Evidence does not need to be fancy. It needs to be easy to find during audit, troubleshooting, or handoff.

Operational Improvements

Add these once the basic workflow is stable:

See also: Automate NetApp Volume Provisioning with Ansible

References

Comments