Forum Discussion

amlucent's avatar
amlucent
Novice I
3 years ago

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```

8 Replies

  • Check out the `purefa_info` module. There is a `snapshots` option and one for `pgroups`
  • Don't worry about those errors - they can be ignored.
  • thank you very much. I will check that out as an alternative.
  • it seems when I run any of the purestorage.flasharray.purefa_info module examples like I find at https://docs.ansible.com/ansible/latest/collections/purestorage/flasharray/purefa_info_module.html#ansible-collections-purestorage-flasharray-purefa-info-module|https://docs.ansible.com/ansible/latest/collections/purestorage/flasharray/purefa_info_module.html#ansible-collections-pur[…]rray-purefa-info-module I get a `stderr:/../connectionpool.py InsecureRequestWarning Unverified HTTPS request is being made to host 'x.x.x.x'. Adding certificate verification is strongly advised`
  • Thank you for your help Simon. I understand completely if you are working reduced hours or not at all this week due to the holidays. This is not urgent. Unfortunately this quiet time is when I am able to work on these time saving automations.
  • I added `export PYTHONWARNINGS="ignore:Unverified HTTPS request"` and now I am getting a number of other errors. I think I need to update my py-pure-client version, its at 1.19. Im at a darksite. No pypi servers available. I am going to be in dependency hell for a while.
  • Yes - you need to be at the latest versions - sorry
  • my arrays were recently updated to the 6.2 purity version so I knew it was coming I just thought I could skate by for longer