- name: 21-sysctl
  hosts: localhost
  
  vars:
          netapp_kernel_parameters:
              - { name: net.core.rmem_max, value: 16777216 }
              - { name: net.core.wmem_max, value: 16777216 }
              - { name: net.core.rmem_default, value: 16777216 }
              - { name: net.core.wmem_default, value: 16777216 }
              - { name: net.core.optmem_max, value: 16777216 }
              - { name: net.core.netdev_max_backlog, value: 300000 }
              - { name: net.ipv4.tcp_rmem, value: "65536 16777216 16777216" }
              - { name: net.ipv4.tcp_wmem, value: "65536 16777216 16777216" }
              - { name: sunrpc.tcp_slot_table_entries, value: 128 }
              - { name: sunrpc.tcp_max_slot_table_entries, value: 128 }
              - { name: net.ipv4.tcp_max_syn_backlog, value: 16384}
          sap_base_kernel_parameters:
              - { name: fs.aio-max-nr, value: 18446744073709551615 }
              - { name: net.ipv4.tcp_tw_reuse, value: 1 }
          local_kernel_parameters:
              - { name: net.ipv6.conf.all.disable_ipv6, value: 1 }
          etc_sysctl_netapp_conf: /etc/sysctl.d/91-hana-basenet.conf
          etc_sysctl_sap_conf: /etc/sysctl.d/92-sap-local.conf
          etc_sysctl_local_conf: /etc/sysctl.d/93-local.conf

  tasks:
    - name: setting kernel tunables for netapp
      sysctl:
        sysctl_file: "{{ etc_sysctl_netapp_conf }}"
        name: "{{ item.name }}"
        value: "{{ item.value }}"
        state: present
        sysctl_set: yes
        reload: yes
      with_items: "{{ netapp_kernel_parameters }}"

    - name: setting additional kernel tunables for SAP
      sysctl:
        sysctl_file: "{{ etc_sysctl_sap_conf }}"
        name: "{{ item.name }}"
        value: "{{ item.value }}"
        state: present
        sysctl_set: yes
        reload: yes
      with_items: "{{ sap_base_kernel_parameters }}"

    - name: setting local kernel tunables
      sysctl:
        sysctl_file: "{{ etc_sysctl_local_conf }}"
        name: "{{ item.name }}"
        value: "{{ item.value }}"
        state: present
        sysctl_set: yes
        reload: yes
      with_items: "{{ local_kernel_parameters }}"
