- name: yum elrepo-release
  become: true
  yum:
    update_cache: yes
    name: epel-release,elrepo-release
  when: ansible_distribution_major_version|int == 7
- name: yum plugin
  become: true
  yum:
    update_cache: yes
    name: yum-plugin-elrepo
  when: ansible_distribution_major_version|int == 7
- name: yum install kernel
  become: true
  yum:
    update_cache: yes
    state: latest
    name: kernel-ml
    enablerepo: elrepo-kernel
  when: ansible_distribution_major_version|int == 7
- name: yum kernel-devel if possible
  become: true
  ignore_errors: true
  yum:
    state: latest
    name: kernel-ml-devel
    enablerepo: elrepo-kernel
  when: ansible_distribution_major_version|int == 7
- name: yum kernel-headers if possible
  become: true
  ignore_errors: true
  yum:
    state: latest
    name: kernel-ml-headers
    enablerepo: elrepo-kernel
  when: ansible_distribution_major_version|int == 7
- name: yum remove wireguard-dkms
  become: true
  yum:
    name: kmod-wireguard,wireguard-dkms
    state: absent
  when: ansible_distribution_major_version|int >= 8
- name: dnf elrepo-release
  become: true
  dnf:
    update_cache: yes
    name: epel-release,elrepo-release
  when: ansible_distribution_major_version|int >= 8
- name: dnf plugin
  become: true
  dnf:
    update_cache: yes
    name: dnf-plugin-elrepo
  when: ansible_distribution_major_version|int >= 8
- name: dnf install kernel
  become: true
  dnf:
    update_cache: yes
    state: latest
    name: kernel-ml
    enablerepo: elrepo-kernel
  when: ansible_distribution_major_version|int >= 8
- name: dnf kernel-devel if possible
  become: true
  ignore_errors: true
  dnf:
    state: latest
    name: kernel-ml-devel
    enablerepo: elrepo-kernel
  when: ansible_distribution_major_version|int >= 8
- name: dnf kernel-headers if possible
  become: true
  ignore_errors: true
  dnf:
    state: latest
    name: kernel-ml-headers
    enablerepo: elrepo-kernel
  when: ansible_distribution_major_version|int >= 8
- name: dnf remove wireguard-dkms
  become: true
  dnf:
    name: kmod-wireguard,wireguard-dkms
    state: absent
  when: ansible_distribution_major_version|int >= 8
- name: change grub
  become: true
  lineinfile:
    path: /etc/default/grub
    regexp: '^GRUB_DEFAULT='
    line: 'GRUB_DEFAULT=0'
    backrefs: true
  register: change_grub_result
- name: make grub config
  when: change_grub_result.changed
  become: true
  shell: grub2-mkconfig -o /boot/grub2/grub.cfg
