def _rhel_kernel_info(packages, kernel_version, current_version):
    """
    Return kernel to install with associated repository.

    Args:
        packages (dict): DNF/YUM list output.
        kernel_version (str): Kernel version to install.
        current_version (str): Current kernel version.

    Returns:
       dict: kernel version, repository
    """
    kernels = list()

    if current_version.startswith(kernel_version):
        kernel_version = current_version.rsplit(".", 1)[0]

    for line in packages["stdout"].splitlines():
        if line.startswith("kernel.") and not line.startswith("kernel.src"):
            package = line.strip().split()
            kernels.append(dict(version=package[1], repo=package[2]))

    for kernel in reversed(kernels):
        if kernel["version"].startswith(kernel_version):
            return kernel

    raise RuntimeError(
        'No kernel matching to "%s". Available kernel versions: %s'
        % (kernel_version, ", ".join(kernel["version"] for kernel in kernels))
    )