def yum_install(packages, downloadonly=False, dest_dir='/tmp'):
    """Installs (or downloads) a list of packages from yum

    This public method installs a list of packages from yum or
    downloads the packages to the specified destination directory using
    the yum-downloadonly yum plugin.

    :param downloadonly: Boolean, set to only download the package and
        not install it
    :param packages: List of package names (str) to download param
    :param dest_dir: (str) Full path to the download directory
    :return: int exit code from the yum command
    :raises CommandError
    """
    log = logging.getLogger(mod_logger + '.yum_install')

    # Type checks on the args
    if not isinstance(dest_dir, basestring):
        msg = 'dest_dir argument must be a string'
        log.error(msg)
        raise CommandError(msg)
    if not isinstance(packages, list):
        msg = 'packages argument must be a list'
        log.error(msg)
        raise CommandError(msg)
    if not isinstance(downloadonly, bool):
        msg = 'downloadonly argument must be a bool'
        log.error(msg)
        raise CommandError(msg)
    if not packages:
        msg = 'Empty list of packages provided'
        log.error(msg)
        raise CommandError(msg)
    for package in packages:
        # Ensure the package is specified as a string
        if not isinstance(package, basestring):
            msg = 'One of the packages was not specified as a string'
            log.error(msg)
            raise CommandError(msg)

    # Build the yum install command string
    command = ['yum', '-y', 'install'] + packages

    # If downloadonly was True, download packages to dest_dir
    if downloadonly:
        log.info('yum downloadonly was specified, adding additional options...')

        # Append downloadonly args to the command
        command += ['--downloadonly', '--downloaddir={d}'.format(d=dest_dir)]

        # Create the destination directory if it does not exist
        log.info('Creating directory: %s', dest_dir)
        try:
            mkdir_p(dest_dir)
        except CommandError:
            _, ex, trace = sys.exc_info()
            msg = 'Unable to create destination directory: {d}'.format(d=dest_dir)
            log.error(msg)
            raise CommandError, msg, trace
        log.info('Downloading packages from yum to %s...', dest_dir)
    else:
        log.info('Installing yum packages from RHN...')

    # Run the yum install command
    try:
        result = run_command(command)
    except CommandError:
        raise
    log.info('Yum update completed and exit with code: {c}'.format(
        c=result['code']))
    return result['code']