#na_ontap_info vserver name query using UUID

1 messages · Page 1 of 1 (latest)

queen stream
#

Hello all, I'm fairly new to Ansible, and have just started using the Netapp collection.
The purpose of this playbook, is to pull the volume space details automatically when we receive a space utilization alert for a volume being over a threshold.

The issue I'm running into is, I found out later that our alerts only provide the vserver UUID, not the name.
So now I'm trying to do a query, if possible, using the vserver_info subset of na_ontap_info, using the UUID. Everything else works fine.

I thought it may have been similar to the volume_info query I did, so I tried various similar combinations, but it just pulls the info for every vserver, rather than just the one with the UUID that I want.

Is there a way to do this? Or will it have to be done another way?

Obviously not showing everything here, but hopefully this gets the point across.

  • name: Get vserver info from UUID in the alert
    na_ontap_info:
    gather_subset: vserver info
    query:
    vserver-attributes:
    uuid: "{{ svm_uuid }}"
    <<: *login
    register: svm_info_all

When this query works, I want to use svm_info_all to get the vserver name - svm_name

Thought it may be similar to this query, which works great:

  • name: Get specific volume info from cluster
    na_ontap_info:
    gather_subset: volume_info
    query:
    volume-attributes:
    volume-íd-attributes:
    name: "{{ vol_name }}"
    <<: *login
    register: vol_info_all

The goal is to get the svm_name to be used in the var vol_info below, to be referenced later. We have thousands of volumes, so the vserver name needs to be used for cases where there are multiple volumes with the same name. This all works fine when I specify svm_name.

  • name: Set variable for the volume info
    set_fact:
    vol_info: "{{ vol_info_all['ontap_ info']['volume_info'][vars['vol_name'] + ':' + vars['svm_name']] }}"
    when: vol_info_all is defined

Thanks in advance, any help that can be provided here is greatly appreciated!

tawdry panther
#

small change needed in getting vserver info task
vserver-attributes should be vserver-info in query, but I suggest using rest info.

`- name: Get vserver info from UUID in the alert
na_ontap_info:
gather_subset: vserver_info
query:
vserver-info:
uuid: "{{ svm_uuid }}"
<<: *login

- name: Get vserver details using REST.
  na_ontap_rest_info:
    gather_subset: vserver_info
    parameters:
      uuid: "{{ svm_uuid }}"
    <<: *login
  register: result
- name: debug
  debug:
    var=result['ontap_info']['svm/svms']['records'][0]['name']`
queen stream
#

Thank you so much Mohan, this is exactly what I needed. Didn't realize there were rest_info modules in there that do the same thing either. Will be using those. Thanks again!