kafo 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/bin/kafo-export-params +6 -3
- data/lib/kafo/configuration.rb +8 -4
- data/lib/kafo/data_type.rb +10 -1
- data/lib/kafo/help_builders/basic.rb +5 -1
- data/lib/kafo/kafo_configure.rb +22 -11
- data/lib/kafo/param.rb +51 -26
- data/lib/kafo/param_builder.rb +5 -5
- data/lib/kafo/params/password.rb +9 -0
- data/lib/kafo/parser_cache_reader.rb +15 -3
- data/lib/kafo/puppet_command.rb +4 -1
- data/lib/kafo/puppet_configurer.rb +37 -0
- data/lib/kafo/version.rb +1 -1
- data/lib/kafo/wizard.rb +4 -4
- metadata +5 -4
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 510b992ff3fbaf2166c54dbc84fe06c95ffa28e4
         | 
| 4 | 
            +
              data.tar.gz: 39928764fca55a2390c670cb08d68bb2c9f4ce38
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: b102ff1bfe985eee3436fbfa94323ed775828e63b8550118ea9568d7c1c51ee17006831d6af12e1cb94befc6c65d6f50eafab3c0fa54b7874d5a3f4b6f1a2da3
         | 
| 7 | 
            +
              data.tar.gz: aaf516905b8330ecffe67c40f33e9122ae3e928ed37da976891c8145b3e030b1291e330f5caaf1f073057a711141ea7bede3bbd1ca4af585f0c6e5046022c94b
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1034,7 +1034,8 @@ configure it in config/kafo.yaml with: | |
| 1034 1034 | 
             
            ```
         | 
| 1035 1035 |  | 
| 1036 1036 | 
             
            The cache will be skipped if the file modification time of the manifest is
         | 
| 1037 | 
            -
            greater than the mtime recorded in the cache.
         | 
| 1037 | 
            +
            greater than the mtime recorded in the cache. Using `--parser-cache` will force
         | 
| 1038 | 
            +
            the use of an outdated cache, but this should be used with caution.
         | 
| 1038 1039 |  | 
| 1039 1040 | 
             
            ## Configuring Hiera
         | 
| 1040 1041 |  | 
    
        data/bin/kafo-export-params
    CHANGED
    
    | @@ -31,15 +31,18 @@ module Kafo | |
| 31 31 |  | 
| 32 32 | 
             
                option ['-o', '--output'], 'FILE', 'Output file to write parameters into', :default => '-'
         | 
| 33 33 |  | 
| 34 | 
            -
                option '--[no-]parser-cache', :flag, 'Enable or disable the parser cache, disable for fresh results' | 
| 34 | 
            +
                option '--[no-]parser-cache', :flag, 'Enable or disable the parser cache, disable for fresh results'
         | 
| 35 35 |  | 
| 36 36 | 
             
                def execute
         | 
| 37 | 
            +
                  KafoConfigure.logger      = Logger.new(STDERR)
         | 
| 37 38 | 
             
                  c                         = Configuration.new(config, false)
         | 
| 38 | 
            -
                  c.app[:parser_cache_path] = nil unless parser_cache?
         | 
| 39 39 | 
             
                  KafoConfigure.config      = c
         | 
| 40 | 
            +
                  if KafoConfigure.config.parser_cache
         | 
| 41 | 
            +
                    KafoConfigure.config.parser_cache.force = true if ARGV.include?('--parser-cache')
         | 
| 42 | 
            +
                    KafoConfigure.config.parser_cache.force = false if ARGV.include?('--no-parser-cache')
         | 
| 43 | 
            +
                  end
         | 
| 40 44 | 
             
                  KafoConfigure.root_dir    = File.expand_path(c.app[:installer_dir])
         | 
| 41 45 | 
             
                  KafoConfigure.module_dirs = c.module_dirs
         | 
| 42 | 
            -
                  KafoConfigure.logger      = Logger.new(STDERR)
         | 
| 43 46 |  | 
| 44 47 | 
             
                  if output == '-'
         | 
| 45 48 | 
             
                    file = STDOUT
         | 
    
        data/lib/kafo/configuration.rb
    CHANGED
    
    | @@ -5,6 +5,7 @@ require 'kafo/puppet_module' | |
| 5 5 | 
             
            require 'kafo/password_manager'
         | 
| 6 6 | 
             
            require 'kafo/color_scheme'
         | 
| 7 7 | 
             
            require 'kafo/data_type_parser'
         | 
| 8 | 
            +
            require 'kafo/puppet_configurer'
         | 
| 8 9 |  | 
| 9 10 | 
             
            module Kafo
         | 
| 10 11 | 
             
              class Configuration
         | 
| @@ -147,8 +148,12 @@ module Kafo | |
| 147 148 | 
             
                    @logger.debug "Creating tmp dir within #{app[:default_values_dir]}..."
         | 
| 148 149 | 
             
                    temp_dir = Dir.mktmpdir(nil, app[:default_values_dir])
         | 
| 149 150 | 
             
                    KafoConfigure.exit_handler.register_cleanup_path temp_dir
         | 
| 151 | 
            +
             | 
| 152 | 
            +
                    puppetconf = PuppetConfigurer.new('noop' => true)
         | 
| 153 | 
            +
                    KafoConfigure.exit_handler.register_cleanup_path puppetconf.config_path
         | 
| 154 | 
            +
             | 
| 150 155 | 
             
                    @logger.info 'Loading default values from puppet modules...'
         | 
| 151 | 
            -
                    command = PuppetCommand.new("$temp_dir=\"#{temp_dir}\" #{includes} dump_values(#{params_to_dump})", [ | 
| 156 | 
            +
                    command = PuppetCommand.new("$temp_dir=\"#{temp_dir}\" #{includes} dump_values(#{params_to_dump})", [], puppetconf, self).append('2>&1').command
         | 
| 152 157 | 
             
                    result = `#{command}`
         | 
| 153 158 | 
             
                    @logger.debug result
         | 
| 154 159 | 
             
                    unless $?.exitstatus == 0
         | 
| @@ -201,7 +206,7 @@ module Kafo | |
| 201 206 | 
             
                def preset_defaults_from_puppet
         | 
| 202 207 | 
             
                  # set values based on default_values
         | 
| 203 208 | 
             
                  params.each do |param|
         | 
| 204 | 
            -
                    param. | 
| 209 | 
            +
                    param.set_default_from_dump(params_default_values)
         | 
| 205 210 | 
             
                  end
         | 
| 206 211 | 
             
                end
         | 
| 207 212 |  | 
| @@ -296,8 +301,7 @@ module Kafo | |
| 296 301 | 
             
                end
         | 
| 297 302 |  | 
| 298 303 | 
             
                def params_to_dump
         | 
| 299 | 
            -
                   | 
| 300 | 
            -
                  parameters.map { |param| "#{param.dump_default}" }.join(',')
         | 
| 304 | 
            +
                  params.select(&:dump_default_needed?).map(&:dump_default).join(',')
         | 
| 301 305 | 
             
                end
         | 
| 302 306 |  | 
| 303 307 | 
             
                def format(data)
         | 
    
        data/lib/kafo/data_type.rb
    CHANGED
    
    | @@ -39,7 +39,16 @@ module Kafo | |
| 39 39 | 
             
                end
         | 
| 40 40 |  | 
| 41 41 | 
             
                def self.split_arguments(input)
         | 
| 42 | 
            -
                  input.scan(%r{ | 
| 42 | 
            +
                  input.scan(%r{
         | 
| 43 | 
            +
                    \s*
         | 
| 44 | 
            +
                      (?:
         | 
| 45 | 
            +
                        ["'/](.*?)["'/] # quoted string, or regexp argument
         | 
| 46 | 
            +
                        |
         | 
| 47 | 
            +
                        ([\w:]+ (?:\[.+\])?) # bare words, or Type::Name, or Type::Name[args..]
         | 
| 48 | 
            +
                      )
         | 
| 49 | 
            +
                    \s*
         | 
| 50 | 
            +
                    (?:,|$) # match to end of comma-separated arg, or the last arg
         | 
| 51 | 
            +
                  }mx).flatten.compact
         | 
| 43 52 | 
             
                end
         | 
| 44 53 |  | 
| 45 54 | 
             
                def self.parse_hash(input)
         | 
| @@ -8,10 +8,14 @@ module Kafo | |
| 8 8 | 
             
                    add_list(module_header(name), data['Basic'])
         | 
| 9 9 | 
             
                  end
         | 
| 10 10 |  | 
| 11 | 
            +
                  def string
         | 
| 12 | 
            +
                    super + "\nOnly commonly used options have been displayed.\nUse --full-help to view the complete list."
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
             | 
| 11 15 | 
             
                  private
         | 
| 12 16 |  | 
| 13 17 | 
             
                  def except_resets(items)
         | 
| 14 | 
            -
                    items.select { |i| !i.help.first.strip.start_with?('--reset-') || !i.help.last. | 
| 18 | 
            +
                    items.select { |i| !i.help.first.strip.start_with?('--reset-') || !i.help.last.include?('to the default value (') }
         | 
| 15 19 | 
             
                  end
         | 
| 16 20 | 
             
                end
         | 
| 17 21 | 
             
              end
         | 
    
        data/lib/kafo/kafo_configure.rb
    CHANGED
    
    | @@ -27,6 +27,7 @@ require 'kafo/hooking' | |
| 27 27 | 
             
            require 'kafo/exit_handler'
         | 
| 28 28 | 
             
            require 'kafo/scenario_manager'
         | 
| 29 29 | 
             
            require 'kafo/hiera_configurer'
         | 
| 30 | 
            +
            require 'kafo/puppet_configurer'
         | 
| 30 31 |  | 
| 31 32 | 
             
            module Kafo
         | 
| 32 33 | 
             
              class KafoConfigure < Clamp::Command
         | 
| @@ -234,6 +235,12 @@ module Kafo | |
| 234 235 | 
             
                def setup_config(conf_file)
         | 
| 235 236 | 
             
                  self.class.config_file      = conf_file
         | 
| 236 237 | 
             
                  self.class.config           = Configuration.new(self.class.config_file)
         | 
| 238 | 
            +
             | 
| 239 | 
            +
                  if self.class.config.parser_cache
         | 
| 240 | 
            +
                    self.class.config.parser_cache.force = true if ARGV.include?('--parser-cache')
         | 
| 241 | 
            +
                    self.class.config.parser_cache.force = false if ARGV.include?('--no-parser-cache')
         | 
| 242 | 
            +
                  end
         | 
| 243 | 
            +
             | 
| 237 244 | 
             
                  self.class.root_dir         = self.class.config.root_dir
         | 
| 238 245 | 
             
                  self.class.check_dirs       = self.class.config.check_dirs
         | 
| 239 246 | 
             
                  self.class.module_dirs      = self.class.config.module_dirs
         | 
| @@ -303,6 +310,7 @@ module Kafo | |
| 303 310 | 
             
                  self.class.app_option ['--force'], :flag, 'Force change of installation scenaraio'
         | 
| 304 311 | 
             
                  self.class.app_option ['--compare-scenarios'], :flag, 'Show changes between last used scenario and the scenario specified with -S or --scenario argument'
         | 
| 305 312 | 
             
                  self.class.app_option ['--migrations-only'], :flag, 'Apply migrations to a selected scenario and exit'
         | 
| 313 | 
            +
                  self.class.app_option ['--[no-]parser-cache'], :flag, 'Force use or bypass of Puppet module parser cache'
         | 
| 306 314 | 
             
                end
         | 
| 307 315 |  | 
| 308 316 | 
             
                def set_options
         | 
| @@ -320,10 +328,10 @@ module Kafo | |
| 320 328 |  | 
| 321 329 | 
             
                  params.sort.each do |param|
         | 
| 322 330 | 
             
                    doc = param.doc.nil? ? 'UNDOCUMENTED' : param.doc.join("\n")
         | 
| 323 | 
            -
                    self.class.option parametrize(param), '', doc,
         | 
| 324 | 
            -
                                      : | 
| 331 | 
            +
                    self.class.option parametrize(param), '', doc + " (current: #{param.value_to_s})",
         | 
| 332 | 
            +
                                      :multivalued => param.multivalued?
         | 
| 325 333 | 
             
                    self.class.option parametrize(param, 'reset-'), :flag,
         | 
| 326 | 
            -
                                      "Reset #{param.name} to the default value"
         | 
| 334 | 
            +
                                      "Reset #{param.name} to the default value (#{param.default_to_s})"
         | 
| 327 335 | 
             
                  end
         | 
| 328 336 | 
             
                end
         | 
| 329 337 |  | 
| @@ -411,23 +419,26 @@ module Kafo | |
| 411 419 | 
             
                  hiera.write_configs
         | 
| 412 420 | 
             
                  self.class.exit_handler.register_cleanup_path(hiera.temp_dir)
         | 
| 413 421 |  | 
| 422 | 
            +
                  puppetconf = PuppetConfigurer.new(
         | 
| 423 | 
            +
                    'color'        => false,
         | 
| 424 | 
            +
                    'evaltrace'    => !!@progress_bar,
         | 
| 425 | 
            +
                    'hiera_config' => hiera.config_path,
         | 
| 426 | 
            +
                    'noop'         => !!noop?,
         | 
| 427 | 
            +
                    'profile'      => !!profile?,
         | 
| 428 | 
            +
                    'show_diff'    => false
         | 
| 429 | 
            +
                  )
         | 
| 430 | 
            +
                  self.class.exit_handler.register_cleanup_path(puppetconf.config_path)
         | 
| 431 | 
            +
             | 
| 414 432 | 
             
                  exit_code   = 0
         | 
| 415 433 | 
             
                  exit_status = nil
         | 
| 416 434 | 
             
                  options     = [
         | 
| 417 435 | 
             
                      '--verbose',
         | 
| 418 436 | 
             
                      '--debug',
         | 
| 419 437 | 
             
                      '--trace',
         | 
| 420 | 
            -
                      '--color=false',
         | 
| 421 | 
            -
                      '--show_diff',
         | 
| 422 438 | 
             
                      '--detailed-exitcodes',
         | 
| 423 | 
            -
                      '--reports=',
         | 
| 424 | 
            -
                      "--hiera_config=#{hiera.config_path}",
         | 
| 425 439 | 
             
                  ]
         | 
| 426 | 
            -
                  options.push '--evaltrace' if @progress_bar
         | 
| 427 | 
            -
                  options.push '--noop' if noop?
         | 
| 428 | 
            -
                  options.push '--profile' if profile?
         | 
| 429 440 | 
             
                  begin
         | 
| 430 | 
            -
                    command = PuppetCommand.new('include kafo_configure', options).command
         | 
| 441 | 
            +
                    command = PuppetCommand.new('include kafo_configure', options, puppetconf).command
         | 
| 431 442 | 
             
                    log_parser = PuppetLogParser.new
         | 
| 432 443 | 
             
                    PTY.spawn(command) do |stdin, stdout, pid|
         | 
| 433 444 | 
             
                      begin
         | 
    
        data/lib/kafo/param.rb
    CHANGED
    
    | @@ -5,8 +5,10 @@ require 'kafo/validator' | |
| 5 5 |  | 
| 6 6 | 
             
            module Kafo
         | 
| 7 7 | 
             
              class Param
         | 
| 8 | 
            -
                 | 
| 9 | 
            -
             | 
| 8 | 
            +
                UNSET_VALUES = ['UNSET', :undef]
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                attr_reader :name, :module, :type, :manifest_default
         | 
| 11 | 
            +
                attr_accessor :doc, :value_set, :condition
         | 
| 10 12 | 
             
                attr_writer :groups
         | 
| 11 13 |  | 
| 12 14 | 
             
                def initialize(builder, name, type)
         | 
| @@ -20,8 +22,9 @@ module Kafo | |
| 20 22 | 
             
                end
         | 
| 21 23 |  | 
| 22 24 | 
             
                # we use @value_set flag because even nil can be valid value
         | 
| 25 | 
            +
                # Order of descending precedence: @value, @default (from dump), @manifest_default
         | 
| 23 26 | 
             
                def value
         | 
| 24 | 
            -
                  @type.typecast(@ | 
| 27 | 
            +
                  @value_set ? @type.typecast(@value) : default
         | 
| 25 28 | 
             
                end
         | 
| 26 29 |  | 
| 27 30 | 
             
                def value=(value)
         | 
| @@ -34,8 +37,34 @@ module Kafo | |
| 34 37 | 
             
                  @value     = nil
         | 
| 35 38 | 
             
                end
         | 
| 36 39 |  | 
| 40 | 
            +
                # For literal default values, only use 'manifest_default'. For variable values, use the value
         | 
| 41 | 
            +
                # loaded back from the dump in 'default'.
         | 
| 42 | 
            +
                def default
         | 
| 43 | 
            +
                  @type.typecast(dump_default_needed? ? @default : manifest_default)
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                def default=(default)
         | 
| 47 | 
            +
                  default = nil if UNSET_VALUES.include?(default)
         | 
| 48 | 
            +
                  @default = default
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                # manifest_default may be a variable ($foo::params::bar) and need dumping from Puppet to get
         | 
| 52 | 
            +
                # the actual default value
         | 
| 53 | 
            +
                def dump_default_needed?
         | 
| 54 | 
            +
                  manifest_default.to_s.start_with?('$')
         | 
| 55 | 
            +
                end
         | 
| 56 | 
            +
             | 
| 37 57 | 
             
                def dump_default
         | 
| 38 | 
            -
                  @type.dump_default( | 
| 58 | 
            +
                  @type.dump_default(manifest_default_params_variable)
         | 
| 59 | 
            +
                end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                def manifest_default=(default)
         | 
| 62 | 
            +
                  default = nil if UNSET_VALUES.include?(default)
         | 
| 63 | 
            +
                  @manifest_default = default
         | 
| 64 | 
            +
                end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                def manifest_default_params_variable
         | 
| 67 | 
            +
                  manifest_default[1..-1] if dump_default_needed?
         | 
| 39 68 | 
             
                end
         | 
| 40 69 |  | 
| 41 70 | 
             
                def module_name
         | 
| @@ -46,28 +75,20 @@ module Kafo | |
| 46 75 | 
             
                  "#<#{self.class}:#{self.object_id} @name=#{name.inspect} @default=#{default.inspect} @value=#{value.inspect} @type=#{@type}>"
         | 
| 47 76 | 
             
                end
         | 
| 48 77 |  | 
| 49 | 
            -
                def  | 
| 50 | 
            -
                   | 
| 51 | 
            -
             | 
| 52 | 
            -
             | 
| 53 | 
            -
             | 
| 54 | 
            -
             | 
| 55 | 
            -
             | 
| 56 | 
            -
             | 
| 57 | 
            -
             | 
| 58 | 
            -
             | 
| 59 | 
            -
             | 
| 60 | 
            -
             | 
| 61 | 
            -
             | 
| 62 | 
            -
             | 
| 63 | 
            -
                        # in puppet 2.7 :undefined means that it's param which value is
         | 
| 64 | 
            -
                        # not set by another parameter (e.g. foreman_group = 'something')
         | 
| 65 | 
            -
                        # which means, default is sensible unlike dumped default
         | 
| 66 | 
            -
                        # newer puppet has default dump in format 'value' => 'value' so
         | 
| 67 | 
            -
                        # it's handled correctly by else branch
         | 
| 68 | 
            -
                      else
         | 
| 69 | 
            -
                        self.default = value
         | 
| 70 | 
            -
                    end
         | 
| 78 | 
            +
                def default_to_s
         | 
| 79 | 
            +
                  internal_value_to_s(default)
         | 
| 80 | 
            +
                end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                def value_to_s
         | 
| 83 | 
            +
                  internal_value_to_s(value)
         | 
| 84 | 
            +
                end
         | 
| 85 | 
            +
             | 
| 86 | 
            +
                def set_default_from_dump(defaults)
         | 
| 87 | 
            +
                  # if we don't have default value from dump (can happen for modules added from hooks,
         | 
| 88 | 
            +
                  # or without using a params class), the existing default value from the manifest will
         | 
| 89 | 
            +
                  # be used. On calling #value, the default will be returned if no overriding value is set.
         | 
| 90 | 
            +
                  if dump_default_needed? && defaults.has_key?(manifest_default_params_variable)
         | 
| 91 | 
            +
                    self.default = defaults[manifest_default_params_variable]
         | 
| 71 92 | 
             
                  end
         | 
| 72 93 | 
             
                end
         | 
| 73 94 |  | 
| @@ -156,6 +177,10 @@ module Kafo | |
| 156 177 | 
             
                      value
         | 
| 157 178 | 
             
                  end
         | 
| 158 179 | 
             
                end
         | 
| 180 | 
            +
             | 
| 181 | 
            +
                def internal_value_to_s(value)
         | 
| 182 | 
            +
                  value.nil? ? 'UNDEF' : value.inspect
         | 
| 183 | 
            +
                end
         | 
| 159 184 | 
             
              end
         | 
| 160 185 | 
             
            end
         | 
| 161 186 |  | 
    
        data/lib/kafo/param_builder.rb
    CHANGED
    
    | @@ -59,11 +59,11 @@ module Kafo | |
| 59 59 | 
             
                  else
         | 
| 60 60 | 
             
                    type = Param
         | 
| 61 61 | 
             
                  end
         | 
| 62 | 
            -
                  param | 
| 63 | 
            -
                  param. | 
| 64 | 
            -
                  param.doc | 
| 65 | 
            -
                  param.groups | 
| 66 | 
            -
                  param.condition | 
| 62 | 
            +
                  param                  = type.new(@module, name, data_type)
         | 
| 63 | 
            +
                  param.manifest_default = data[:values][name]
         | 
| 64 | 
            +
                  param.doc              = data[:docs][name]
         | 
| 65 | 
            +
                  param.groups           = data[:groups][name]
         | 
| 66 | 
            +
                  param.condition        = data[:conditions][name]
         | 
| 67 67 | 
             
                  param
         | 
| 68 68 | 
             
                end
         | 
| 69 69 |  | 
    
        data/lib/kafo/params/password.rb
    CHANGED
    
    
| @@ -2,6 +2,8 @@ require 'kafo/version' | |
| 2 2 |  | 
| 3 3 | 
             
            module Kafo
         | 
| 4 4 | 
             
              class ParserCacheReader
         | 
| 5 | 
            +
                attr_accessor :force
         | 
| 6 | 
            +
             | 
| 5 7 | 
             
                def self.new_from_file(cache_paths)
         | 
| 6 8 | 
             
                  cache_paths = [cache_paths].compact unless cache_paths.is_a?(Array)
         | 
| 7 9 | 
             
                  if cache_paths.empty?
         | 
| @@ -38,8 +40,9 @@ module Kafo | |
| 38 40 | 
             
                  KafoConfigure.logger
         | 
| 39 41 | 
             
                end
         | 
| 40 42 |  | 
| 41 | 
            -
                def initialize(cache)
         | 
| 43 | 
            +
                def initialize(cache, options = {})
         | 
| 42 44 | 
             
                  @cache = cache
         | 
| 45 | 
            +
                  @force = options[:force]
         | 
| 43 46 | 
             
                end
         | 
| 44 47 |  | 
| 45 48 | 
             
                def logger
         | 
| @@ -47,11 +50,20 @@ module Kafo | |
| 47 50 | 
             
                end
         | 
| 48 51 |  | 
| 49 52 | 
             
                def get(key, manifest_path)
         | 
| 53 | 
            +
                  if @force == false
         | 
| 54 | 
            +
                    logger.debug "Skipping parser cache for #{manifest_path}, forced off"
         | 
| 55 | 
            +
                    return nil
         | 
| 56 | 
            +
                  end
         | 
| 57 | 
            +
             | 
| 50 58 | 
             
                  return nil unless @cache[:files].has_key?(key)
         | 
| 51 59 |  | 
| 52 60 | 
             
                  if @cache[:files][key][:mtime] && File.mtime(manifest_path).to_i > @cache[:files][key][:mtime]
         | 
| 53 | 
            -
                     | 
| 54 | 
            -
             | 
| 61 | 
            +
                    if @force
         | 
| 62 | 
            +
                      logger.warn "Parser cache for #{manifest_path} is outdated, forced to use it anyway"
         | 
| 63 | 
            +
                    else
         | 
| 64 | 
            +
                      logger.debug "Parser cache for #{manifest_path} is outdated, ignoring cache entry"
         | 
| 65 | 
            +
                      return nil
         | 
| 66 | 
            +
                    end
         | 
| 55 67 | 
             
                  end
         | 
| 56 68 |  | 
| 57 69 | 
             
                  @cache[:files][key][:data]
         | 
    
        data/lib/kafo/puppet_command.rb
    CHANGED
    
    | @@ -1,14 +1,16 @@ | |
| 1 1 | 
             
            # encoding: UTF-8
         | 
| 2 2 | 
             
            module Kafo
         | 
| 3 3 | 
             
              class PuppetCommand
         | 
| 4 | 
            -
                def initialize(command, options = [], configuration = KafoConfigure.config)
         | 
| 4 | 
            +
                def initialize(command, options = [], puppet_config = nil, configuration = KafoConfigure.config)
         | 
| 5 5 | 
             
                  @configuration = configuration
         | 
| 6 6 | 
             
                  @command = command
         | 
| 7 | 
            +
                  @puppet_config = puppet_config
         | 
| 7 8 |  | 
| 8 9 | 
             
                  # Expand the modules_path to work around the fact that Puppet doesn't
         | 
| 9 10 | 
             
                  # allow modulepath to contain relative (i.e ..) directory references as
         | 
| 10 11 | 
             
                  # of 2.7.23.
         | 
| 11 12 | 
             
                  @options = options.push("--modulepath #{File.expand_path(modules_path)}")
         | 
| 13 | 
            +
                  @options.push("--config=#{puppet_config.config_path}") if puppet_config
         | 
| 12 14 | 
             
                  @logger  = KafoConfigure.logger
         | 
| 13 15 | 
             
                end
         | 
| 14 16 |  | 
| @@ -17,6 +19,7 @@ module Kafo | |
| 17 19 | 
             
                end
         | 
| 18 20 |  | 
| 19 21 | 
             
                def command
         | 
| 22 | 
            +
                  @puppet_config.write_config if @puppet_config
         | 
| 20 23 | 
             
                  result = [
         | 
| 21 24 | 
             
                      "echo '$kafo_config_file=\"#{@configuration.config_file}\" #{add_progress} #{@command}'",
         | 
| 22 25 | 
             
                      '|',
         | 
| @@ -0,0 +1,37 @@ | |
| 1 | 
            +
            require 'tempfile'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Kafo
         | 
| 4 | 
            +
              class PuppetConfigurer
         | 
| 5 | 
            +
                attr_reader :logger
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                def initialize(settings = {})
         | 
| 8 | 
            +
                  @settings = {'reports' => ''}.merge(settings)
         | 
| 9 | 
            +
                  @logger = KafoConfigure.logger
         | 
| 10 | 
            +
                  @temp_file = Tempfile.new(['kafo_puppet', '.conf'])
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                def config_path
         | 
| 14 | 
            +
                  @temp_file.path
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                def [](key)
         | 
| 18 | 
            +
                  @settings[key]
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                def []=(key, value)
         | 
| 22 | 
            +
                  @settings[key] = value
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                def write_config
         | 
| 26 | 
            +
                  @logger.debug("Writing Puppet config file at #{@temp_file.path}")
         | 
| 27 | 
            +
                  @temp_file.open
         | 
| 28 | 
            +
                  @temp_file.truncate(0)
         | 
| 29 | 
            +
                  @temp_file.puts '[main]'
         | 
| 30 | 
            +
                  @settings.keys.sort.each do |key|
         | 
| 31 | 
            +
                    @temp_file.puts "#{key} = #{@settings[key]}"
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
                ensure
         | 
| 34 | 
            +
                  @temp_file.close
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
            end
         | 
    
        data/lib/kafo/version.rb
    CHANGED
    
    
    
        data/lib/kafo/wizard.rb
    CHANGED
    
    | @@ -114,7 +114,7 @@ END | |
| 114 114 | 
             
                def render_params(params, menu)
         | 
| 115 115 | 
             
                  params.each do |param|
         | 
| 116 116 | 
             
                    if param.visible?(@kafo.params)
         | 
| 117 | 
            -
                      menu.choice "Set #{HighLine.color(param.name, :important)}, current value: #{HighLine.color(param. | 
| 117 | 
            +
                      menu.choice "Set #{HighLine.color(param.name, :important)}, current value: #{HighLine.color(param.value_to_s, :info)}" do
         | 
| 118 118 | 
             
                        configure(param)
         | 
| 119 119 | 
             
                      end
         | 
| 120 120 | 
             
                    end
         | 
| @@ -141,13 +141,13 @@ END | |
| 141 141 | 
             
                end
         | 
| 142 142 |  | 
| 143 143 | 
             
                def configure_single(param)
         | 
| 144 | 
            -
                  say "\ncurrent value: #{HighLine.color(param. | 
| 144 | 
            +
                  say "\ncurrent value: #{HighLine.color(param.value_to_s, :info)}"
         | 
| 145 145 | 
             
                  ask("new value:")
         | 
| 146 146 | 
             
                end
         | 
| 147 147 |  | 
| 148 148 | 
             
                def configure_multi(param)
         | 
| 149 149 | 
             
                  say HighLine.color('every line is a separate value, blank line to quit, for hash use key:value syntax', :info)
         | 
| 150 | 
            -
                  say "\ncurrent value: #{HighLine.color(param. | 
| 150 | 
            +
                  say "\ncurrent value: #{HighLine.color(param.value_to_s, :info)} %>"
         | 
| 151 151 | 
             
                  ask("new value:") do |q|
         | 
| 152 152 | 
             
                    q.gather = ""
         | 
| 153 153 | 
             
                  end
         | 
| @@ -164,7 +164,7 @@ END | |
| 164 164 | 
             
                    say "\n" + HighLine.color("Resetting parameters of module #{mod.name}", :headline)
         | 
| 165 165 | 
             
                    choose do |menu|
         | 
| 166 166 | 
             
                      mod.params.each do |param|
         | 
| 167 | 
            -
                        menu.choice "Reset #{HighLine.color(param.name, :important)}, current value: #{HighLine.color(param. | 
| 167 | 
            +
                        menu.choice "Reset #{HighLine.color(param.name, :important)}, current value: #{HighLine.color(param.value_to_s, :info)}, default value: #{HighLine.color(param.default_to_s, :info)}" do
         | 
| 168 168 | 
             
                          reset(param)
         | 
| 169 169 | 
             
                        end if param.visible?(@kafo.params)
         | 
| 170 170 | 
             
                      end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: kafo
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0. | 
| 4 | 
            +
              version: 1.0.6
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Marek Hulan
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2017-01-05 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         | 
| @@ -114,14 +114,14 @@ dependencies: | |
| 114 114 | 
             
                requirements:
         | 
| 115 115 | 
             
                - - ">="
         | 
| 116 116 | 
             
                  - !ruby/object:Gem::Version
         | 
| 117 | 
            -
                    version: 0.1. | 
| 117 | 
            +
                    version: 0.1.6
         | 
| 118 118 | 
             
              type: :runtime
         | 
| 119 119 | 
             
              prerelease: false
         | 
| 120 120 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 121 121 | 
             
                requirements:
         | 
| 122 122 | 
             
                - - ">="
         | 
| 123 123 | 
             
                  - !ruby/object:Gem::Version
         | 
| 124 | 
            -
                    version: 0.1. | 
| 124 | 
            +
                    version: 0.1.6
         | 
| 125 125 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 126 126 | 
             
              name: logging
         | 
| 127 127 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -252,6 +252,7 @@ files: | |
| 252 252 | 
             
            - lib/kafo/progress_bars/black_white.rb
         | 
| 253 253 | 
             
            - lib/kafo/progress_bars/colored.rb
         | 
| 254 254 | 
             
            - lib/kafo/puppet_command.rb
         | 
| 255 | 
            +
            - lib/kafo/puppet_configurer.rb
         | 
| 255 256 | 
             
            - lib/kafo/puppet_log_parser.rb
         | 
| 256 257 | 
             
            - lib/kafo/puppet_module.rb
         | 
| 257 258 | 
             
            - lib/kafo/scenario_manager.rb
         |