Class: Kafo::PuppetCommand
- Inherits:
-
Object
- Object
- Kafo::PuppetCommand
- Defined in:
- lib/kafo/puppet_command.rb
Class Method Summary collapse
Instance Method Summary collapse
- #append(suffix) ⇒ Object
- #command ⇒ Object
-
#initialize(command, options = [], puppet_config = nil, configuration = KafoConfigure.config) ⇒ PuppetCommand
constructor
A new instance of PuppetCommand.
Constructor Details
#initialize(command, options = [], puppet_config = nil, configuration = KafoConfigure.config) ⇒ PuppetCommand
Returns a new instance of PuppetCommand.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/kafo/puppet_command.rb', line 4 def initialize(command, = [], puppet_config = nil, configuration = KafoConfigure.config) @configuration = configuration @command = command @puppet_config = puppet_config if puppet_config puppet_config['basemodulepath'] = modules_path.join(':') @options = .push("--config=#{puppet_config.config_path}") else @options = .push("--modulepath #{modules_path.join(':')}") end @logger = KafoConfigure.logger @puppet_version_check = !configuration.app[:skip_puppet_version_check] @suffix = nil end |
Class Method Details
.search_puppet_path(bin_name) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/kafo/puppet_command.rb', line 37 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
#append(suffix) ⇒ Object
32 33 34 35 |
# File 'lib/kafo/puppet_command.rb', line 32 def append(suffix) @suffix = suffix self end |
#command ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/kafo/puppet_command.rb', line 20 def command @puppet_config.write_config if @puppet_config result = [ manifest, '|', "RUBYLIB=#{[@configuration.kafo_modules_dir, ::ENV['RUBYLIB']].join(File::PATH_SEPARATOR)}", "#{puppet_path} apply #{@options.join(' ')} #{@suffix}", ].join(' ') @logger.debug result result end |