---

# can be configured by tuned profile sap-hana, entry "transparent_hugepages=never"
- name: Perform steps for setting transparent_hugepage=never
  block:
    - name: THP - Get contents of GRUB_CMDLINE_LINUX in /etc/default/grub
      command: grep GRUB_CMDLINE_LINUX /etc/default/grub
      register: __sap_hana_preconfigure_register_default_grub_cmdline_thp_assert
      changed_when: no

    - name: Assert that transparent_hugepage=never is in GRUB_CMDLINE_LINUX in /etc/default/grub
      assert:
        that: "'transparent_hugepage=never' in __sap_hana_preconfigure_register_default_grub_cmdline_thp_assert.stdout"
        fail_msg: "FAIL: 'transparent_hugepage=never' is not in GRUB_CMDLINE_LINUX in /etc/default/grub!"
        success_msg: "PASS: 'transparent_hugepage=never' is in GRUB_CMDLINE_LINUX in /etc/default/grub."
      ignore_errors: "{{ sap_hana_preconfigure_assert_ignore_errors|d(false) }}"

    - name: THP - Get contents of /proc/cmdline
      command: cat /proc/cmdline
      register: __sap_hana_preconfigure_register_proc_cmdline_thp_assert
      changed_when: no

    - name: Assert that transparent_hugepage=never is in /proc/cmdline
      assert:
        that: "'transparent_hugepage=never' in __sap_hana_preconfigure_register_proc_cmdline_thp_assert.stdout"
        fail_msg: "FAIL: 'transparent_hugepage=never' is not in /proc/cmdline!"
        success_msg: "PASS: 'transparent_hugepage=never' is in /proc/cmdline."
      ignore_errors: "{{ sap_hana_preconfigure_assert_ignore_errors|d(false) }}"

  when: not sap_hana_preconfigure_use_tuned or
        sap_hana_preconfigure_modify_grub_cmdline_linux or
        sap_hana_preconfigure_assert_all_config|d(false)
