ansible-collections / netapp.ontap

Ansible collection to support NetApp ONTAP configuration.
https://galaxy.ansible.com/netapp/ontap
GNU General Public License v3.0
55 stars 35 forks source link

type parameter in na_ontap_volume should not be case sensitive #177

Closed joecaruso closed 8 months ago

joecaruso commented 11 months ago

Summary

When specifying the type parameter in na_ontap_volume, if you specify RW it will cause the task to fail with a fatal error after the volume has been created on the storage cluster. This appears to be due to the API returning the type as rw (lower case) as part of a GET response on the object. The na_ontap_volume module code should handle this difference and allow the user to specify the volume type as either upper or lower case. When the type is specified as rw in the module, it works as expected.

Component Name

na_ontap_volume

Ansible Version

(venv) [jcaruso@storshelladmindal0501 ansible]$ ansible --version
ansible 2.9.27
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/jcaruso/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/venv/lib/python2.7/site-packages/ansible
  executable location = /usr/local/venv/bin/ansible
  python version = 2.7.5 (default, May 27 2022, 11:27:32) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]

ONTAP Collection Version

]$ cat ~/.ansible/collections/ansible_collections/netapp/ontap/README.md | grep -A 3 'Release Notes' 
# Release Notes

## 22.7.0

ONTAP Version

natestdal0505-fc::> version
NetApp Release 9.8P18: Wed Mar 29 13:19:30 UTC 2023

Playbook

See playbook below.

Steps to Reproduce

---
- hosts: localhost
  gather_facts: false
  name: Test playbook
  vars_prompt:
    - name: netapp_hostname
      prompt: "Enter the Cluster name"
      private: false
    - name: netapp_username
      prompt: "Enter local Cluster admin username"
      private: false
      default: "admin"
    - name: netapp_password
      prompt: "Enter local Cluster admin password"
  vars:
    login: &login
      hostname: "{{ netapp_hostname }}"
      username: "{{ netapp_username }}"
      password: "{{ netapp_password }}"
      validate_certs: false
      https: true

  tasks:
    - name: Create nfs volume
      netapp.ontap.na_ontap_volume:
        <<: *login
        state: present
        name: ansible_testvol
        junction_path: /ansible_testvol
        aggregate_name: aggr_natestdal0505_fc_c_ssd01
        size: 10
        unix_permissions: '755'
        size_unit: gb
        type: RW
        space_guarantee: none
        snapshot_policy: none
        vserver: natestdal0505-fc_vs00
        wait_for_completion: true

    - name: Get volume info
      netapp.ontap.na_ontap_rest_info:
        <<: *login
        gather_subset:
          - storage/volumes
        parameters:
          name: ansible_testvol
          svm.name: natestdal0505-fc_vs00
        fields:
          - name
          - type
      register: volume_info

    - debug:
        var: volume_info

Expected Results

Task should run without a failure. The input of "type" parameter should not be case sensitive.

Actual Results

When you run the task the first time, it will create the volume in ONTAP but will return this error

TASK [Create nfs volume] ************************************************************************************************************************************************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Error: volume type was not set properly at creation time.  Current: rw, desired: RW."}

If you run the task a second time after the volume is created, you will see this error.

TASK [Create nfs volume] ************************************************************************************************************************************************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Error: changing a volume from one type to another is not allowed.  Current: rw, desired: RW."}

Looking at the output of an na_ontap_rest_info call.  I see that the API is returning the "type" field as "rw" instead of "RW"

TASK [debug] *********************************************************************************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "volume_info": {
        "changed": false, 
        "failed": false, 
        "ontap_info": {
            "storage/volumes": {
                "_links": {
                    "self": {
                        "href": "/api/storage/volumes?fields=name%2Ctype&max_records=1024&svm.name=natestdal0505-fc_vs00&name=ansible_testvol"
                    }
                }, 
                "num_records": 1, 
                "records": [
                    {
                        "_links": {
                            "self": {
                                "href": "/api/storage/volumes/c4a954ca-6905-11ee-b059-d039ea4f9878"
                            }
                        }, 
                        "name": "ansible_testvol", 
                        "svm": {
                            "name": "natestdal0505-fc_vs00"
                        }, 
                        "type": "rw", 
                        "uuid": "c4a954ca-6905-11ee-b059-d039ea4f9878"
                    }
                ]
            }
        }
    }
}

PLAY RECAP ***********************************************************************************************************************************************************************************************************************************************************************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0
carchi8py commented 11 months ago

@joecaruso sorry for the delay for this.

I have story DEVOPS-6487 open for this.

carchi8py commented 8 months ago

This was ixed in 22.9.0