Module: CemAcpt::PuppetHelpers::Module

Extended by:
Logging
Defined in:
lib/cem_acpt/puppet_helpers.rb

Overview

Provides helper methods for Puppet Modules.

Constant Summary

Constants included from Logging

Logging::LEVEL_MAP

Class Method Summary collapse

Methods included from Logging

current_log_config, current_log_config, current_log_format, current_log_format, current_log_level, current_log_level, included, logger, logger, new_log_config, new_log_config, new_log_formatter, new_log_formatter, new_log_level, new_log_level, new_logger, new_logger, verbose?, verbose?

Class Method Details

.build_module_package(module_dir, target_dir = nil, should_log: false) ⇒ String

Builds a Puppet module package.

Parameters:

  • module_dir (String)

    Path to the module directory. If target_dir is specified as a relative path, it will be relative to the module dir.

  • target_dir (String) (defaults to: nil)

    Path to the target directory where the package will be built. This defaults to the relative path ‘pkg/’.

  • should_log (Boolean) (defaults to: false)

    Whether or not to log the build process.

Returns:

  • (String)

    Path to the built package.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/cem_acpt/puppet_helpers.rb', line 22

def self.build_module_package(module_dir, target_dir = nil, should_log: false)
  require 'puppet/modulebuilder'
  require 'fileutils'

  builder_logger = should_log ? logger : nil
  builder = Puppet::Modulebuilder::Builder.new(File.expand_path(module_dir), target_dir, builder_logger)

  # Validates module metadata by raising exception if invalid
   = builder.

  # Builds the module package
  logger.info('CemAcpt::PuppetHelpers') { "Building module package for #{builder.release_name}" }
  builder.build
end