Upgrade RHEL7.9 to 8.x with leapp using Ansible

Latest response

Hello,
I'm trying to automate the upgrade process with ansible and when I try to run the following task I get some errors:

Task:

- hosts: upgrade
  tasks:
    - name: Generate leapp preupgrade report
      ansible.builtin.raw: leapp preupgrade
      ignore_errors: false
      register: leapp_preupgrade
      become: true

Errors:

==> Processing phase `configuration_phase`
====> * ipu_workflow_config
        IPU workflow config actor
==> Processing phase `FactsCollection`
====> * scancpu
        Scan CPUs of the machine.
====> * source_boot_loader_scanner
        Scans the boot loader configuration on the source system.
====> * tcp_wrappers_config_read
        Parse tcp_wrappers configuration files /etc/hosts.{allow,deny}.
====> * storage_scanner
        Provides data about storage settings.
====> * scan_custom_repofile
        Scan the custom /etc/leapp/files/leapp_upgrade_repositories.repo repo file.
====> * removed_pam_modules_scanner
        Scan PAM configuration for modules that are not available in RHEL-8.
====> * scan_files_for_target_userspace
        Scan the source system and identify files that will be copied into the target userspace when it is created.
====> * network_manager_read_config
        Provides data about NetworkManager configuration.
====> * scan_kernel_cmdline
        No documentation has been provided for the scan_kernel_cmdline actor.
====> * system_facts
        Provides data about many facts from system.
Process Process-199:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/usr/lib64/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python2.7/site-packages/leapp/repository/actor_definition.py", line 72, in _do_run
    actor_instance.run(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/leapp/actors/__init__.py", line 335, in run
    self.process(*args)
  File "/usr/share/leapp-repository/repositories/system_upgrade/common/actors/systemfacts/actor.py", line 36, in process
    self.produce(systemfacts.get_sysctls_status())
  File "/usr/share/leapp-repository/repositories/system_upgrade/common/actors/systemfacts/libraries/systemfacts.py", line 170, in get_sysctls_status
    return SysctlVariablesFacts(sysctl_variables=_get_sysctls())
  File "/usr/share/leapp-repository/repositories/system_upgrade/common/actors/systemfacts/libraries/systemfacts.py", line 22, in inner
    return list(f(*args, **kwargs))
  File "/usr/share/leapp-repository/repositories/system_upgrade/common/actors/systemfacts/libraries/systemfacts.py", line 143, in _get_sysctls
    for sc in run(['sysctl', '-a'], split=True)['stdout']:"
  File "/usr/lib/python2.7/site-packages/leapp/libraries/stdlib/__init__.py", line 188, in run
    result=result
CalledProcessError: Command ['sysctl', '-a'] failed with exit code 1.
============================================================================================="
Actor system_facts unexpectedly terminated with exit code: 1 - Please check the above details"
=============================================================================================
============================================================
                           ERRORS                           
============================================================
2022-04-13 16:21:34.524115 [ERROR] Actor: source_boot_loader_scanner"
Message: Failed to call `grubby` to list available boot entries."
Summary:"
    Details: Command ['grubby', '--info', 'ALL'] failed with exit code 1."
    Stderr: Process Process-183:"
            Traceback (most recent call last):"
              File "/usr/lib64/python2.7/multiprocessing/process.py", line 258, in _bootstrap"
                self.run()"
              File "/usr/lib64/python2.7/multiprocessing/process.py", line 114, in run"
                self._target(*self._args, **self._kwargs)"
              File "/usr/lib/python2.7/site-packages/leapp/repository/actor_definition.py", line 72, in _do_run"
                actor_instance.run(*args, **kwargs)"
              File "/usr/lib/python2.7/site-packages/leapp/actors/__init__.py", line 335, in run"
                self.process(*args)"
              File "/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/actors/sourcebootloaderscanner/actor.py", line 18, in process"
                scan_source_boot_loader_configuration()"
              File "/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/actors/sourcebootloaderscanner/libraries/sourcebootloaderscanner.py", line 54, inscan_source_boot_loader_configuration",
                entries=scan_boot_entries()"
              File "/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/actors/sourcebootloaderscanner/libraries/sourcebootloaderscanner.py", line 17, inscan_boot_entries",
                grubby_output = run(CMD_GRUBBY_INFO_ALL, split=True)"
              File "/usr/lib/python2.7/site-packages/leapp/libraries/stdlib/__init__.py", line 181, in run"
                stdin=stdin, env=env, encoding=encoding)"
              File "/usr/lib/python2.7/site-packages/leapp/libraries/stdlib/call.py", line 217, in _call"
                os.execvpe(command[0], command, env=environ)"
              File "/usr/lib64/python2.7/os.py", line 353, in execvpe"
                _execvpe(file, args, env)"
              File "/usr/lib64/python2.7/os.py", line 380, in _execvpe"
                func(fullname, *argrest)
            OSError: [Errno 2] No such file or directory
============================================================
                       END OF ERRORS                        
============================================================
Debug output written to /var/log/leapp/leapp-preupgrade.log
============================================================
                           REPORT                           
============================================================
A report has been generated at /var/log/leapp/leapp-report.json
A report has been generated at /var/log/leapp/leapp-report.txt
============================================================
                       END OF REPORT                        
============================================================
Answerfile has been generated at /var/log/leapp/answerfile

Do you have any idea why this happens? I've also tried to run the command leapp preupgrade with the modules ansible.builtin.command and ansible.builtin.shell.
When I run the command manually on the server via an ssh connection, I get a full report without any errors.
Someone has already tried to this kind of job with Ansible. the only reference I've found using leapp with ansible is this role: https://github.com/mrjoshuap/ansible-leapp.

Thanks for any help ;)

Responses