Undeniably, Ansible helps you spend less time managing the configuration of your datacenter by grouping tasks together into a single playbook, configurations can be deployed across a variety of systems simply and easily. NetApp’s new and improved Ansible modules for ONTAP allow configuration management and automation of all ONTAP9 systems using Ansible.

NetApp and Ansible make it easier than ever before to create end-to-end workflows covering the entire process of provisioning and consuming storage. Complete application environments can be created and managed from a single playbook. In this example a complete workflow for creating and presenting an NFS export from an ONTAP system to a host is presented.

There are six tasks in this playbook.

  1. Create or verify and export policy
  2. Create or verify export policy rule
  3. Create or verify a volume, which is then junctioned and accessible according to the rules set in the export policy
  4. Create or verify the host fstabline to target hosts fstab file for new export
  5. Create or verify directory for mount location
  6. Mount or verify export volume on target host


- hosts: localhost 
  name: Setup ONTAP 
    hostname: "" 
    username: "admin" 
    volname: ansibleVolume 
    vserver: vserver1 
    aggr: aggr1 
    policy: ansiblePolicy 
    state: present 
  - name: "password" 
    prompt: "Password:" 
  - name: Create Policy 
      state: "{{ state }}" 
      name: "{{ policy }}" 
      vserver: "{{ vserver }}" 
      hostname: "{{ hostname }}" 
      username: "{{ username }}" 
      password: "{{ password }}" 
  - name: Setup rules 
      state: "{{ state }}" 
      policy_name: "{{ policy }}" 
      vserver: "{{ vserver }}" 
      ro_rule: sys 
      rw_rule: sys 
      super_user_security: sys 
      hostname: "{{ hostname }}" 
      username: "{{ username }}" 
      password: "{{ password }}" 
  - name: Create volume 
      state: "{{ state }}" 
      name: "{{ volname }}" 
      aggregate_name: "{{ aggr }}" 
      size: 1 
      size_unit: gb 
      policy: "{{ policy }}" 
      junction_path: "/{{ volname }}" 
      space_guarantee: "none" 
      vserver: "{{ vserver }}" 
      hostname: "{{ hostname }}" 
      username: "{{ username }}" 
      password: "{{ password }}" 
- hosts: client 
  - name: Update fstab file 
      path: /etc/fstab 
      line: "{{ volname }} /mnt/ontap nfs defaults 0 0" 
  - name: Verify mount directory exists 
      path: /mnt/ontap 
      state: directory 
  - name: Mount nfs export 
      state: "{{ state }}" 
      path: /mnt/ontap 
      src: "{{ volname }}" 
      fstype: nfs

If you’re curious about all of the options available for the modules used in this playbook, links to the documentation are below:

Documentation for the non-NetApp modules used can be found here.

Ansible makes automation easy

If you want to start using the ONTAP modules, or just learn more about them, instructions for adding the ONTAP modules to an existing Ansible set can be found here and full documentation for the ONTAP modules is here.

Try using the Ansible playbooks to create and consume storage for your application! Or, create storage which implements your best practices: naming conventions, options, etc.

Be sure to check back at netapp.io often to see other examples of our Ansible modules, and if you are not on our Slack channel be sure to get an invite and join us to discuss configuration management, along with all our other developer projects.

About David Blackwell

David is a twenty year IT veteran who has been an admin for just about every aspect of a DataCenter at one time or another. When not working, or tinkering with new software at home, David spends most of his free time with his six year old son and his lovely wife.

Pin It on Pinterest