Chapter 6. Upgrading large deployments by using Ansible roles
To efficiently upgrade large numbers of systems, you can automate parts of the upgrade process by using Ansible roles.
The following Ansible roles are available:
-
analysis- This Ansible role runs the pre-upgrade report, which analyzes the target system for upgradability and flags potential issues. Along with theremediaterole, this role replaces the Reviewing the pre-upgrade report manual procedure. -
remediate- This Ansible role fixes issues found in the pre-upgrade report. Along with theanalysisrole, this role replaces the Reviewing the pre-upgrade report manual procedure. -
upgrade- This Ansible role runs the upgrade from RHEL 7 to RHEL 8 on the target system and verifies that the upgrade was successful. This role replaces the Performing the upgrade and Verifying the upgrade manual procedures.
To use the analysis, remediate, and upgrade Ansible roles to upgrade from RHEL 7 to RHEL 8, you must install and run the roles from an Ansible control node running on RHEL 9 or RHEL 10. These Ansible roles are part of the ansible-collection-redhat-leapp package available in the AppStream repository on RHEL 9 and RHEL 10 and are supported by Red Hat.
You can also use these Ansible roles to upgrade from RHEL 8 to RHEL 9 from an Ansible control node running on RHEL 9 or RHEL 10 or from RHEL 9 to RHEL 10 from an Ansible control node running on RHEL 10.
6.1. Running the pre-upgrade report by using Ansible roles Copy linkLink copied to clipboard!
You can use the analysis Ansible role to run the pre-upgrade report on the target system. The pre-upgrade report summarizes potential problems and suggests recommended solutions. The report also helps you decide whether it is possible or advisable to proceed with the upgrade.
The analysis Ansible role is best used in conjunction with the remediate Ansible role, which completes the pre-upgrade process by remediating and fixing issues found within the report. These two roles replace the manual procedure described in Reviewing the pre-upgrade report.
Prerequisites
- You have prepared the control node and the managed nodes.
-
The account you use to connect to the managed nodes has
sudopermissions for these nodes. - You have completed the Planning an upgrade and Preparing for the upgrade procedures.
You have installed the
ansible-collection-redhat-leapppackage to an Ansible control node running on RHEL 9 or RHEL 10.NoteRHEL 9 contains
ansible-core2.14. This Ansible version supports managing RHEL 7, RHEL 8, and RHEL 9 nodes. Therefore, you can upgrade both RHEL 7 and RHEL 8 managed nodes by using a RHEL 9 control node.
Procedure
Create a playbook file, for example
~/analysis.yml, with the following content:--- - name: RHEL pre-upgrade analysis hosts: managed-node-01.example.com tasks: - name: Generate pre-upgrade analysis report ansible.builtin.import_role: name: redhat.leapp.analysis vars: leapp_upgrade_type: satellite leapp_satellite_organization: <satellite_org> leapp_satellite_activation_key_post_analysis: <activation_key_post_analysis> leapp_satellite_activation_key: <activation_key>The settings specified in the example playbook include the following:
leapp_upgrade_type: <upgrade_type>-
Optional: The type of upgrade being performed. The default value is
cdn, which must be used for hosts registered with Red Hat CDN. Set tosatellitefor hosts registered with Satellite,rhuifor hosts using RHUI repositories, andcustomfor custom repositories. Note that the playbook example above uses Satellite, not the default CDN. leapp_satellite_organization: <organization>- Optional: Organization used in Satellite definition. Use only if upgrading by using Satellite. You can omit this variable if the system is registered with an activation key for a content view that includes both the current RHEL version and the next version repositories.
leapp_satellite_activation_key_post_analysis: <activation_key_post_analysis>- Optional: Activation key for the current RHEL version content view to register to after analysis. Use only if upgrading by using Satellite. You can omit this variable if the system is registered with an activation key for the content view, including both the current RHEL version and the next version.
leapp_satellite_activation_key: <activation_key>- Optional: Activation key for the content view, including both the current RHEL version and the next version. Use only if upgrading by using Satellite. You can omit this variable if the system is registered with an activation key for the content view, including both the current RHEL version and the next version.
leapp_preupg_opts: <options>Optional: List of command line options to run with the pre-upgrade command, namely:
-
--target <target_os_version> -
--enablerepo <repository_id>if you are upgrading with custom repositories -
--no-rhsmif you are upgrading with custom repositories -
--channel <channel>if you have an EUS or AUS subscription
-
leapp_answerfile: <answerfile>- Optional: In certain system configurations, the pre-upgrade report requires you to respond to certain true or false questions. This variable sets the true or false answer to the designated question.
For details about all variables that can be used in the playbook, see the
/usr/share/ansible/collections/ansible_collections/redhat/leapp/roles/analysis/README.mdfile on the control node.Note that if you upgrade systems that run different RHEL versions, you can specify their variables within Ansible
host_varsfiles.Validate the playbook syntax:
$ ansible-playbook --syntax-check ~/analysis.ymlNote that this command only validates the syntax and does not protect against a wrong but syntactically valid configuration.
Run the playbook:
$ ansible-playbook ~/analysis.ymlReview the output to confirm that the analysis was successful:
RUNNING HANDLER [redhat.leapp.analysis : Pre-upgrade analysis report is done] ************************************************************************************************* ok: [managed-node-01.example.com] => { "msg": "The pre-upgrade analysis report generation is now complete. SUCCESS: No inhibitors found. Review the tasks above or the result file at /var/log/leapp/leapp-report.txt." }Review the pre-upgrade report at one of the following locations:
-
/var/log/leapp/leapp-report.txton the managed node. -
<workdir>/ansible_leapp_<role_name>_logs_<timestamp>directory on the control node. This directory contains subdirectories for each managed node.
-
6.2. Remediating the pre-upgrade report by using Ansible roles Copy linkLink copied to clipboard!
You can use the remediate Ansible role to remediate and fix problems found on the target system by the pre-upgrade report. The pre-upgrade report summarizes potential problems and suggests recommended solutions. The report also helps you decide whether it is possible or advisable to proceed with the upgrade.
The remediate Ansible role is best used in conjunction with the analysis Ansible role, which starts the pre-upgrade process by analyzing the target system and generating the pre-upgrade report. These two roles replace the manual procedure described in Reviewing the pre-upgrade report.
Prerequisites
- You have prepared the control node and the managed nodes.
-
The account you use to connect to the managed nodes has
sudopermissions for these nodes. - You have completed the Planning an upgrade and Preparing for the upgrade procedures.
-
You have installed the
ansible-collection-redhat-leapppackage to an Ansible control node running on RHEL 9 or RHEL 10. -
You have generated the pre-upgrade report by using the
analysisAnsible role. See Reviewing the pre-upgrade report and Running the pre-upgrade report by using Ansible roles for more information.
Procedure
Review the
host_varsfiles created by the analysis role on the control node. By default, thehost_varsfiles are created in the playbook location. These files contain instructions on whichremediaterole tasks can be applied to remediate the upgrade inhibitors detected by the analysis role.NoteNot all inhibitors can be remediated by the
remediateAnsible role, and either must instead be remediated manually or cannot be remediated.The following is an example of a
host_varsfile:--- leapp_remediation_todo: - leapp_nfs_detected - leapp_remote_using_root leapp_satellite_activation_key: <activation_key> leapp_satellite_activation_key_post_analysis: <activation_key_post_analysis> leapp_satellite_activation_key_post_upgrade: <activation_key_post_upgrade>Use the
remediate.ymlplaybook, generated by theanalysisrole, to resolve the identified inhibitors. This playbook executes theremediationrole and you can customize the playbook to meet your requirements. For example:--- - name: Remediate hosts: managed-node-01.example.com tasks: - name: Perform remediations on the system ansible.builtin.include_role: name: redhat.leapp.remediateNoteYou can also create a new remediation playbook instead of copying the generated playbook. For more information, see the
/usr/share/ansible/collections/ansible_collections/redhat/leapp/roles/remediate/README.mdfile on the control node.Validate the playbook syntax:
$ ansible-playbook --syntax-check ~/remediate.ymlNote that this command only validates the syntax and does not protect against a wrong but valid configuration.
Run the playbook:
$ ansible-playbook ~/remediate.yml- After remediations are applied, re-run the pre-upgrade report. For more information, see Running the pre-upgrade report by using Ansible roles.
6.3. Upgrading to RHEL 8 by using Ansible roles Copy linkLink copied to clipboard!
You can use the upgrade Ansible role to upgrade the RHEL 7 target system to RHEL 8 and to run verification steps to ensure the upgrade was successful.
The upgrade role replaces the Performing the upgrade and Verifying the upgrade manual procedures.
Prerequisites
- You have prepared the control node and the managed nodes.
-
The account you use to connect to the managed nodes has
sudopermissions for these nodes. - You have completed the Planning an upgrade and Preparing for the upgrade procedures.
-
You have installed the
ansible-collection-redhat-leapppackage to an Ansible control node running on RHEL 9 or RHEL 10. -
You have generated and remediated the pre-upgrade report, either by manually running the pre-upgrade report or by using the
analysisandremediateAnsible roles, and no longer have any inhibitors in the report. See Reviewing the pre-upgrade report, Running the pre-upgrade report by using Ansible roles, and Remediating the pre-upgrade report by using Ansible roles for more information.
Procedure
Create a playbook file, for example
~/upgrade.yml, with the following content:--- - name: RHEL upgrade hosts: managed-node-01.example.com tasks: - name: Perform OS upgrade ansible.builtin.import_role: name: redhat.leapp.upgrade vars: leapp_upgrade_type: satellite leapp_satellite_organization: <satellite_org> leapp_satellite_activation_key: <activation_key> leapp_satellite_activation_key_post_upgrade: <activation_key_post_upgrade> leapp_upgrade_opts: --target 8.10 leapp_selinux_mode: permissive ...The settings specified in the example playbook include the following:
leapp_upgrade_type: <upgrade_type>-
Optional: The type of upgrade being performed. The default value is
cdn, which should be used for hosts registered with Red Hat CDN. Set tosatellitefor hosts registered with Satellite,rhuifor hosts using RHUI repositories, andcustomfor custom repositories. leapp_satellite_organization: <satellite_org>- Optional: Organization used in Satellite definition. Use only if upgrading by using Satellite. You can omit this variable if the system is registered with an activation key for the content view, including both the current RHEL version and the next version.
leapp_satellite_activation_key: <activation_key>- Optional: Activation key for the content view, including both the current RHEL version and the next version. Use only if upgrading by using Satellite. You can omit this variable if the system is registered with an activation key for the content view, including both the current RHEL version and the next version.
leapp_satellite_activation_key_post_upgrade: <activation_key_post_upgrade>- Optional: Activation key for the content view with the next RHEL version to register to after the upgrade. Use only if upgrading by using Satellite. You can omit this variable if the system is registered with an activation key for the content view, including both the current RHEL version and the next version.
leapp_upgrade_opts: <options>Optional: List of command line options to run with the upgrade command, namely:
-
--target <target_os_version> -
--enablerepo <repository_id>if you are upgrading with custom repositories -
--no-rhsmif you are upgrading with custom repositories -
--channel <channel>if you have an EUS or AUS subscription
-
leapp_selinux_mode: <mode>-
Optional: By default, the SELinux mode on the RHEL 8 system is set to whichever mode was selected in RHEL 7. Enter
enforcing,permissive, ordisabledto change the mode in RHEL 8.
For details about all variables used in the playbook, see the
/usr/share/ansible/collections/ansible_collections/redhat/leapp/roles/upgrade/README.mdfile on the control node.Validate the playbook syntax:
$ ansible-playbook --syntax-check ~/upgrade.ymlNote that this command only validates the syntax and does not protect against a wrong but valid configuration.
Run the playbook:
$ ansible-playbook ~/upgrade.yml
Verification
Verify that the following message appears in the Ansible role output:
RUNNING HANDLER [redhat.leapp.upgrade : Ansible leapp in-place OS upgrade is done] ****************************************************************************************** ok: [managed-node-01.example.com] => { "msg": "The in-place OS upgrade is now complete. Engage partner teams to begin application validation." }
Next steps