NetApp Community Update
This site will enter Read Only mode on July 23 as we prepare to move to a new platform.
You will still be able to view content, but posting and replying will be temporarily disabled.
To learn more, please review the information in this blog post.

Software Development Kit (SDK) and API Discussions

Retrieving a value from Cluster, and assign it to a variable in Playbook

netappmagic
2,040 Views

How can I retrieve the corresponding export policy name based on a known volume name, then assign it to a variable in Playbook. The goal is to use the NA module to create a rule based on the policy name. 

 

I don't know if Playbook can do that. Thank you!

1 REPLY 1

Trubida
1,828 Views

Not sure if this is the best way to do it you can make an API call to the OnTap system to get the export policy name.

---
- hosts: localhost
tasks:
- name: Get NetApp UUID of Volume
uri:
url: https://cluster_name/api/storage/volumes?name=volume_name&fields=nas.export_policy.name&return_records=true&return_timeout=15
url_username: username
url_password: password
method: GET
force_basic_auth: yes
validate_certs: no
register: vol_export_policy
- name: Set export policy fact
set_fact:
export_policy: "{{ vol_export_policy.json.records[0].nas.export_policy.name }}"

 

Public