ONTAP Discussions
ONTAP Discussions
Hi Guys,
We have a setup wherein today we apply Export Policy per Qtree but while looking into Ansible modules i dont see option to apply Export policy to Qtree while creating a Qtree. I can only see export policy option available at Volume level.
Is it not available at Qtree level?
Hi Raj,
Looking at the latest module for Qtrees it appears to be possible to set an export policy using the "export_policy" property.
https://docs.ansible.com/ansible/latest/modules/na_ontap_qtree_module.html
/Matt
Thanks Matt for the reply. I added the "export_policy" property but getting below error.
$ ansible-playbook Qtree_Create_template.yml --extra-vars "@Qtree_Create_Variable.yml"
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
PLAY [Qtree Action] ****************************************************************************************************************************************************************************
TASK [Gathering Facts] *************************************************************************************************************************************************************************
ok: [localhost]
TASK [Create Qtrees] ***************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (na_ontap_qtree) module: export_policy Supported parameters include: flexvol_name, from_name, hostname, http_port, https, name, ontapi, password, state, username, validate_certs, vserver"}
PLAY RECAP *************************************************************************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
My Ansible version is 2.8.4
Python 3.7
Hi Raj,
I tested it, here is an example playbook:
---
- hosts: localhost
  gather_facts: false
  name: na_ontap_qtree
  vars:
    login: &login
      hostname: cluster1.testlab.local
      username: admin
      password: N0tMyP@ssw0rd!
      https: yes
      use_rest: Always
      validate_certs: no
  tasks:
  - name: Create qtree
    na_ontap_qtree:
      export_policy: policy_001
      flexvol_name: nfs_data_001
      name: qtree_001
      oplocks: enabled
      security_style: unix
      state: present
      vserver: vserver2
      <<: *login
When i run the playbook it works successfully.
[root@testux1 playbooks]# ansible-playbook qtree.yml
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
PLAY [na_ontap_qtree] *******************************************************************************************************************************************************************************
TASK [Create qtree qtree_001 in volume nfs_data_001 on vserver vserver4] ****************************************************************************************************************************
changed: [localhost]
PLAY RECAP ******************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
The storage shows the qtree created on the volume exported to the policy.
cluster1::> qtree show -vserver vserver2 -volume nfs_data_001 -qtree qtree_001 -instance
                                 Vserver Name: vserver2
                                  Volume Name: nfs_data_001
                                   Qtree Name: qtree_001
             Actual (Non-Junction) Qtree Path: /vol/nfs_data_001/qtree_001
                               Security Style: unix
                                  Oplock Mode: enable
                             Unix Permissions: ---rwxr-xr-x
                                     Qtree Id: 1
                                 Qtree Status: normal
                                Export Policy: policy_001
                   Is Export Policy Inherited: false
It is possible, perhaps you need to update the module?
https://docs.ansible.com/ansible/latest/modules/na_ontap_qtree_module.html
/Matt
Thanks a lot Guys for your help. I upgraded my ansible to 2.9 and now i can this export_policy parameter in qtree module and able to update it via playbook.
Take care everyone.