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 the remediate role, 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 the analysis role, 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.

Note

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.

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 sudo permissions for these nodes.
  • You have completed the Planning an upgrade and Preparing for the upgrade procedures.
  • You have installed the ansible-collection-redhat-leapp package to an Ansible control node running on RHEL 9 or RHEL 10.

    Note

    RHEL 9 contains ansible-core 2.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

  1. 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 to satellite for hosts registered with Satellite, rhui for hosts using RHUI repositories, and custom for 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-rhsm if 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.md file on the control node.

    Note that if you upgrade systems that run different RHEL versions, you can specify their variables within Ansible host_vars files.

  2. Validate the playbook syntax:

    $ ansible-playbook --syntax-check ~/analysis.yml

    Note that this command only validates the syntax and does not protect against a wrong but syntactically valid configuration.

  3. Run the playbook:

    $ ansible-playbook ~/analysis.yml
  4. Review 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."
    }
  5. Review the pre-upgrade report at one of the following locations:

    • /var/log/leapp/leapp-report.txt on the managed node.
    • <workdir>/ansible_leapp_<role_name>_logs_<timestamp> directory on the control node. This directory contains subdirectories for each managed node.

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

Procedure

  1. Review the host_vars files created by the analysis role on the control node. By default, the host_vars files are created in the playbook location. These files contain instructions on which remediate role tasks can be applied to remediate the upgrade inhibitors detected by the analysis role.

    Note

    Not all inhibitors can be remediated by the remediate Ansible role, and either must instead be remediated manually or cannot be remediated.

    The following is an example of a host_vars file:

    ---
    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>
  2. Use the remediate.yml playbook, generated by the analysis role, to resolve the identified inhibitors. This playbook executes the remediation role 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.remediate
    Note

    You 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.md file on the control node.

  3. Validate the playbook syntax:

    $ ansible-playbook --syntax-check ~/remediate.yml

    Note that this command only validates the syntax and does not protect against a wrong but valid configuration.

  4. Run the playbook:

    $ ansible-playbook ~/remediate.yml
  5. 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

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

Procedure

  1. 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 to satellite for hosts registered with Satellite, rhui for hosts using RHUI repositories, and custom for 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-rhsm if 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, or disabled to 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.md file on the control node.

  2. Validate the playbook syntax:

    $ ansible-playbook --syntax-check ~/upgrade.yml

    Note that this command only validates the syntax and does not protect against a wrong but valid configuration.

  3. 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."
    }
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat Documentation

Legal Notice

Theme

© 2026 Red Hat
Back to top