# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

---
# Set 'sap' as tuned profile
# Disable SELinux
# Disable core file creation


- name:                                "2.10.2 sap-notes: - Collect facts about installed packages"
  ansible.builtin.package_facts:

- name:                                "2.10.2 sap-notes: - Ensure tuned-profiles-sap is installed"
  ansible.builtin.dnf:
    name:                              tuned-profiles-sap
    state:                             present
  when:                                "'tuned-profiles-sap' not in ansible_facts.packages"

- name:                                "2.10.2 sap-notes: - Ensure tuned service is running and enabled"
  ansible.builtin.systemd:
    name:                              tuned
    state:                             started
    enabled:                           true

- name:                                "2.10.3 sap-notes: - Set 'sap' as tuned profile"
  ansible.builtin.command:             tuned-adm profile sap-netweaver
  changed_when:                        false

- name:                                "2.10.2 sap-notes: - Disable core file creation"
  ansible.builtin.lineinfile:
    path:                              /etc/security/limits.d/99-sap.conf
    regexp:                            "@sapsys\\s*{{ item }}\\s*core\\s*0"
    line:                              "@sapsys    {{ item }}    core    0"
    owner:                             root
    group:                             root
    mode:                              0600
    create:                            true
  with_items:
    - soft
    - hard

- name:                                "2.10.3 sap-notes: - Disable SELinux"
  ansible.posix.selinux:
    state:                             disabled
  notify:                              "2.10-sap-notes: Reboot after the selinux is configured"
  tags: ansible_skip_lint


- name:                                "2.10.2 - Force all notified handlers to run now"
  ansible.builtin.meta:                flush_handlers

...
# /*----------------------------------------------------------------------------8
# |                                    END                                      |
# +-------------------------------------4--------------------------------------*/
