diff options
author | Reid Vandewiele <reid@puppetlabs.com> | 2016-06-29 15:54:20 +0100 |
---|---|---|
committer | Reid Vandewiele <reid@puppetlabs.com> | 2016-11-10 09:28:29 -0800 |
commit | f81ba549b73f0d752be1b4185c73818f791ab2f6 (patch) | |
tree | 3405c92a5c76463bc50a31fc2d9eb7e88da48bad | |
parent | dcef77af4cef2870874f76c06e92f601aeb5bc0c (diff) |
Add puppet_server fact to return agent's server
It is frequently useful to configure an agent to retrieve a resource
from it's configured master, or make further configuration adjustments
to itself based on what server it's using. Similar to the rationale for
stdlib providing a puppet_vardir fact, this commit adds a puppet_server
fact.
Note that the closest equivalent available today is $settings::server,
which returns only the MASTER's configured server, not the AGENT's. This
makes $settings::server unreliable, and not useful in a multi-master
deployment or a deployment involving a load balancer.
-rw-r--r-- | lib/facter/puppet_settings.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/facter/puppet_settings.rb b/lib/facter/puppet_settings.rb index e6a066a..eac9e97 100644 --- a/lib/facter/puppet_settings.rb +++ b/lib/facter/puppet_settings.rb @@ -33,3 +33,11 @@ Facter.add(:puppet_environmentpath) do end end end + +Facter.add(:puppet_server) do + setcode do + Facter::Util::PuppetSettings.with_puppet do + Puppet[:server] + end + end +end |