---
# SAP Note: 3024346 - Linux Kernel Settings for NetApp NFS
#
- name: Configure - Display SAP note number 3024346 and its version
  debug:
    msg: "SAP note {{ (__sap_hana_preconfigure_sapnotes_versions | selectattr('number', 'match', '^3024346$') | first).number }}
          (version {{ (__sap_hana_preconfigure_sapnotes_versions | selectattr('number', 'match', '^3024346$') | first).version }}): Linux kernel settings for NetApp NFS"

- name: Set kernel tunables for NetApp NFS as per SAP note 3024346
  block:

    - name: Modify entries in file '{{ __sap_hana_preconfigure_etc_sysctl_netapp_hana_conf }}'
      lineinfile:
        path: "{{ __sap_hana_preconfigure_etc_sysctl_netapp_hana_conf }}"
        create: yes
        mode: 0644
        regexp: ^{{ line_item.name }}.*
        line: "{{ line_item.name }}={{ line_item.value }}"
        state: present
      with_items: "{{ __sap_hana_preconfigure_kernel_parameters_netapp_nfs }}"
      loop_control:
        loop_var: line_item

    - name: Reload kernel parameters from file '{{ __sap_hana_preconfigure_etc_sysctl_netapp_hana_conf }}'
      command: sysctl -p "{{ __sap_hana_preconfigure_etc_sysctl_netapp_hana_conf }}"
      register: __sap_hana_preconfigure_register_netapp_sysctl_p_output

    - name: Display kernel parameters for NetApp NFS
      debug:
        var: __sap_hana_preconfigure_register_netapp_sysctl_p_output.stdout_lines

    - name: Set kernel tunable for NFSv3 as per SAP note 3024346
      lineinfile:
        path: /etc/modprobe.d/sunrpc.conf
        create: yes
        mode: 0644
        regexp: '^options sunrpc tcp_max_slot_table_entries'
        line: options sunrpc tcp_max_slot_table_entries=128
      when: sap_hana_preconfigure_use_netapp_settings_nfsv3

  when:
    - sap_hana_preconfigure_use_netapp_settings_nfs|d(false)
    - sap_hana_preconfigure_config_all|d(true) or sap_hana_preconfigure_3024346|d(false)
