ONTAP Discussions

ansible export-policy add-clientmatches and remove-clientmatches not available

anusha90
1,135 Views

I want to add or remove clients from a rule in export-policy, the export-policy rule module deleting and adding rules only

1 REPLY 1

mbeattie
1,086 Views

Hi,

 

You might have to first enumerate the clientmatches in the export policy rules by index, assign it to a variable and replace the clientmatches to remove. Here's a start

 

---
  - hosts: localhost
    gather_facts: false
    name: Get Export Policy Rules
    vars_prompt:
      # Some special characters, such as '{' and '%' in passwords can create templating errors. If you need to accept special characters, use the "unsafe" option
      - name: "password"
        prompt: "Please enter the cluster password"
        unsafe: yes
        private: yes
    vars:
      login: &login
        hostname: cluster1.testlab.local
        username: admin
        password: "{{ password }}"
        https: true
        validate_certs: false
        use_rest: Always
      vserver: testsvm1
      export_policy: ansible_001
      rule_index: 1

    tasks:

    - name: Get Export Policy
      netapp.ontap.na_ontap_rest_info:
        <<: *login
        use_python_keys: true
        parameters:
          svm.name: "{{ vserver }}"
          name: "{{ export_policy }}"
        fields:
          - id
          - svm.name
          - name
        gather_subset:
          - protocols/nfs/export-policies
      register: get_export_policy
      tags: get_export_policy

    - name: Get Export Policy
      netapp.ontap.na_ontap_zapit:
        <<: *login
        zapi:
          export-rule-get-iter:
            desired-attributes:
              export-rule-info:
                - client-match
            query:
              export-rule-info:
                - policy-name: "{{ export_policy }}"
                - rule-index: "{{ rule_index }}"
                - vserver-name: "{{ vserver }}"
      when:
        get_export_policy.ontap_info.protocols_nfs_export_policies.num_records == 1
      register: export_policy_rules

 ansible-playbook -vvv export_rules.yml

 

/Matt

 

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.
Public