Class: Kafo::PuppetCommand
- Inherits:
-
Object
- Object
- Kafo::PuppetCommand
- Defined in:
- lib/kafo/puppet_command.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_progress ⇒ Object
- #append(suffix) ⇒ Object
- #command ⇒ Object
- #custom_answer_file ⇒ Object
-
#initialize(command, options = [], configuration = KafoConfigure.config) ⇒ PuppetCommand
constructor
A new instance of PuppetCommand.
Constructor Details
#initialize(command, options = [], configuration = KafoConfigure.config) ⇒ PuppetCommand
Returns a new instance of PuppetCommand.
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/kafo/puppet_command.rb', line 4 def initialize(command, = [], 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 = .push("--modulepath #{File.(modules_path)}") @logger = KafoConfigure.logger end |
Class Method Details
.search_puppet_path(bin_name) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/kafo/puppet_command.rb', line 39 def self.search_puppet_path(bin_name) bin_path = (::ENV['PATH'].split(File::PATH_SEPARATOR) + ['/opt/puppetlabs/bin']).find do |path| File.executable?(File.join(path, bin_name)) end File.join([bin_path, bin_name].compact) end |
Instance Method Details
#add_progress ⇒ Object
19 20 21 |
# File 'lib/kafo/puppet_command.rb', line 19 def add_progress KafoConfigure.verbose ? '' : "$kafo_add_progress=true" end |
#append(suffix) ⇒ Object
34 35 36 37 |
# File 'lib/kafo/puppet_command.rb', line 34 def append(suffix) @suffix = suffix self end |
#command ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/kafo/puppet_command.rb', line 23 def command result = [ "echo '$kafo_config_file=\"#{@configuration.config_file}\" #{custom_answer_file} #{add_progress} #{@command}'", '|', "RUBYLIB=#{[@configuration.kafo_modules_dir, ::ENV['RUBYLIB']].join(File::PATH_SEPARATOR)}", "#{puppet_path} apply #{@options.join(' ')} #{@suffix}", ].join(' ') @logger.debug result result end |
#custom_answer_file ⇒ Object
15 16 17 |
# File 'lib/kafo/puppet_command.rb', line 15 def custom_answer_file KafoConfigure.temp_config_file.nil? ? '' : "$kafo_answer_file=\"#{KafoConfigure.temp_config_file}\"" end |