Class: Puppet::ModuleTool::Applications::Installer

Inherits:
Application show all
Includes:
Errors, Shared
Defined in:
lib/vendor/puppet/module_tool/applications/installer.rb

Constant Summary

Constants inherited from Application

Application::DOCPATTERN

Constants included from Util

Util::AbsolutePathPosix, Util::AbsolutePathWindows

Instance Attribute Summary

Attributes inherited from Application

#command_line, #options

Instance Method Summary collapse

Methods included from Shared

#annotated_version, #download_tarballs, #get_local_constraints, #get_remote_constraints, #implicit_version, #resolve_constraints

Methods inherited from Application

[], banner, clear!, clear?, #configure_indirector_routes, controlled_run, exit, find, #handlearg, #help, interrupted?, #main, #name, option, option_parser_commands, #parse_options, #preinit, restart!, restart_requested?, #run_command, run_mode, #set_run_mode, #setup, #setup_logs, should_not_parse_config, should_parse_config, #should_parse_config?, should_parse_config?, stop!, stop_requested?

Methods included from Util

absolute_path?, activerecord_version, benchmark, binread, chuser, classproxy, #execfail, #execpipe, execute, execute_posix, execute_windows, logmethods, memory, path_to_uri, proxy, replace_file, safe_posix_fork, symbolize, symbolizehash, symbolizehash!, synchronize_on, thinmark, #threadlock, uri_to_path, wait_for_output, which, withumask

Methods included from Util::POSIX

#get_posix_field, #gid, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid

Constructor Details

#initialize(name, options = {}) ⇒ Installer

Returns a new instance of Installer.



15
16
17
18
19
20
21
22
# File 'lib/vendor/puppet/module_tool/applications/installer.rb', line 15

def initialize(name, options = {})
  @action              = :install
  @environment         = Puppet::Node::Environment.new(Puppet.settings[:environment])
  @force               = options[:force]
  @ignore_dependencies = options[:force] || options[:ignore_dependencies]
  @name                = name
  super(options)
end

Instance Method Details

#runObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/vendor/puppet/module_tool/applications/installer.rb', line 24

def run
  begin
    if is_module_package?(@name)
      @source = :filesystem
      @filename = File.expand_path(@name)
      raise MissingPackageError, :requested_package => @filename unless File.exist?(@filename)

      parsed = parse_filename(@filename)
      @module_name = parsed[:module_name]
      @version     = parsed[:version]
    else
      @source = :repository
      @module_name = @name.gsub('/', '-')
      @version = options[:version]
    end

    results = {
      :module_name    => @module_name,
      :module_version => @version,
      :install_dir    => options[:target_dir],
    }

    unless File.directory? options[:target_dir]
      raise MissingInstallDirectoryError,
        :requested_module  => @module_name,
        :requested_version => @version || 'latest',
        :directory         => options[:target_dir]
    end

    cached_paths = get_release_packages

    unless @graph.empty?
      Puppet.notice 'Installing -- do not interrupt ...'
      cached_paths.each do |hash|
        hash.each do |dir, path|
          Unpacker.new(path, @options.merge(:target_dir => dir)).run
        end
      end
    end
  rescue ModuleToolError => err
    results[:error] = {
      :oneline   => err.message,
      :multiline => err.multiline,
    }
  else
    results[:result] = :success
    results[:installed_modules] = @graph
  ensure
    results[:result] ||= :failure
  end

  results
end