ansible-collections / netapp

Development area for Netapp collections
49 stars 36 forks source link

na_ontap_volume errors if Root LS Mirror Volume already exists #43

Closed chjones45 closed 4 years ago

chjones45 commented 4 years ago
SUMMARY

When the SVM Root LS Mirror Volume already exists the na_ontap_volume module fails with the error "Invalid operation. Reason: Cannot unmount Vserver namespace root volume"

ISSUE TYPE
COMPONENT NAME

na_ontap_volume

ANSIBLE VERSION
ansible 2.9.7
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/usr/share/my_modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.17 (default, Apr 15 2020, 17:20:14) [GCC 7.5.0]
CONFIGURATION
DEFAULT_MODULE_PATH(/etc/ansible/ansible.cfg) = [u'/usr/share/my_modules']
DEFAULT_ROLES_PATH(/etc/ansible/ansible.cfg) = [u'/etc/ansible/roles']
DEPRECATION_WARNINGS(/etc/ansible/ansible.cfg) = False
OS / ENVIRONMENT

FAS8060 running ONTAP 9.7P3 ONTAP vSIM running 9.5P6

STEPS TO REPRODUCE
- name: Create SVM Root LS Mirror Volume
  netapp.ontap.na_ontap_volume:
    <<: *clusterlogin
    state: "{{ item.state }}"
    vserver: "{{ item.name }}"
    name: "{{ item.name }}_root_m1"
    aggregate_name: "{{ item.ls_mirror_aggr }}"
    size: 20
    size_unit: mb
    type: DP
    policy: default
    junction_path: ""
    space_guarantee: "volume"
    snapshot_policy: none
    volume_security_style: "{{ 'ntfs' if item.protocol.lower() is search('cifs') else 'unix' }}"
  with_items:
    "{{ vservers }}"
  when:
    - item.ls_mirror_aggr is defined
    - vservers != None
  tags: vserver_ls_volume
EXPECTED RESULTS

The module will report OK if the LS Mirror Volume already exists.

ACTUAL RESULTS
TASK [svms : Create SVM Root LS Mirror Volume] ******************************************************************************************************************************************************************************************************************************************************************************
task path: /mnt/c/Users/chrisj1/Documents/GitRepos/Test Cluster Build/roles/svms/tasks/main.yml:27
<fas-cluster1> ESTABLISH LOCAL CONNECTION FOR USER: root
<fas-cluster1> EXEC /bin/sh -c 'echo ~root && sleep 0'
<fas-cluster1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir /root/.ansible/tmp/ansible-tmp-1591317837.6-14779-179076282602759 && echo ansible-tmp-1591317837.6-14779-179076282602759="` echo /root/.ansible/tmp/ansible-tmp-1591317837.6-14779-179076282602759 `" ) && sleep 0'
Using module file /root/.ansible/collections/ansible_collections/netapp/ontap/plugins/modules/na_ontap_volume.py
<fas-cluster1> PUT /root/.ansible/tmp/ansible-local-14740YCh7IS/tmpTUCG_z TO /root/.ansible/tmp/ansible-tmp-1591317837.6-14779-179076282602759/AnsiballZ_na_ontap_volume.py
<fas-cluster1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1591317837.6-14779-179076282602759/ /root/.ansible/tmp/ansible-tmp-1591317837.6-14779-179076282602759/AnsiballZ_na_ontap_volume.py && sleep 0'
<fas-cluster1> EXEC /bin/sh -c '/usr/bin/python3 /root/.ansible/tmp/ansible-tmp-1591317837.6-14779-179076282602759/AnsiballZ_na_ontap_volume.py && sleep 0'
<fas-cluster1> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1591317837.6-14779-179076282602759/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_netapp.ontap.na_ontap_volume_payload_km7d0uv4/ansible_netapp.ontap.na_ontap_volume_payload.zip/ansible_collections/netapp/ontap/plugins/modules/na_ontap_volume.py", line 1306, in volume_unmount
  File "/usr/local/lib/python3.6/dist-packages/netapp_lib/api/zapi/zapi.py", line 301, in invoke_successfully
    raise NaApiError(code, msg)
netapp_lib.api.zapi.zapi.NaApiError: NetApp API failed. Reason - 13001:Invalid operation. Reason: Cannot unmount Vserver namespace root volume "fas_svm1_root_m1".
failed: [fas-cluster1] (item={u'ls_mirror_aggr': u'sas_aggr_02', u'protocol': u'cifs,nfs,iscsi', u'name': u'fas_svm1', u'subtype': u'default', u'state': u'present', u'snapshot_policy': u'default', u'aggr': u'sas_aggr_01', u'export_policy_clientmatch': u'10.128.57.0/24'}) => {
    "ansible_loop_var": "item",
    "changed": false,
    "invocation": {
        "module_args": {
            "aggr_list": null,
            "aggr_list_multiplier": null,
            "aggregate_name": "sas_aggr_02",
            "atime_update": null,
            "auto_provision_as": null,
            "auto_remap_luns": null,
            "cert_filepath": null,
            "check_interval": 30,
            "comment": null,
            "cutover_action": null,
            "efficiency_policy": null,
            "encrypt": false,
            "feature_flags": {},
            "force_restore": null,
            "force_unmap_luns": null,
            "from_name": null,
            "from_vserver": null,
            "group_id": null,
            "hostname": "10.128.58.113",
            "http_port": null,
            "https": true,
            "is_infinite": false,
            "is_online": true,
            "junction_path": "",
            "key_filepath": null,
            "language": null,
            "name": "fas_svm1_root_m1",
            "nvfail_enabled": null,
            "ontapi": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "percent_snapshot_space": null,
            "policy": "default",
            "preserve_lun_ids": null,
            "qos_adaptive_policy_group": null,
            "qos_policy_group": null,
            "size": 20,
            "size_unit": "mb",
            "snapdir_access": null,
            "snapshot_auto_delete": null,
            "snapshot_policy": "none",
            "snapshot_restore": null,
            "space_guarantee": "volume",
            "space_slo": null,
            "state": "present",
            "tiering_policy": null,
            "time_out": 180,
            "type": "DP",
            "unix_permissions": null,
            "use_rest": "Auto",
            "user_id": null,
            "username": "admin",
            "validate_certs": false,
            "volume_security_style": "ntfs",
            "vserver": "fas_svm1",
            "vserver_dr_protection": null,
            "wait_for_completion": false
        }
    },
    "item": {
        "aggr": "sas_aggr_01",
        "export_policy_clientmatch": "10.128.57.0/24",
        "ls_mirror_aggr": "sas_aggr_02",
        "name": "fas_svm1",
        "protocol": "cifs,nfs,iscsi",
        "snapshot_policy": "default",
        "state": "present",
        "subtype": "default"
    },
    "msg": "Error unmounting volume fas_svm1_root_m1: NetApp API failed. Reason - 13001:Invalid operation. Reason: Cannot unmount Vserver namespace root volume \"fas_svm1_root_m1\". "
}
lonico commented 4 years ago

@chjones45 In your playbook, I see junction_path: "". Is this on purpose? This triggers the attempt to unmount the volume.

chjones45 commented 4 years ago

@lonico ARGH! You are 100% correct. It's because the volume was intended to be a LS Mirror so during the create I didn't need/want a junction path for it.

I've now just removed the junction_path completely as it's not a required attribute.

It's working now. You're a legend! Thanks.