Module: BeakerPuppetHelpers::ModuleUtils

Defined in:
lib/beaker_puppet_helpers/module_utils.rb

Overview

Methods to help install puppet modules

Instance Method Summary collapse

Instance Method Details

#install_local_module_on(hosts, source = '.') ⇒ Object

Install local module for acceptance testing

This uses puppet-modulebuilder to build the module located at source and then copies it to the hosts. There it runs puppet module install.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/beaker_puppet_helpers/module_utils.rb', line 41

def install_local_module_on(hosts, source = '.')
  builder = Puppet::Modulebuilder::Builder.new(File.realpath(source))
  source_path = builder.build
  begin
    block_on hosts do |host|
      target_file = host.tmpfile('puppet_module')
      begin
        host.do_scp_to(source_path, target_file, {})
        install_puppet_module_via_pmt_on(host, target_file)
      ensure
        host.rm_rf(target_file)
      end
    end
  ensure
    File.unlink(source_path) if source_path
  end
end

#install_puppet_module_via_pmt_on(hosts, module_name, version = nil, module_repository = nil) ⇒ Object

Install the desired module with the PMT on a given host



20
21
22
23
24
25
26
27
28
29
# File 'lib/beaker_puppet_helpers/module_utils.rb', line 20

def install_puppet_module_via_pmt_on(hosts, module_name, version = nil, module_repository = nil)
  block_on hosts do |host|
    puppet_opts = {}
    puppet_opts.merge!(host[:default_module_install_opts]) if host[:default_module_install_opts]
    puppet_opts[:version] = version if version
    puppet_opts[:module_repository] = module_repository if module_repository

    on host, Beaker::PuppetCommand.new('module', ['install', module_name], puppet_opts)
  end
end