class Kafo::PuppetCommand

Public Class Methods

new(command, options = [], configuration = KafoConfigure.config) click to toggle source
# File lib/kafo/puppet_command.rb, line 3
def initialize(command, options = [], configuration = KafoConfigure.config)
  @configuration = configuration
  @command = command

  # Expand the modules_path to work around the fact that Puppet doesn't
  # allow modulepath to contain relative (i.e ..) directory references as
  # of 2.7.23.
  @options = options.push("--modulepath #{File.expand_path(modules_path)}")
  @logger  = KafoConfigure.logger
end

Public Instance Methods

add_progress() click to toggle source
# File lib/kafo/puppet_command.rb, line 18
def add_progress
  KafoConfigure.verbose ? '' : "$kafo_add_progress=true"
end
append(suffix) click to toggle source
# File lib/kafo/puppet_command.rb, line 33
def append(suffix)
  @suffix = suffix
  self
end
command() click to toggle source
# File lib/kafo/puppet_command.rb, line 22
def command
  result = [
      "echo '$kafo_config_file=\"#{@configuration.config_file}\" #{custom_answer_file} #{add_progress} #{@command}'",
      '|',
      "RUBYLIB=#{["#{@configuration.gem_root}/modules", ::ENV['RUBYLIB']].join(File::PATH_SEPARATOR)}",
      "puppet apply #{@options.join(' ')} #{@suffix}",
  ].join(' ')
  @logger.debug result
  result
end
custom_answer_file() click to toggle source
# File lib/kafo/puppet_command.rb, line 14
def custom_answer_file
  KafoConfigure.temp_config_file.nil? ? '' : "$kafo_answer_file=\"#{KafoConfigure.temp_config_file}\""
end

Private Instance Methods

modules_path() click to toggle source
# File lib/kafo/puppet_command.rb, line 40
def modules_path
  [
      @configuration.module_dirs,
      @configuration.kafo_modules_dir,
  ].flatten.join(':')
end