#qtree test

1 messages · Page 1 of 1 (latest)

brittle sequoia
#

@lyric umbra double checked, qtree module is good, below are the tasks tried and its reponse

#
  • name: Delete Qtree
    tags: test
    na_ontap_qtree:
    state: absent
    name: ansibleQTree_1
    flexvol_name: "{{ volume_name }}"
    vserver: "{{ vserver }}"

    • name: Create Qtree
      tags: test
      na_ontap_qtree:
      state: present
      name: ansibleQTree_1
      flexvol_name: "{{ volume_name }}"
      security_style: mixed
      export_policy: policy1
      vserver: "{{ vserver }}"
      unix_permissions: rw-rw-rw-

    • name: Create Qtree - idempotent check.
      tags: test
      na_ontap_qtree:
      state: present
      name: ansibleQTree_1
      flexvol_name: "{{ volume_name }}"
      security_style: mixed
      export_policy: policy1
      vserver: "{{ vserver }}"
      unix_permissions: rw-rw-rw-

    • name: Try to Create Qtree on a volume that has a directory ansibleQTree in path /.
      tags: test
      na_ontap_qtree:
      state: present
      name: ansibleQTree
      flexvol_name: "{{ volume_name }}"
      security_style: mixed
      export_policy: policy1
      vserver: "{{ vserver }}"
      unix_permissions: rw-rw-rw-

#

response
PLAY [QTree test] ****************************************************************************************************

TASK [Delete Qtree] **************************************************************************************************
changed: [localhost]

TASK [Create Qtree] **************************************************************************************************
changed: [localhost]

TASK [Create Qtree - idempotent check.] ******************************************************************************
ok: [localhost]

TASK [Try to Create Qtree on a volume that has a directory ansibleQTree in path /.] **********************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Error creating qtree ansibleQTree: calling: storage/qtrees: got {'message': 'Failed to create qtree "ansibleQTree" in volume "ansibleVolQTree" SVM "svm0". Reason: Qtree (or directory) "ansibleQTree" already exists.', 'code': '5242886'}."}

PLAY RECAP ***********************************************************************************************************
localhost : ok=3 changed=2 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

#

I have a directory ansibleQTree in volume, so the last task throws error expected.

lyric umbra
#

Thanks ... so your "Create Qtree - idempotent check" that fails for me. I can run the create, that works, but if I run the create again it fails. It doesnt report "OK". I'll test it again now

#

I wonder if it's because of oplocks. My customer is setting oplocks, and that requires ZAPI.

#

I just tested it, this is my playbook

#
  • hosts: "netapp1_cbr"
    connection: local
    gather_facts: no
    collections:

    • netapp.ontap

    tasks:

Create Test Qtree

  • name: Create Qtree
    ignore_errors: no
    na_ontap_qtree:
    hostname: "{{ mgmt_ip }}"
    username: "{{ mgmt_username }}"
    password: "{{ mgmt_password }}"
    state: present
    name: "{{ curlyb }}{{ qtree_name | lower }}{{ curlya }}"
    vserver: "{{ vserver }}"
    flexvol_name: data
    export_policy: EP-{{ qtree_name | lower }}
    security_style: unix
    oplocks: enabled
    unix_permissions: '0755'
    https: true
    validate_certs: false

  • name: Create Qtree - idempotent check
    ignore_errors: no
    na_ontap_qtree:
    hostname: "{{ mgmt_ip }}"
    username: "{{ mgmt_username }}"
    password: "{{ mgmt_password }}"
    state: present
    name: "{{ curlyb }}{{ qtree_name | lower }}{{ curlya }}"
    vserver: "{{ vserver }}"
    flexvol_name: data
    export_policy: EP-{{ qtree_name | lower }}
    security_style: unix
    oplocks: enabled
    unix_permissions: '0755'
    https: true
    validate_certs: false

#

I ran that, and the "Create Qtree - idempotent check" task failed with the same error

#

"msg": "Error creating qtree {cjtest-really-long-name}: NetApp API failed. Reason - 13080:Failed to create qtree "{cjtest-really-long-name}" in volume "data" Vserver "cbr_primary". Reason: Qtree (or directory) "{cjtest-really-long-name}" already exists."

#

I'll remove the oplocks parameter and see if it works using Rest_API

brittle sequoia
#

oplocks should not be the issue. is it possible to check the volume has the directory same as qtree name?

lyric umbra
#

Ok ... so I just got it work. I think I know what's breaking it. it's the syntax of the qtree name

#

This customer uses really weird qtree names, which seem to be breaking the module.

#

I ran this:

Create Test Qtree

  • name: Create Qtree
    ignore_errors: no
    na_ontap_qtree:
    hostname: "{{ mgmt_ip }}"
    username: "{{ mgmt_username }}"
    password: "{{ mgmt_password }}"
    state: present
    name: cjtest
    vserver: "{{ vserver }}"
    flexvol_name: data
    export_policy: default
    security_style: unix
    oplocks: enabled
    unix_permissions: '0755'
    https: true
    validate_certs: false

  • name: Create Qtree - idempotent check
    ignore_errors: no
    na_ontap_qtree:
    hostname: "{{ mgmt_ip }}"
    username: "{{ mgmt_username }}"
    password: "{{ mgmt_password }}"
    state: present
    name: cjtest
    vserver: "{{ vserver }}"
    flexvol_name: data
    export_policy: default
    security_style: unix
    oplocks: enabled
    unix_permissions: '0755'
    https: true
    validate_certs: false

#

That code above worked. Note that the "name" is set to a simple string: cjtest

#

If I use the string for the qtree name that the customer uses, it fails. the create works, but the idempotent check fails.

#

The name the customer uses for a qtree is, in this test:

{cjtest-really-long-name}

#

This customer actually wants the squiggly brackets as part of the qtree name. Without the brackets it works. With them, it fails.

#

Could those brackets be messing with the idempotent check?

#

I just ran the playbook again to create the qtree as:

cjtest-really-long-name

That works as expect. The idempotent tasks passes with "OK"

But if the qtree name is:

{cjtest-really-long-name}

The idempotent task fails. So it's gotta be those brackets are messing with the code. This customer has over 1,600 qtrees in one single FlexGroup, so changing the naming is not really an option

#

To me it appears like the check for the qtree name already existing isn't escaping the { and } correctly, or something.

#

I'm happy to take this offline via Teams (I am a NetApp PS Consultant in Australia) if that's more suitable.

brittle sequoia
lyric umbra
#

ok, let me test that out, thanks.

#

dude, you're a legend! That worked. Far out

#

name: "\{{ curlyb }}{{ qtree_name | lower }}\{{ curlya }}"

#

That works. LEGEND!

lyric umbra
#

hmmm ... nah actualoly, that doesn't work

#

having real trouble getting it to escape a single {

#

it works for the create, but still falling over on the idempotent check ... are you able to make a qtree that starts and ends with {} ??

brittle sequoia
#

yes

lyric umbra
#

hmm ... are you able to make it work when the "cjtest-really-long-name" is a variable itself?

#

sorry about this. it's driving my insane trying to get this to work and the customer is pushing back hard that we must fix this or it's "all NetApp's fault" ... the usual story 😦

brittle sequoia
#

above file is for using special characters in name, we have to skip it if need it in name.
but I suspect, the user want to reference variable, have to use this format "{{ variable_name }}" , so the value of variable_name will be substituted.

#

is it possible to share the entire playbook, put some dummy value for hostname/username/password so I can see

lyric umbra
#

yep, thats exactly what they want. They want the { to be a variable, then the qtree name "cjtest-really-long-name" to be a variable, and the final } to also be a variable

#

sure, two secs

#

`- hosts: "<host>"
connection: local
gather_facts: no
collections:
- netapp.ontap

tasks:

Create Test Qtree

  • name: Create Qtree
    ignore_errors: no
    na_ontap_qtree:
    hostname: "{{ mgmt_ip }}"
    username: "{{ mgmt_username }}"
    password: "{{ mgmt_password }}"
    state: present
    name: "{{ curlyb }}{{ qtree_name | lower }}{{ curlya }}"
    vserver: "{{ vserver }}"
    flexvol_name: data
    export_policy: EP-{{ qtree_name | lower }}
    security_style: unix
    oplocks: enabled
    unix_permissions: '0755'
    https: true
    validate_certs: false`
#

That's the playbook. let me get the host_vars

#

And the host_vars:

`mgmt_ip: x.x.x.x
mgmt_username: "domain\user"
mgmt_password: "password"

qtree_name: "cjtest-really-long-name"
vserver: "cbr_primary"

curlyb: "{"
curlya: "}"`

#

I've tried different ways to call in the "curlyb" and "curlya" variables into the task, but can't seem to get it correct. The customer has refuted my suggestions to just put the brackets into the variable for the qtree_name ... they flat out reject it, which is frustrating

brittle sequoia
#

@icy hill @cold jackal
name: "{{ curlyb }}{{ qtree_name | lower }}{{ curlya }}"
this resolves to {cjtest-really-long-name}.

it creates qtree with name {cjtest-really-long-name}, but in the 2nd run both ZAPI/REST cannot find and try to create the a new qtree.
"msg": "Error creating qtree {cjtest-really-long-name}: calling: storage/qtrees: got {'message': 'Failed to create qtree "{cjtest-really-long-name}" in volume "ansibleVolQTree" SVM "svm0". Reason: Qtree (or directory) "{cjtest-really-long-name}" already exists.'

#

if we set brackets -
curlyb: "("
curlya: ")"
its good.

cold jackal
#

do they really want to have "{" or "}" in the name of the qtree ?

icy hill
#

So looking at Stackoverflow it look like you can escape the brances by doing

{{ '{' }}

#

and that would become the string {

#

"{{ '{' }}{{ qtree_name | lower }}{{ '}' }}"
so if you try this, i think it might work correctly

#

though now that i read the top, it look like that what you did but with variables

#

@brittle sequoia can you try this out. create a qtree with {cjtest-really-long-name}, and then try the rest api directly

brittle sequoia
#

yes it works, but not idempotent

icy hill
#

just to see if it return to us with the currly bracses or not

#

or if the rest api is coverting it { to { or { and that why the matching isn't woring

brittle sequoia
#

with {{ '{' }} it creates good.
ontap910::> qtree show -vserver svm0
Vserver Volume Qtree Style Oplocks Status


svm0 ansibleVolQTree
{cjtest-really-long-name}
mixed enable normal

on the second run error

#

fatal: [localhost]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"cert_filepath": null,
"export_policy": "policy1",
"feature_flags": {
"trace_apis": true
},
"flexvol_name": "ansibleVolQTree",
"force_delete": true,
"force_ontap_version": null,
"from_name": null,
"hostname": "",
"http_port": null,
"https": true,
"key_filepath": null,
"name": "{cjtest-really-long-name}",
"ontapi": null,
"oplocks": null,
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"security_style": "mixed",
"state": "present",
"time_out": 180,
"unix_group": null,
"unix_permissions": "rw-rw-rw-",
"unix_user": null,
"use_rest": "always",
"username": "admin",
"validate_certs": false,
"vserver": "svm0",
"wait_for_completion": true
}
},
"msg": "Error creating qtree {cjtest-really-long-name}: calling: storage/qtrees: got {'message': 'Failed to create qtree "{cjtest-really-long-name}" in volume "ansibleVolQTree" SVM "svm0". Reason: Qtree (or directory) "{cjtest-really-long-name}" already exists.', 'code': '5242886'}."
}

brittle sequoia
lyric umbra
lyric umbra
cold jackal