---
- name: Configure sysconfig prelink
  ansible.builtin.stat:
    path: /etc/sysconfig/prelink
  register: sysconfig_prelink
  tags:
    - prelink

- name: Stat prelink configuration file
  ansible.builtin.stat:
    path: /etc/prelink.conf
  register: etc_prelink
  tags:
    - prelink

- name: Disable prelinking
  become: true
  ansible.builtin.lineinfile:
    line: "PRELINKING=no"
    dest: /etc/sysconfig/prelink
    mode: "0644"
    state: present
    create: true
  when: ansible_os_family == "RedHat" and sysconfig_prelink.stat.exists
  tags:
    - prelink

- name: Return to non-prelinked state
  become: true
  ansible.builtin.command: prelink -ua # noqa no-changed-when
  when: sysconfig_prelink.stat.exists or etc_prelink.stat.exists
  tags:
    - prelink
    - CIS-UBUNTU2004-1.5.3
