---

- name: Create file /etc/init.d/boot.local if it does not exist
  file:
    path: /etc/init.d/boot.local
    state: touch
    mode: 0755

- name: Configure - Get info about file /etc/init.d/boot.local
  stat:
    path: /etc/init.d/boot.local
  register: __sap_hana_preconfigure_register_stat_boot_local_ksm

- name: Disable KSM at boot time
  lineinfile:
    dest: /etc/init.d/boot.local
    line: "echo 0 > /sys/kernel/mm/ksm/run"
  when: __sap_hana_preconfigure_register_stat_boot_local_ksm.stat.exists

- name: Disable KSM on the running system
  shell: echo 0 > /sys/kernel/mm/ksm/run
  register: __sap_hana_preconfigure_register_disable_ksm
  changed_when: true

- name: Configure - Get status of KSM
  command: cat /sys/kernel/mm/ksm/run
  register: __sap_hana_preconfigure_register_ksm_status
  ignore_errors: true
  changed_when: false

- name: Display the status of KSM
  debug:
    var: __sap_hana_preconfigure_register_ksm_status.stdout_lines, __sap_hana_preconfigure_register_ksm_status.stderr_lines
