def bootstrap(name,
              config=None,
              approve_key=True,
              install=True,
              pub_key=None,
              priv_key=None,
              bootstrap_url=None,
              force_install=False,
              unconditional_install=False,
              path=None,
              bootstrap_delay=None,
              bootstrap_args=None,
              bootstrap_shell=None):
    '''
    Install and configure salt in a container.

    config
        Minion configuration options. By default, the ``master`` option is set
        to the target host's master.

    approve_key
        Request a pre-approval of the generated minion key. Requires
        that the salt-master be configured to either auto-accept all keys or
        expect a signing request from the target host. Default: ``True``

    path
        path to the container parent
        default: /var/lib/lxc (system default)

        .. versionadded:: 2015.8.0

    pub_key
        Explicit public key to pressed the minion with (optional).
        This can be either a filepath or a string representing the key

    priv_key
        Explicit private key to pressed the minion with (optional).
        This can be either a filepath or a string representing the key

    bootstrap_delay
        Delay in seconds between end of container creation and bootstrapping.
        Useful when waiting for container to obtain a DHCP lease.

        .. versionadded:: 2015.5.0

    bootstrap_url
        url, content or filepath to the salt bootstrap script

    bootstrap_args
        salt bootstrap script arguments

    bootstrap_shell
        shell to execute the script into

    install
        Whether to attempt a full installation of salt-minion if needed.

    force_install
        Force installation even if salt-minion is detected,
        this is the way to run vendor bootstrap scripts even
        if a salt minion is already present in the container

    unconditional_install
        Run the script even if the container seems seeded

    CLI Examples:

    .. code-block:: bash

        salt 'minion' lxc.bootstrap container_name [config=config_data] \\
                [approve_key=(True|False)] [install=(True|False)]

    '''
    wait_started(name, path=path)
    if bootstrap_delay is not None:
        try:
            log.info('LXC {0}: bootstrap_delay: {1}'.format(
                name, bootstrap_delay))
            time.sleep(bootstrap_delay)
        except TypeError:
            # 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, path=path)
    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 bootstrap_args not in '{0}':
            bootstrap_args += ' -c {0}'
    else:
        bootstrap_args = '-c {0}'
    if not bootstrap_shell:
        bootstrap_shell = 'sh'

    orig_state = _ensure_running(name, path=path)
    if not orig_state:
        return orig_state
    if not force_install:
        needs_install = _needs_install(name, path=path)
    else:
        needs_install = True
    seeded = retcode(name,
                     'test -e \'{0}\''.format(SEED_MARKER),
                     path=path,
                     chroot_fallback=True,
                     ignore_retcode=True) == 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 = '/var/tmp/.c_{0}'.format(rstr)

                cmd = 'install -m 0700 -d {0}'.format(configdir)
                if run(name, cmd, python_shell=False):
                    log.error('tmpdir {0} creation failed ({1}'
                              .format(configdir, cmd))
                    return False

                bs_ = __salt__['config.gather_bootstrap_script'](
                    bootstrap=bootstrap_url)
                script = '/sbin/{0}_bootstrap.sh'.format(rstr)
                copy_to(name, bs_, script, path=path)
                result = run_all(name,
                                 'sh -c "chmod +x {0}"'.format(script),
                                 python_shell=True)

                copy_to(name, cfg_files['config'],
                        os.path.join(configdir, 'minion'),
                        path=path)
                copy_to(name, cfg_files['privkey'],
                        os.path.join(configdir, 'minion.pem'),
                        path=path)
                copy_to(name, cfg_files['pubkey'],
                        os.path.join(configdir, 'minion.pub'),
                        path=path)
                bootstrap_args = bootstrap_args.format(configdir)
                cmd = ('{0} {2} {1}'
                       .format(bootstrap_shell,
                               bootstrap_args.replace("'", "''"),
                               script))
                # 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',
                              path=path, use_vt=True) == 0

                run_all(name,
                        'sh -c \'if [ -f "{0}" ];then rm -f "{0}";fi\''
                        ''.format(script),
                        ignore_retcode=True,
                        python_shell=True)
            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',
                    path=path)
            copy_to(name,
                    cfg_files['privkey'],
                    os.path.join(pki_dir, 'minion.pem'),
                    path=path)
            copy_to(name,
                    cfg_files['pubkey'],
                    os.path.join(pki_dir, 'minion.pub'),
                    path=path)
            run(name,
                'salt-call --local service.enable salt-minion',
                path=path,
                python_shell=False)
            ret = True
        shutil.rmtree(tmp)
        if orig_state == 'stopped':
            stop(name, path=path)
        elif orig_state == 'frozen':
            freeze(name, path=path)
        # mark seeded upon successful install
        if ret:
            run(name,
                'touch \'{0}\''.format(SEED_MARKER),
                path=path,
                python_shell=False)
    return ret
dataset/ETHPy150Open saltstack/salt/salt/modules/lxc.py/bootstrap/swapped operands of `not in`