---
- name: Update subscription info on RHEL
  become: true
  ansible.builtin.command: subscription-manager refresh --force
  changed_when: false
  when: ansible_distribution == "RedHat"
  tags:
    - subscription

- name: RedHat family EPEL installation
  become: true
  ansible.builtin.dnf:
    name: "epel-release"
    state: present
    update_cache: true
  when: ansible_os_family == "RedHat" and (not (ansible_distribution == "Fedora" or ansible_distribution == "RedHat"))
  tags:
    - dnf
    - packages
    - yum

- name: Install python-pexpect
  become: true
  ansible.builtin.apt:
    name: python-pexpect
    state: present
    update_cache: true
  when: ansible_os_family == "Debian" and ansible_python.version.major <= 2
  tags:
    - apt
    - packages
    - python

- name: Install python3-pexpect
  become: true
  ansible.builtin.apt:
    name: python3-pexpect
    state: present
    update_cache: true
  when: ansible_os_family == "Debian" and ansible_python.version.major >= 3
  tags:
    - apt
    - packages
    - python

- name: Install python2-rpm
  become: true
  ansible.builtin.dnf:
    name: "python2-rpm"
    state: present
  when: ansible_distribution == "RedHat" and ansible_python.version.major <= 2
  tags:
    - dnf
    - packages
    - python
    - yum

- name: Install python3-rpm
  become: true
  ansible.builtin.dnf:
    name: "python3-rpm"
    state: present
  when: ansible_distribution == "RedHat" and ansible_python.version.major >= 3
  tags:
    - dnf
    - packages
    - python
    - yum

- name: Install python3-passlib
  become: true
  ansible.builtin.package:
    name: python3-passlib
    state: present
  register: python3_passlib
  failed_when:
    - python3_passlib.rc is defined
    - python3_passlib.rc != 0
    - not ansible_distribution == "AlmaLinux"
  tags:
    - apt
    - dnf
    - packages
    - python
    - yum

- name: Install Python pip
  when:
    - python3_passlib.rc is defined
    - python3_passlib.rc != 0
  block:
    - name: Python3-pip installation
      become: true
      ansible.builtin.package:
        name: "python3-pip"
        state: present
      tags:
        - dnf
        - packages
        - python
        - yum

    - name: Pip passlib installation
      become: true
      ansible.builtin.pip:
        name: "passlib"
        state: present
      tags:
        - dnf
        - packages
        - python
        - yum

- name: EFI or UEFI booting check
  ansible.builtin.set_fact:
    booted_with_efi: "{{ ansible_mounts | selectattr('mount', 'equalto', '/boot/efi') | list | length > 0 }}"
  tags:
    - fact
...
