<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ansible export-policy add-clientmatches and remove-clientmatches not available in ONTAP Discussions</title>
    <link>https://community.netapp.com/t5/ONTAP-Discussions/ansible-export-policy-add-clientmatches-and-remove-clientmatches-not-available/m-p/445820#M42554</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;---
  - 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: &amp;amp;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:
        &amp;lt;&amp;lt;: *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:
        &amp;lt;&amp;lt;: *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&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;ansible-playbook -vvv export_rules.yml&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/Matt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Jul 2023 03:12:40 GMT</pubDate>
    <dc:creator>mbeattie</dc:creator>
    <dc:date>2023-07-07T03:12:40Z</dc:date>
    <item>
      <title>ansible export-policy add-clientmatches and remove-clientmatches not available</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/ansible-export-policy-add-clientmatches-and-remove-clientmatches-not-available/m-p/445809#M42551</link>
      <description>&lt;P&gt;I want to add or remove clients from a rule in export-policy, the export-policy rule module deleting and adding rules only&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 09:47:20 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/ansible-export-policy-add-clientmatches-and-remove-clientmatches-not-available/m-p/445809#M42551</guid>
      <dc:creator>anusha90</dc:creator>
      <dc:date>2025-06-04T09:47:20Z</dc:date>
    </item>
    <item>
      <title>Re: ansible export-policy add-clientmatches and remove-clientmatches not available</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/ansible-export-policy-add-clientmatches-and-remove-clientmatches-not-available/m-p/445820#M42554</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;---
  - 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: &amp;amp;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:
        &amp;lt;&amp;lt;: *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:
        &amp;lt;&amp;lt;: *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&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;ansible-playbook -vvv export_rules.yml&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/Matt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jul 2023 03:12:40 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/ansible-export-policy-add-clientmatches-and-remove-clientmatches-not-available/m-p/445820#M42554</guid>
      <dc:creator>mbeattie</dc:creator>
      <dc:date>2023-07-07T03:12:40Z</dc:date>
    </item>
  </channel>
</rss>

