Install a Perl module from CPAN

    CLI Example:

    .. code-block:: bash

        salt '*' cpan.install Template::Alloy
541790
def install(module):
    '''
    
    '''
    ret = {
        'old': None,
        'new': None,
    }

    old_info = show(module)

    cmd = 'cpan -i {0}'.format(module)
    out = __salt__['cmd.run'](cmd)

    if "don't know what it is" in out:
        ret['error'] = 'CPAN cannot identify this package'
        return ret

    new_info = show(module)
    ret['old'] = old_info.get('installed version', None)
    ret['new'] = new_info['installed version']

    return ret
423205
def salt_cp():
    '''
    
    '''
    import salt.cli.cp
    client = salt.cli.cp.SaltCPCli()
    _install_signal_handlers(client)
    client.run()
294226
def install(self):
        
        try:
            if self.args.server is not None:
                server = ServerLists(self.server_type)
                DynamicImporter(
                    'ezhost',
                    server.name,
                    args=self.args,
                    configure=self.configure
                )
            else:
                ServerCommand(self.args)
        except Exception as e:
            raise e
354528
def generate(env):
    """"""
    path, cxx, shcxx, version = get_cppc(env)
    if path:
        cxx = os.path.join(path, cxx)
        shcxx = os.path.join(path, shcxx)

    cplusplus.generate(env)

    env['CXX'] = cxx
    env['SHCXX'] = shcxx
    env['CXXVERSION'] = version
    env['SHCXXFLAGS']   = SCons.Util.CLVar('$CXXFLAGS -KPIC')
    env['SHOBJPREFIX']  = 'so_'
    env['SHOBJSUFFIX']  = '.o'
288702
def get_template(path,
                 dest,
                 template='jinja',
                 saltenv='base',
                 makedirs=False,
                 **kwargs):
    '''
    
    '''
    if 'salt' not in kwargs:
        kwargs['salt'] = __salt__
    if 'pillar' not in kwargs:
        kwargs['pillar'] = __pillar__
    if 'grains' not in kwargs:
        kwargs['grains'] = __grains__
    if 'opts' not in kwargs:
        kwargs['opts'] = __opts__
    return _client().get_template(
            path,
            dest,
            template,
            makedirs,
            saltenv,
            **kwargs)
1067147
def bind(self, alloy):
        '''
        
        '''
        param = MethodParameter(self.name, self.method, self.dependencies,
                                self.units, self.aliases, self._references)
        param.alloy = alloy
        return param
602578
def setup(self, app):
        
        super().setup(app)

        if isinstance(self.cfg.template_folders, str):
            self.cfg.template_folders = [self.cfg.template_folders]

        self.cfg.template_folders = list(self.cfg.template_folders)
        if not self.cfg.loader:
            self.cfg.loader = FileSystemLoader(
                self.cfg.template_folders, encoding=self.cfg.encoding)

        self.env = jinja2.Environment(
            auto_reload=self.cfg.auto_reload,
            cache_size=self.cfg.cache_size,
            extensions=self.cfg.extensions,
            loader=self.cfg.loader,
        )
        self.env.globals['app'] = app

        @self.register
        @jinja2.contextfunction
        def debug(ctx, value=None):
            """ Debug current context to template. """
            return jinja2.filters.do_pprint(value is None and ctx or value)

        @self.filter
        def jsonify(obj):
            return dumps(obj, ensure_ascii=False, encode_html_chars=True)
951986
def prepare(self):
        '''
        
        '''
        super(Syndic, self).prepare()
        try:
            if self.config['verify_env']:
                verify_env(
                    [
                        self.config['pki_dir'],
                        self.config['cachedir'],
                        self.config['sock_dir'],
                        self.config['extension_modules'],
                    ],
                    self.config['user'],
                    permissive=self.config['permissive_pki_access'],
                    root_dir=self.config['root_dir'],
                    pki_dir=self.config['pki_dir'],
                )
        except OSError as error:
            self.environment_failure(error)

        self.setup_logfile_logger()
        verify_log(self.config)
        self.action_log_info('Setting up "{0}"'.format(self.config['id']))

        # Late import so logging works correctly
        import salt.minion
        self.daemonize_if_required()
        self.syndic = salt.minion.SyndicManager(self.config)
        self.set_pidfile()
1361786
def install_npm_modules():
    """"""
    # This is a little weird, but we do it this way because if you
    # have package.json, then heroku thinks this might be a node.js
    # app.
    call_command('cp node.json package.json', verbose=True)
    call_command('npm install', verbose=True)
    call_command('rm package.json', verbose=True)
686832
def setup
      Dir.chdir(build_dir) do
        distribution.templates.each do |template|
          template.install(config.sesame)
        end
      end
    end
240194
public static function install_site() {
        global $DB, $CFG;
        require_once($CFG->dirroot.'/user/lib.php');
        if (!defined('BEHAT_UTIL')) {
            throw new coding_exception('This method can be only used by Behat CLI tool');
        }

        $tables = $DB->get_tables(false);
        if (!empty($tables)) {
            behat_error(BEHAT_EXITCODE_INSTALLED);
        }

        // New dataroot.
        self::reset_dataroot();

        $options = array();
        $options['adminuser'] = 'admin';
        $options['adminpass'] = 'admin';
        $options['fullname'] = self::BEHATSITENAME;
        $options['shortname'] = self::BEHATSITENAME;

        install_cli_database($options, false);

        // We need to keep the installed dataroot filedir files.
        // So each time we reset the dataroot before running a test, the default files are still installed.
        self::save_original_data_files();

        $frontpagesummary = new admin_setting_special_frontpagedesc();
        $frontpagesummary->write_setting(self::BEHATSITENAME);

        // Update admin user info.
        $user = $DB->get_record('user', array('username' => 'admin'));
        $user->email = 'moodle@example.com';
        $user->firstname = 'Admin';
        $user->lastname = 'User';
        $user->city = 'Perth';
        $user->country = 'AU';
        user_update_user($user, false);

        // Disable email message processor.
        $DB->set_field('message_processors', 'enabled', '0', array('name' => 'email'));

        // Sets maximum debug level.
        set_config('debug', DEBUG_DEVELOPER);
        set_config('debugdisplay', 1);

        // Disable some settings that are not wanted on test sites.
        set_config('noemailever', 1);

        // Enable web cron.
        set_config('cronclionly', 0);

        // Set editor autosave to high value, so as to avoid unwanted ajax.
        set_config('autosavefrequency', '604800', 'editor_atto');

        // Set noreplyaddress to an example domain, as it should be valid email address and test site can be a localhost.
        set_config('noreplyaddress', 'noreply@example.com');

        // Keeps the current version of database and dataroot.
        self::store_versions_hash();

        // Stores the database contents for fast reset.
        self::store_database_state();
    }
768327
def install_semod(module_path):
    '''
    
    '''
    if module_path.find('salt://') == 0:
        module_path = __salt__['cp.cache_file'](module_path)
    cmd = 'semodule -i {0}'.format(module_path)
    return not __salt__['cmd.retcode'](cmd)
800270
def __read_and_render_yaml_file(source,
                                template,
                                saltenv):
    '''
    
    '''
    sfn = __salt__['cp.cache_file'](source, saltenv)
    if not sfn:
        raise CommandExecutionError(
            'Source file \'{0}\' not found'.format(source))

    with salt.utils.files.fopen(sfn, 'r') as src:
        contents = src.read()

        if template:
            if template in salt.utils.templates.TEMPLATE_REGISTRY:
                # TODO: should we allow user to set also `context` like  # pylint: disable=fixme
                # `file.managed` does?
                # Apply templating
                data = salt.utils.templates.TEMPLATE_REGISTRY[template](
                    contents,
                    from_str=True,
                    to_str=True,
                    saltenv=saltenv,
                    grains=__grains__,
                    pillar=__pillar__,
                    salt=__salt__,
                    opts=__opts__)

                if not data['result']:
                    # Failed to render the template
                    raise CommandExecutionError(
                        'Failed to render file path with error: '
                        '{0}'.format(data['data'])
                    )

                contents = data['data'].encode('utf-8')
            else:
                raise CommandExecutionError(
                    'Unknown template specified: {0}'.format(
                        template))

        return salt.utils.yaml.safe_load(contents)
642865
function installModule (module, modulesDir, callback) {

    let details = module.split('/');
    let devModulePath = resolve(modulesDir, module);

    fs.access(resolve(modulesDir, module), err => {

        // skip next steps if module already exists
        if (!err || err.code !== 'ENOENT') {
            return callback();
        }

        exec('git clone git@github.com:' + details[0] + '/' + details[1] + '.git ' + devModulePath, err => {

            if (err) {
                return callback(err);
            }

            exec('cd ' + devModulePath + '; npm i', err => {

                if (err) {
                    return callback(err);
                }

                // create a symlink to the babelify presets
                // it is required in order for babelify to work
                fs.symlink(resolve(__dirname, '../../', 'babel-preset-es2015'), resolve(devModulePath, 'node_modules/babel-preset-es2015'), err => {

                    if (err) {
                        return callback(err);
                    }

                    callback();
                });
            });
        });
    });
}
36133
def in_bolt_compiler
      r = Puppet::Pal.in_tmp_environment('bolt', modulepath: @modulepath, facts: {}) do |pal|
        pal.with_script_compiler do |compiler|
          alias_types(compiler)
          begin
            Puppet.override(yaml_plan_instantiator: Bolt::PAL::YamlPlan::Loader) do
              yield compiler
            end
          rescue Bolt::Error => e
            e
          rescue Puppet::PreformattedError => e
            PALError.from_preformatted_error(e)
          rescue StandardError => e
            PALError.from_preformatted_error(e)
          end
        end
      end

      # Plans may return PuppetError but nothing should be throwing them
      if r.is_a?(StandardError) && !r.is_a?(Bolt::PuppetError)
        raise r
      end
      r
    end
747970
def generic_insert_module(module_name, args, **kwargs):
    
    file = create_or_open(
        '{}.py'.format(module_name), 
        os.path.join(
            BASE_TEMPLATES_DIR, 
            '{}_initial.py.tmpl'.format(module_name)
        ), 
        args
    )
        
    render_template_with_args_in_file(
        file, 
        os.path.join(
            BASE_TEMPLATES_DIR, 
            '{}.py.tmpl'.format(module_name)
        ), 
        **kwargs
        )
    file.close()
160283
def install(manifest = 'manifest.yml')
      unless File.exist? manifest
        logger.fatal { "Manifest file '#{manifest}' does not exist." }
        return false
      end

      collection.load_manifest manifest
      result = options[:dryrun] ? collection.install? : collection.install

      msg = install_message(result, options[:dryrun])
      result ? logger.info(msg) : logger.error(msg)
      result
    end