#na_ontap_wait_for_condition syntax

1 messages · Page 1 of 1 (latest)

tepid bolt
#

Could someone help me out with the syntax I need to use for the na_ontap_wait_for_condition module (collection 22.12.0)? I'm doing a snapmirror update, and then I want it to wait until the update completes and the Snapmirror to become idle. But, I keep getting this error... what am I missing?

`` - name: Wait for Snapmirror update to complete
netapp.ontap.na_ontap_wait_for_condition:
hostname: "{{ netapp_hostname }}"
username: "{{ netapp_username }}"
password: "{{ netapp_password }}"
https: true
validate_certs: false
name: "snapmirror_relationship"
conditions: "state"
attributes:
destination_path: "{{ dest_path }}"
expected_state: "snapmirrored"
polling_interval: 30
timeout: 120

TASK [Wait for Snapmirror update to complete] *************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Error: no record for node: {'destination.path': vs01:volume01', 'fields': 'state,transfer.state'} - count: 3"}
``

Unfortunately, the documentation is not real clear to me, and none of the examples are for Snapmirrors. They are all for firmware upgrades:
https://docs.ansible.com/ansible/latest/collections/netapp/ontap/na_ontap_wait_for_condition_module.html#ansible-collections-netapp-ontap-na-ontap-wait-for-condition-module

tepid bolt
#

I figured out the error above... it was because I was trying to connect to the source hostname instead of the destination. So, now it goes through without an error message, but on the next step where I try to break the Snapmirror, I get the message "fatal: [localhost]: FAILED! => {"changed": false, "msg": "snapmirror data are transferring"}" because the mirrored state is "Snapmirrored", but the Relationship Status is "Transferring".

I tried adding:
expected_transfer_state: "idle"

under "attributes", but then it hangs for a long time, and I get this error message:
TASK [Wait for Snapmirror update to complete] ************************************************************************************************************************************************************************* fatal: [localhost]: FAILED! => {"changed": false, "last_state": "success", "msg": "Error: timeout waiting for condition: transfer_state==idle.", "states": "snapmirrored,transferring,snapmirrored,success,snapmirrored,success,snapmirrored,success"}

tight trellis
#

This works for me.

        - name: Wait for Prod to DR snapmirror resync to complete.
          netapp.ontap.na_ontap_wait_for_condition:
            hostname: "{{ dr_hostname }}"
            <<: *netapp_vars
            name: snapmirror_relationship
            state: present
            conditions:
              - transfer_state
            attributes:
              destination_path: "{{ dr_vserver + ':' + dr_volume }}"
              expected_transfer_state: success
            polling_interval: 60
            timeout: "{{ sm_wait_timeout_seconds | int }}"
tepid bolt
#

Thanks, @tight trellis!
That seems to be working. Apparently what I was missing was the "expected_transfer_state: success".
How did you know that that value was supposed to be success? The documentation says "expected_transfer_state to match the condition(s)", but I don't see anywhere that it lists the possible conditions. From the CLI, the desired "Mirror State" is "Snapmirrored", and the "Relationship Status" is "Idle", so how the heck are we supposed to know that it's looking for "success"?

tight trellis
# tepid bolt Thanks, <@1009129832992477375>! That seems to be working. Apparently what I wa...

I used the na_ontap_rest_info module to check the state and transfer state of a successful snapmirror.

- name: Get snapmirror info.
  hosts: localhost
  collections:
    - netapp.ontap
  gather_facts: false

  vars_files:
    - vars/main.yml
    - vault/main.yml

  vars:
    netapp_hostname: cluster_hostname_or_ip
    vserver: vserver_name
    dest_path: destination_path

  tasks:
    - name: Get snapmirrors.
      netapp.ontap.na_ontap_rest_info:
        hostname: "{{ netapp_hostname }}"
        username: "{{ netapp_username }}"
        password: "{{ netapp_password }}"
        https: true
        validate_certs: false
        use_python_keys: true
        fields:
          - 'state'
          - 'transfer.state'
        gather_subset:
          - snapmirror/relationships
        parameters:
          destination.path: "{{ dest_path }}"
      register: sm_info

    - name: Display snapmirror info.
      ansible.builtin.debug:
        msg: "{{ sm_info }}"

frosty hornet
tepid bolt
frosty hornet
#

The REST API Swagger doc -https://{clusterip}/docs/api- under the SnapMirror category /snapmirror/relationship/{uuid} - click on the 'Model' tab and it will show all the valid values for each parameter as you expand each field

#

The result you get back when you set the state should have a link to the relationship with the UUID if I recall correctly

tepid bolt
#

Ok, finally found where you were looking. Though I don't have any idea how you were able to correlate "expected_transfer_state" to that location in the Swagger Doc. It's under 'snapmirror_relationship > transfer > state'. And, to make it more confusing, there is a 'snapmirror_relationship > state' that has different values (broken_off, paused, snapmirrored, etc.) I expect that Lorne's method will probably work better for me than trying to navigate the doc.

Thanks though!

lean knot
#

It is confusing on the CLI as well with "state" and "status" being the corresponding fields. I think they did the best they can to make it more clear in REST.

frosty hornet
#

Using /snapmirror/relationship/{uuid/transfers is more challenging to use as it seems to only track active transfers. I've experienced it returning 0 records once the transfer completes. Using /snapmirror/relationship/[uuid}/transfers/{transfer_uuid} would return an error. That's why they added basic information on the current transfer or the last transfer if there is no active transfer at the time of the request to /snapmirror/relationship/{uuid}.

This is more about the ONTAP REST API than Ansible though.

livid cradle
#

does anyone have a list of the conditions that are available, this module could be very useful to me but just need to know what can and cant be done. many thanks