From 63429fe9ec595df70a39de0944d893134899211e Mon Sep 17 00:00:00 2001 From: Nick Walker Date: Wed, 11 Nov 2015 13:52:20 -0800 Subject: [PATCH] Add custom functions for determining some PE settings Added a function to find the hostname and port of the classifier Added a fucntion to return all puppetdb hostnames --- .../functions/puppet_master_classifer_settings.rb | 5 +++++ .../lib/puppet/parser/functions/puppetdb_hostname.rb | 12 ++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 site/puppet_master_classifer_settings_function/lib/puppet/parser/functions/puppet_master_classifer_settings.rb create mode 100644 site/puppetdb_hostname_function/lib/puppet/parser/functions/puppetdb_hostname.rb diff --git a/site/puppet_master_classifer_settings_function/lib/puppet/parser/functions/puppet_master_classifer_settings.rb b/site/puppet_master_classifer_settings_function/lib/puppet/parser/functions/puppet_master_classifer_settings.rb new file mode 100644 index 0000000..5559849 --- /dev/null +++ b/site/puppet_master_classifer_settings_function/lib/puppet/parser/functions/puppet_master_classifer_settings.rb @@ -0,0 +1,5 @@ +module Puppet::Parser::Functions + newfunction(:puppet_master_classifer_settings, :type => :rvalue) do |args| + function_parseyaml([function_file([File.join(lookupvar('settings::confdir').to_s, 'classifier.yaml')])]) + end +end diff --git a/site/puppetdb_hostname_function/lib/puppet/parser/functions/puppetdb_hostname.rb b/site/puppetdb_hostname_function/lib/puppet/parser/functions/puppetdb_hostname.rb new file mode 100644 index 0000000..b43365f --- /dev/null +++ b/site/puppetdb_hostname_function/lib/puppet/parser/functions/puppetdb_hostname.rb @@ -0,0 +1,12 @@ +require 'puppet/util/puppetdb' + +module Puppet::Parser::Functions + newfunction(:puppetdb_hostnames, :type => :rvalue) do |args| + output = [] + Puppet::Util::Puppetdb.config.server_urls.each do | server_url | + output << server_url.hostname + end + + output + end +end