---
- name: Upgrade RHEL 7 to RHEL 8
hosts: all
become: true
vars:
leapp_repo: "rhel-7-server-extras-rpms"
tasks:
- name: Ensure system is up to date
yum:
name: '*'
state: latest
- name: Install the Leapp utility
yum:
name: leapp
state: present
enablerepo: "{{ leapp_repo }}"
- name: Run the pre-upgrade check with Leapp
shell: leapp preupgrade
register: leapp_preupgrade
ignore_errors: true
- name: Check for pre-upgrade issues
debug:
msg: "Leapp pre-upgrade check output: {{ leapp_preupgrade.stdout }}"
- name: Fix any issues identified by Leapp (manual step)
pause:
prompt: "Please review the pre-upgrade report at /var/log/leapp/leapp-report.txt and fix any blocking issues. Press Enter to continue."
- name: Proceed with the upgrade
shell: leapp upgrade
ignore_errors: true
- name: Reboot the server to complete the upgrade
reboot:
reboot_timeout: 1200
- name: Verify the OS version after reboot
shell: cat /etc/redhat-release
register: os_version
- name: Display the new OS version
debug:
msg: "The server has been successfully upgraded to: {{ os_version.stdout }}"