#na_ontap_export_rule

1 messages · Page 1 of 1 (latest)

peak oak
#

Hello, I'm starting to develop different scripts wusing REST Api. I would need to understand how create different rules after creating the export policy with na_ontap_export indeed. My approach is using a temp file loaded in vars_files and then create the different rules based on that. Now, the problem I read is that I should duplicate the tasks for all the IPs...and yes clear but this file can have variable entries and not a fixed number of IPs and rules (ro,rw,su). do you already know a right method to do this job? Thank you in advance

olive wraith
#

you can create export policy rules with something like the following:

- name: Create ExportPolicyRule
  netapp.ontap.na_ontap_export_policy_rule:
    state: present
    name: default123
    rule_index: 100
    vserver: ci_dev
    client_match: 1.1.1.0/24
    ro_rule: sys
    rw_rule: sys
    protocol: nfs3
    super_user_security: sys
    anonymous_user_id: 65534
    allow_suid: true
    ntfs_unix_security: ignore
    hostname: "{{ netapp_hostname }}"
    username: "{{ netapp_username }}"
    password: "{{ netapp_password }}"

There is no need to load a temp file anywhere. You can just loop over IP addresses (for example) using the loop: construct

peak oak
#

Yes I know that I can use the /24 or whatever else but we are enforcing always specfic IPs for each volume/share and for security reasons. So I'm using the subnet only for root volumes and not for the others. But thank you for your suggestion; I will check the loop construct!

olive wraith
#

something like this should do the trick:

- name: Create ExportPolicyRule
  netapp.ontap.na_ontap_export_policy_rule:
    state: present
    ...
    client_match: {{ item }}/32
    ...
  loop:
    - 192.168.0.1
    - 192.168.0.2
    - 192.168.0.3
peak oak
#

already a good trick thank you... I will try asap

olive wraith
#

you can also populate the list to loop over from other sources. from gather_facts for example, or through inventory files or even build it dynamically