ONTAP Rest API Discussions

set adv with na_ontap_rest_cli

SCL
1,220 Views

Hi -- I am wondering how to convert this functioning Ansible snippet into the REST version? TIA!

 

- name: run vserver cifs options modify is-netbios-over-tcp-enabled false
  na_ontap_command:
    command:
      - set adv;
      - vserver cifs options modify -vserver {{ item.name }} -is-netbios-over-tcp-enabled false
    return_dict: yes
    <<: *login
  with_items:
    - "{{ svm }}"
  register: command_result
  tags: [command,cifs-security]
1 ACCEPTED SOLUTION

JohnChampion
1,155 Views

This seems to work ... it will always show as 'changed' since there's no idempotence but that shouldn't be a problem.  The module handles the advanced privilege setting.

 

I assume you meant this module (na_ontap_rest_cli) and not a straight REST CLI call you'd make from code. If you did mean from code then you'd use the /private/cli API.

 

 

 gather_facts: no

  collections:
  - netapp.ontap

  module_defaults:
    group/netapp.ontap.netapp_ontap:
      hostname: xxx.xxx.xxx.xxx
      username: admin
      password: Netapp1!
      https: true
      validate_certs: false

  vars:
    svm:
      - { name: "svmCifsData" }

  tasks:

  - name: REST CLI

    netapp.ontap.na_ontap_rest_cli:

      command: 'vserver/cifs/options'
      verb: 'PATCH'
      params:
        vserver: "{{ item.name }}"
      body: {'is-netbios-over-tcp-enabled': false}

    with_items: "{{ svm }}"

    loop_control:
      label: "{{ item.name }}"

    register: result

    tags: [command,cifs-security]

  - debug:
      var: result

 

 

View solution in original post

2 REPLIES 2

JohnChampion
1,156 Views

This seems to work ... it will always show as 'changed' since there's no idempotence but that shouldn't be a problem.  The module handles the advanced privilege setting.

 

I assume you meant this module (na_ontap_rest_cli) and not a straight REST CLI call you'd make from code. If you did mean from code then you'd use the /private/cli API.

 

 

 gather_facts: no

  collections:
  - netapp.ontap

  module_defaults:
    group/netapp.ontap.netapp_ontap:
      hostname: xxx.xxx.xxx.xxx
      username: admin
      password: Netapp1!
      https: true
      validate_certs: false

  vars:
    svm:
      - { name: "svmCifsData" }

  tasks:

  - name: REST CLI

    netapp.ontap.na_ontap_rest_cli:

      command: 'vserver/cifs/options'
      verb: 'PATCH'
      params:
        vserver: "{{ item.name }}"
      body: {'is-netbios-over-tcp-enabled': false}

    with_items: "{{ svm }}"

    loop_control:
      label: "{{ item.name }}"

    register: result

    tags: [command,cifs-security]

  - debug:
      var: result

 

 

SCL
1,127 Views

Thanks @JohnChampion ! Good to know that the module will auto-handle the privilege issue.

Public