Bootstrap an image using the yum tools

    root
        The root of the image to install to. Will be created as a directory if
        it does not exist. (e.x.: /root/arch)

    pkg_confs
        The location of the conf files to copy into the image, to point yum
        to the right repos and configuration.

    pkgs
        A list of packages to be installed on this image. For RedHat, this
        will include ``yum``, ``centos-release`` and ``iputils`` by default.

    exclude_pkgs
        A list of packages to be excluded. If you do not want to install the
        defaults, you need to include them in this list.

    epel_url
        The URL to download the EPEL release package from.

    TODO: Set up a pre-install overlay, to copy files into /etc/ and so on,
        which are required for the install to work.

def _bootstrap_yum(
        root,
        pkg_confs='/etc/yum*',
        pkgs=None,
        exclude_pkgs=None,
        epel_url=EPEL_URL,
    ):
    '''
    Bootstrap an image using the yum tools

    root
        The root of the image to install to. Will be created as a directory if
        it does not exist. (e.x.: /root/arch)

    pkg_confs
        The location of the conf files to copy into the image, to point yum
        to the right repos and configuration.

    pkgs
        A list of packages to be installed on this image. For RedHat, this
        will include ``yum``, ``centos-release`` and ``iputils`` by default.

    exclude_pkgs
        A list of packages to be excluded. If you do not want to install the
        defaults, you need to include them in this list.

    epel_url
        The URL to download the EPEL release package from.

    TODO: Set up a pre-install overlay, to copy files into /etc/ and so on,
        which are required for the install to work.
    '''
    if pkgs is None:
        pkgs = []
    elif isinstance(pkgs, six.string_types):
        pkgs = pkgs.split(',')

    default_pkgs = ('yum', 'centos-release', 'iputils')
    for pkg in default_pkgs:
        if pkg not in pkgs:
            pkgs.append(pkg)

    if exclude_pkgs is None:
        exclude_pkgs = []
    elif isinstance(exclude_pkgs, six.string_types):
        exclude_pkgs = exclude_pkgs.split(',')

    for pkg in exclude_pkgs:
        pkgs.remove(pkg)

    _make_nodes(root)
    release_files = [rf for rf in os.listdir('/etc') if rf.endswith('release')]
    __salt__['cmd.run']('cp /etc/resolv/conf {rfs} {root}/etc'.format(root=_cmd_quote(root), rfs=' '.join(release_files)))
    __salt__['cmd.run']('cp -r {rfs} {root}/etc'.format(root=_cmd_quote(root), rfs=' '.join(release_files)))
    __salt__['cmd.run']('cp -r {confs} {root}/etc'.format(root=_cmd_quote(root), confs=_cmd_quote(pkg_confs)))

    yum_args = ['yum', 'install', '--installroot={0}'.format(_cmd_quote(root)), '-y'] + pkgs
    __salt__['cmd.run'](yum_args, python_shell=False)

    if 'epel-release' not in exclude_pkgs:
        __salt__['cmd.run'](
            ('rpm', '--root={0}'.format(_cmd_quote(root)), '-Uvh', epel_url),
            python_shell=False
        )