Class: PuppetCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/kafo/puppet_command.rb

Instance Method Summary collapse

Constructor Details

#initialize(command, options = []) ⇒ PuppetCommand

Returns a new instance of PuppetCommand.



3
4
5
6
7
# File 'lib/kafo/puppet_command.rb', line 3

def initialize(command, options = [])
  @command = command
  @options = options.push("--modulepath #{modules_path}")
  @logger  = Logging.logger.root
end

Instance Method Details

#append(suffix) ⇒ Object



25
26
27
28
# File 'lib/kafo/puppet_command.rb', line 25

def append(suffix)
  @suffix = suffix
  self
end

#commandObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/kafo/puppet_command.rb', line 9

def command
  custom_answer_file = if KafoConfigure.temp_config_file.nil?
    ''
  else
    "$kafo_answer_file=\"#{KafoConfigure.temp_config_file}\""
  end

  result = [
      "echo '$kafo_config_file=\"#{KafoConfigure.config_file}\" #{custom_answer_file} #{@command}'",
      " | ",
      "puppet apply #{@options.join(' ')} #{@suffix}"
  ].join
  @logger.debug result
  result
end