amlucent
3 years agoNovice I
I am unsure if this question is better suited here
I am unsure if this question is better suited here or in the topic-rest_api channel but here goes. I am attempting to write a playbook that does a snap of all luns in a few protection groups then clone the snaps to luns and map those to a different integration host group. At any rate I found and made use of the canned pure flash array modules for creating new snaps and protection groups etc but I am unable to find any for listing/showing snaps. Because of that I am falling back to rest-api with the ansible.builtin.uri module. What I am trying to do is filter the number of snaps this returns to only the ones for the relevant protection groups and the relevant suffix. Im looking for something like `purevol list --snap --pgrouplist someprotectiongroup.snap-date`. I have attempted to append the url with `?filter=snap-date` as is mentioned for parameters in the rest api 2.0 guide.
```- name: Login to FlashArray RestAPI
delegate_to: localhost
ansible.builtin.uri:
url: https://{{ inventory_hostname }}/api/2.11/login
method: POST
headers:
api-token: "{{ fa_api }}"
validate_certs: no
return_content: yes
status_code: [200, 201, 202]
body_format: json
ignore_errors: no
register: session
- debug:
var: session
- name: Register FlashArray Session Token
delegate_to: localhost
ansible.builtin.set_fact:
sessiontoken: "{{ session.x_auth_token }}"
# Grab list of Snaps from FlashArray
- name: Grab list of new Snapshots in the Protection Group
delegate_to: localhost
ansible.builtin.uri:
url: https://{{ inventory_hostname }}/api/2.11/protection-group-snapshots
method: GET
headers:
x-auth-token: "{{ sessiontoken }}"
validate_certs: no
return_content: yes
status_code: [200, 201, 202]
ignore_errors: no
register: snaps
- debug:
var: snaps
- name: Register FlashArray Session Token
delegate_to: localhost
ansible.builtin.set_fact:
snapslist: "{{ (snaps.content | from_json).items }}"
- debug:
var: snapslist```