Skip to content

Commit 66830ac

Browse files
authored
Merge pull request #648 from stbenjam/environmentpath-fact
Add facter fact for puppet_environmentpath
2 parents 805e5b8 + 2beef9a commit 66830ac

2 files changed

Lines changed: 35 additions & 26 deletions

File tree

lib/facter/puppet_settings.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# These facter facts return the value of the Puppet vardir and environment path
2+
# settings for the node running puppet or puppet agent. The intent is to
3+
# enable Puppet modules to automatically have insight into a place where they
4+
# can place variable data, or for modules running on the puppet master to know
5+
# where environments are stored.
6+
#
7+
# The values should be directly usable in a File resource path attribute.
8+
#
9+
begin
10+
require 'facter/util/puppet_settings'
11+
rescue LoadError => e
12+
# puppet apply does not add module lib directories to the $LOAD_PATH (See
13+
# #4248). It should (in the future) but for the time being we need to be
14+
# defensive which is what this rescue block is doing.
15+
rb_file = File.join(File.dirname(__FILE__), 'util', 'puppet_settings.rb')
16+
load rb_file if File.exists?(rb_file) or raise e
17+
end
18+
19+
20+
# These will be nil if Puppet is not available.
21+
Facter.add(:puppet_vardir) do
22+
setcode do
23+
Facter::Util::PuppetSettings.with_puppet do
24+
Puppet[:vardir]
25+
end
26+
end
27+
end
28+
29+
Facter.add(:puppet_environmentpath) do
30+
setcode do
31+
Facter::Util::PuppetSettings.with_puppet do
32+
Puppet[:environmentpath]
33+
end
34+
end
35+
end

lib/facter/puppet_vardir.rb

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)