Skip to content

Commit 2bef9a9

Browse files
author
Kevin Paulisse
committed
Implement more robust handling of facts-terminus == facter
1 parent 167b83b commit 2bef9a9

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

lib/octocatalog-diff/catalog-util/builddir.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def initialize(options = {}, logger = nil)
4242
@enc = nil
4343
@fact_file = nil
4444
@node = options[:node]
45+
@facts_terminus = options.fetch(:facts_terminus, 'yaml')
4546

4647
create_structure
4748
install_directory_symlink(logger, options[:basedir])
@@ -54,7 +55,7 @@ def initialize(options = {}, logger = nil)
5455
unless options[:hiera_config].nil?
5556
install_hiera_config(logger, options[:hiera_config], options[:hiera_path_strip])
5657
end
57-
@fact_file = install_fact_file(logger, options) unless options.fetch(:facts_terminus, 'yaml') != 'yaml'
58+
@fact_file = install_fact_file(logger, options) if @facts_terminus == 'yaml'
5859
@enc = install_enc(logger) unless options[:enc].nil? && options[:pe_enc_url].nil?
5960
install_ssl(logger, options) if options[:puppetdb_ssl_ca] || options[:puppetdb_ssl_client_cert]
6061
end
@@ -98,7 +99,7 @@ def install_routes_yaml(logger)
9899
routes_hash = {
99100
'master' => {
100101
'facts' => {
101-
'terminus' => 'yaml',
102+
'terminus' => @facts_terminus,
102103
'cache' => 'yaml'
103104
},
104105
'catalog' => {
@@ -113,8 +114,8 @@ def install_routes_yaml(logger)
113114
# Install the fact file in temporary directory
114115
# @param options [Hash] Options
115116
def install_fact_file(logger, options)
116-
unless options[:facts_terminus].nil? || options[:facts_terminus] == 'yaml'
117-
raise ArgumentError, "Called install_fact_file but :facts_terminus = #{options[:facts_terminus]}"
117+
unless @facts_terminus == 'yaml'
118+
raise ArgumentError, "Called install_fact_file but :facts_terminus = #{@facts_terminus}"
118119
end
119120
unless options[:node].is_a?(String) && !options[:node].empty?
120121
raise ArgumentError, 'Called install_fact_file without node, or with an empty node'

lib/octocatalog-diff/catalog/computed.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def initialize(options)
4444
@puppet_command = options[:puppet_command]
4545
@retries = nil
4646
@builddir = nil
47+
@facts_terminus = options.fetch(:facts_terminus, 'yaml')
4748

4849
# Pass through the input for other access
4950
@opts = options
@@ -52,10 +53,12 @@ def initialize(options)
5253

5354
# Actually build the catalog (populate @error_message, @catalog, @catalog_json)
5455
def build(logger = Logger.new(StringIO.new))
55-
facts_obj = OctocatalogDiff::CatalogUtil::Facts.new(@opts, logger)
56-
logger.debug "Start retrieving facts for #{@node} from #{self.class}"
57-
@opts[:facts] = facts_obj.facts
58-
logger.debug "Success retrieving facts for #{@node} from #{self.class}"
56+
if @facts_terminus != 'facter'
57+
facts_obj = OctocatalogDiff::CatalogUtil::Facts.new(@opts, logger)
58+
logger.debug "Start retrieving facts for #{@node} from #{self.class}"
59+
@opts[:facts] = facts_obj.facts
60+
logger.debug "Success retrieving facts for #{@node} from #{self.class}"
61+
end
5962
build_catalog(logger)
6063
end
6164

0 commit comments

Comments
 (0)