Software Development Kit (SDK) and API Discussions

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

netappmagic
1,594 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,382 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