diff --git a/puppet/lib/puppet/indirector/facts/puppetdb.rb b/puppet/lib/puppet/indirector/facts/puppetdb.rb index 0e96185a51..9eacf45098 100644 --- a/puppet/lib/puppet/indirector/facts/puppetdb.rb +++ b/puppet/lib/puppet/indirector/facts/puppetdb.rb @@ -31,6 +31,18 @@ def save(request) package_inventory = inventory['packages'] if inventory.respond_to?(:keys) facts.values.delete('_puppet_inventory_1') + fact_names_blacklist = Puppet::Util::Puppetdb.config.fact_names_blacklist + + fact_names_blacklist.each{|blacklisted_fact_name| + facts.values.delete(blacklisted_fact_name) + } + + fact_names_blacklist_regexps = Puppet::Util::Puppetdb.config.fact_names_blacklist_regex + + fact_names_blacklist_regexps.each{|blacklisted_fact_name_regexp_str| + facts.values.reject!{|k,v| k =~ Regexp.new(blacklisted_fact_name_regexp_str)} + } + payload_value = { "certname" => facts.name, "values" => facts.values, diff --git a/puppet/lib/puppet/util/puppetdb/config.rb b/puppet/lib/puppet/util/puppetdb/config.rb index 488a047141..685c3f6eb7 100644 --- a/puppet/lib/puppet/util/puppetdb/config.rb +++ b/puppet/lib/puppet/util/puppetdb/config.rb @@ -14,9 +14,11 @@ def self.load(config_file = nil) :server_url_timeout => 30, :include_unchanged_resources => false, :min_successful_submissions => 1, - :submit_only_server_urls => "", - :command_broadcast => false, - :sticky_read_failover => false + :submit_only_server_urls => "", + :command_broadcast => false, + :sticky_read_failover => false, + :fact_names_blacklist => "", + :fact_names_blacklist_regex => "" } config_file ||= File.join(Puppet[:confdir], "puppetdb.conf") @@ -67,7 +69,9 @@ def self.load(config_file = nil) :min_successful_submissions, :submit_only_server_urls, :command_broadcast, - :sticky_read_failover].include?(k)) + :sticky_read_failover, + :fact_names_blacklist, + :fact_names_blacklist_regex].include?(k)) end parsed_urls = config_hash[:server_urls].split(",").map {|s| s.strip} @@ -102,6 +106,10 @@ def self.load(config_file = nil) "or equal to the number of server_urls (#{config_hash[:server_urls].length})" end + config_hash[:fact_names_blacklist] = config_hash[:fact_names_blacklist].split(",").map {|s| s.strip} + + config_hash[:fact_names_blacklist_regex] = config_hash[:fact_names_blacklist_regex].split(",").map {|s| s.strip} + self.new(config_hash) rescue => detail Puppet.warning "Could not configure PuppetDB terminuses: #{detail}" @@ -147,6 +155,14 @@ def sticky_read_failover config[:sticky_read_failover] end + def fact_names_blacklist + config[:fact_names_blacklist] + end + + def fact_names_blacklist_regex + config[:fact_names_blacklist_regex] + end + # @!group Private instance methods # @!attribute [r] count