def bootstrap_salt(name,
                   config=None,
                   approve_key=True,
                   install=True,
                   pub_key=None,
                   priv_key=None,
                   bootstrap_url=None,
                   force_install=False,
                   unconditional_install=False,
                   bootstrap_delay=None,
                   bootstrap_args=None,
                   bootstrap_shell=None):
    '''
    Bootstrap a container from package servers, if dist is None the os the
    minion is running as will be created, otherwise the needed bootstrapping
    tools will need to be available on the host.

    CLI Example::

        salt '*' nspawn.bootstrap_salt arch1
    '''
    if bootstrap_delay is not None:
        try:
            time.sleep(bootstrap_delay)
        except __HOLE__:
            # Bad input, but assume since a value was passed that
            # a delay was desired, and sleep for 5 seconds
            time.sleep(5)

    c_info = info(name)
    if not c_info:
        return None

    # default set here as we cannot set them
    # in def as it can come from a chain of procedures.
    if bootstrap_args:
        # custom bootstrap args can be totally customized, and user could
        # have inserted the placeholder for the config directory.
        # For example, some salt bootstrap script do not use at all -c
        if '{0}' not in bootstrap_args:
            bootstrap_args += ' -c {0}'
    else:
        bootstrap_args = '-c {0}'
    if not bootstrap_shell:
        bootstrap_shell = 'sh'

    orig_state = _ensure_running(name)
    if not orig_state:
        return orig_state
    if not force_install:
        needs_install = _needs_install(name)
    else:
        needs_install = True
    seeded = retcode(name, 'test -e \'{0}\''.format(SEED_MARKER)) == 0
    tmp = tempfile.mkdtemp()
    if seeded and not unconditional_install:
        ret = True
    else:
        ret = False
        cfg_files = __salt__['seed.mkconfig'](
            config, tmp=tmp, id_=name, approve_key=approve_key,
            pub_key=pub_key, priv_key=priv_key)
        if needs_install or force_install or unconditional_install:
            if install:
                rstr = __salt__['test.rand_str']()
                configdir = '/tmp/.c_{0}'.format(rstr)
                run(name,
                    'install -m 0700 -d {0}'.format(configdir),
                    python_shell=False)
                bs_ = __salt__['config.gather_bootstrap_script'](
                    bootstrap=bootstrap_url)
                dest_dir = os.path.join('/tmp', rstr)
                for cmd in [
                    'mkdir -p {0}'.format(dest_dir),
                    'chmod 700 {0}'.format(dest_dir),
                ]:
                    if run_stdout(name, cmd):
                        log.error(
                            ('tmpdir {0} creation'
                             ' failed ({1}').format(dest_dir, cmd))
                        return False
                copy_to(name,
                   bs_,
                   '{0}/bootstrap.sh'.format(dest_dir),
                   makedirs=True)
                copy_to(name, cfg_files['config'],
                   os.path.join(configdir, 'minion'))
                copy_to(name, cfg_files['privkey'],
                   os.path.join(configdir, 'minion.pem'))
                copy_to(name, cfg_files['pubkey'],
                   os.path.join(configdir, 'minion.pub'))
                bootstrap_args = bootstrap_args.format(configdir)
                cmd = ('{0} {2}/bootstrap.sh {1}'
                       .format(bootstrap_shell,
                               bootstrap_args.replace("'", "''"),
                               dest_dir))
                # log ASAP the forged bootstrap command which can be wrapped
                # out of the output in case of unexpected problem
                log.info('Running {0} in LXC container \'{1}\''
                         .format(cmd, name))
                ret = retcode(name, cmd, output_loglevel='info',
                                  use_vt=True) == 0
            else:
                ret = False
        else:
            minion_config = salt.config.minion_config(cfg_files['config'])
            pki_dir = minion_config['pki_dir']
            copy_to(name, cfg_files['config'], '/etc/salt/minion')
            copy_to(name, cfg_files['privkey'], os.path.join(pki_dir, 'minion.pem'))
            copy_to(name, cfg_files['pubkey'], os.path.join(pki_dir, 'minion.pub'))
            run(name,
                'salt-call --local service.enable salt-minion',
                python_shell=False)
            ret = True
        shutil.rmtree(tmp)
        if orig_state == 'stopped':
            stop(name)
        # mark seeded upon successful install
        if ret:
            run(name,
                    'touch \'{0}\''.format(SEED_MARKER),
                    python_shell=False)
    return ret
dataset/ETHPy150Open saltstack/salt/salt/modules/nspawn.py/bootstrap_salt