class PuppetModule::Pkg::Tasks::Install

Public Class Methods

new(system) click to toggle source
# File lib/puppet_module/pkg/tasks/install.rb, line 5
def initialize(system)
  @sys = system
end

Public Instance Methods

invoke(mod, opts) click to toggle source
# File lib/puppet_module/pkg/tasks/install.rb, line 9
def invoke(mod, opts)
  @mod = mod
  @out_dir = opts.install_dir

  @sys.mkdir install_path
  @sys.cp assets_to_install, install_path

  install_deps if opts.recursive
end

Private Instance Methods

assets_to_install() click to toggle source
# File lib/puppet_module/pkg/tasks/install.rb, line 29
def assets_to_install
  ['Modulefile','manifests','templates','lib','files']
end
dest_path() click to toggle source
# File lib/puppet_module/pkg/tasks/install.rb, line 25
def dest_path
  '/usr/share/puppet/modules'
end
install_deps() click to toggle source
# File lib/puppet_module/pkg/tasks/install.rb, line 33
def install_deps
  # TODO: Refactor!!! Too many hardcoded paths
  @mod.dependencies.each do |dep|
    @sys.sh("puppet module install -i tmp/deps_inst -v '#{dep[:versions].join(' ')}' #{dep[:author]}/#{dep[:name]}")
  end

  @sys.ls('tmp/deps_inst').each do |dep|
    @sys.mkdir "tmp/deps_build/#{dep}#{dest_path}/#{dep}"
    @sys.cp assets_to_install.map { |a| "tmp/deps_inst/#{dep}/#{a}" },
      "tmp/deps_build/#{dep}#{dest_path}/#{dep}"
  end
end
install_path() click to toggle source
# File lib/puppet_module/pkg/tasks/install.rb, line 21
def install_path
  File.join(@out_dir, dest_path, @mod.name)
end