lib/bolt/module_installer.rb
# Adds a single module to the project.
#
Adds a single module to the project.
Adds a single module to the project .
def add(name, specs, puppetfile_path, moduledir, project_file, config)
      project_specs = Specs.new(specs)
      if project_specs.include?(name)
        @outputter.print_message(
          "Project configuration file #{project_file} already includes specification "\
          "with name #{name}. Nothing to do."
        )
        return true
      end
      @outputter.print_message("Adding module #{name} to project\n\n")
      resolve_specs = if puppetfile_path.exist?
                        existing_puppetfile = Puppetfile.parse(puppetfile_path)
                        existing_puppetfile.assert_satisfies(project_specs)
                        Specs.from_puppetfile(existing_puppetfile)
                      else
                        project_specs
                      end
      @outputter.print_action_step("Resolving module dependencies, this might take a moment")
      @outputter.start_spin
      begin
        resolve_specs.add_specs('name' => name)
        puppetfile = Resolver.new.resolve(resolve_specs, config)
      rescue Bolt::Error
        project_specs.add_specs('name' => name)
        puppetfile = Resolver.new.resolve(project_specs, config)
      end
      @outputter.stop_spin
      print_puppetfile_diff(existing_puppetfile, puppetfile)
      @outputter.print_action_step("Updating project configuration file at #{project_file}")
      data = Bolt::Util.read_yaml_hash(project_file, 'project')
      data['modules'] ||= []
      data['modules'] << name.tr('-', '/')
      begin
        File.write(project_file, data.to_yaml)
      rescue SystemCallError => e
        raise Bolt::FileError.new(
          "Unable to update project configuration file: #{e.message}",
          project_file
        )
      end
      @outputter.print_action_step("Writing Puppetfile at #{puppetfile_path}")
      puppetfile.write(puppetfile_path, moduledir)
      install_puppetfile(puppetfile_path, moduledir, config)
    end
def add ( name , specs , puppetfile_path , moduledir , project_file , config ) project_specs = Specs . new ( specs ) if project_specs . include? ( name ) @outputter . print_message ( "Project configuration file #{project_file} already includes specification " "with name #{name}. Nothing to do." ) return true end @outputter . print_message ( "Adding module #{name} to project\n\n" ) resolve_specs = if puppetfile_path . exist? existing_puppetfile = Puppetfile . parse ( puppetfile_path ) existing_puppetfile . assert_satisfies ( project_specs ) Specs . from_puppetfile ( existing_puppetfile ) else project_specs end @outputter . print_action_step ( "Resolving module dependencies, this might take a moment" ) @outputter . start_spin begin resolve_specs . add_specs ( 'name' => name ) puppetfile = Resolver . new . resolve ( resolve_specs , config ) rescue Bolt :: Error project_specs . add_specs ( 'name' => name ) puppetfile = Resolver . new . resolve ( project_specs , config ) end @outputter . stop_spin print_puppetfile_diff ( existing_puppetfile , puppetfile ) @outputter . print_action_step ( "Updating project configuration file at #{project_file}" ) data = Bolt :: Util . read_yaml_hash ( project_file , 'project' ) data [ 'modules' ] ||= [ ] data [ 'modules' ] << name . tr ( '-' , '/' ) begin File . write ( project_file , data . to_yaml ) rescue SystemCallError => e raise Bolt :: FileError . new ( "Unable to update project configuration file: #{e.message}" , project_file ) end @outputter . print_action_step ( "Writing Puppetfile at #{puppetfile_path}" ) puppetfile . write ( puppetfile_path , moduledir ) install_puppetfile ( puppetfile_path , moduledir , config ) end
Adds a single module to the project.
Adds a single module to the project .
# Exit early if project config already includes a spec with this name. # Generate the specs to resolve from. If a Puppetfile exists, parse it and # convert the modules to specs. Otherwise, use the project specs. # Resolve module dependencies. Attempt to first resolve with resolve # specss. If that fails, fall back to resolving from project specs. # This prevents Bolt from modifying installed modules unless there is # a version conflict. # Display the diff between the existing Puppetfile and the new Puppetfile. # Add the module to the project configuration. # Write the Puppetfile. # Install the modules.
name
<not_specific>
specs
<not_specific>
puppetfile_path
<not_specific>
moduledir
<not_specific>
project_file
<not_specific>
config
<not_specific>