I am trying to create a code where user provides a client match and we have to find the export-policy of volume and qtree and then find the rule index where client present. When find, that particular client match will be deleted from rule index.
Please note that in this environment, rule indexes have multiple clients added and multiple rule indexes added in export-policy.
I am able to find export-policies for requested volume and qtree, but not able to check how to fetch rule index in netapp.ontap.na_ontap_rest_info
I used below code to gather qtree information like this below:
netapp.ontap.na_ontap_rest_info:
hostname: "{{ host_name }}"
username: "{{ username }}"
password: "{{ password }}"
use_rest: always
https: true
validate_certs: "{{ validate_certs | default ('false') }}"
gather_subset:
- storage_qtrees_config
fields:
- '*'
parameters:
volume.name: "{{ volume_name }}"
register: qtree_info
- debug: var=qtree_info
This is what I am using to remove client from export-policy:
- name: Remove requested clients in Export-policy of volume
netapp.ontap.na_ontap_export_policy_rule:
hostname: "{{ host_name }}"
vserver: "{{ vserver_name }}"
https: true
validate_certs: false
username: "{{ username }}"
password: "{{ password }}"
state: absent
ro_rule: any
rw_rule: never
protocol: nfs
super_user_security: sys
client_match: "{{ stop_sharing }}"
name: "{{ volume_export_policy }}"
Here the concern is if the rule index has exact match what I am passing in above module, that rule index is getting deleted but if that rule index has multiple clients then its skipping and not doing anything.
This module working like deleting export-policy rule when condition matches and not like export-policy remove-clientmatches.