diff --git a/lib/onceover/controlrepo.rb b/lib/onceover/controlrepo.rb index 5769a51..163aa6f 100644 --- a/lib/onceover/controlrepo.rb +++ b/lib/onceover/controlrepo.rb @@ -1,4 +1,6 @@ require 'r10k/puppetfile' +require 'r10k/initializers' +require 'r10k/settings/loader' require 'erb' require 'yaml' require 'find' @@ -214,6 +216,12 @@ def facts(filter = nil, key = 'values') return all_facts end + def settings_from_config(override_path) + loader = R10K::Settings::Loader.new + path = loader.search(override_path) + loader.read(path) + end + def print_puppetfile_table require 'terminal-table' require 'versionomy' @@ -222,6 +230,9 @@ def print_puppetfile_table # Load up the Puppetfile using R10k logger.debug "Reading puppetfile from #{@root}" + @settings = R10K::Settings.global_settings.evaluate(settings_from_config('r10k.yaml')) + R10K::Initializers::GlobalInitializer.new(@settings).call + logger.debug "Settings: #{@settings}" puppetfile = R10K::Puppetfile.new(@root) logger.debug "Loading modules from Puppetfile" puppetfile.load! @@ -250,7 +261,11 @@ def print_puppetfile_table end row << mod.v3_module.endorsement - superseded_by = mod.v3_module.superseded_by + begin + superseded_by = mod.v3_module.superseded_by + rescue NoMethodError + superseded_by = nil + end row << (superseded_by.nil? ? '' : superseded_by[:slug]) else row << "N/A" @@ -275,6 +290,8 @@ def update_puppetfile # Read in the Puppetfile as a string and as an object puppetfile_string = File.read(@puppetfile).split("\n") + @settings = R10K::Settings.global_settings.evaluate(settings_from_config('r10k.yaml')) + R10K::Initializers::GlobalInitializer.new(@settings).call puppetfile = R10K::Puppetfile.new(@root) puppetfile.load!