Environmentpath support for globbing

11 views
Skip to first unread message

Bostjan Skufca

unread,
Mar 8, 2015, 3:10:06 PM3/8/15
to puppe...@googlegroups.com
Hi there,

I like to have my environments organized into multiple subdirectories. Puppet configuration supports that by defining multiple paths for environmentpath setting, separated by ':'.

However, I find it very convenient to use this simple configuration line:
environmentpath = /etc/puppet/env/*

instead of this one:
environmentpath = /etc/puppet/env/SUB1:/etc/puppet/env/SUB2:/etc/puppet/env/SUB3:/etc/puppet/env/SUBx


The patch for this convenience is a simple one-line change:
---------------------------------------------------------------------------
--- puppet/settings/path_setting.rb.ORIG 2015-03-08 19:05:33.758705374 +0000
+++ puppet/settings/path_setting.rb 2015-03-07 01:59:31.127330981 +0000
@@ -1,7 +1,7 @@
 class Puppet::Settings::PathSetting < Puppet::Settings::StringSetting
   def munge(value)
     if value.is_a?(String)
-      value = value.split(File::PATH_SEPARATOR).map { |d| File.expand_path(d) }.join(File::PATH_SEPARATOR)
+      value = value.split(File::PATH_SEPARATOR).map { |d| File.expand_path(d) }.map { |d| Dir.glob(d) }.join(File::PATH_SEPARATOR)
     end
     value
   end
---------------------------------------------------------------------------

I haven't tested this with adding subdirs AFTER master is already started, thought, but a simple 'touch puppetmaster.conf' should do the trick if new directories are not picked up by default.

Would there be any interest for merging mentioned change upstream?

b.

Henrik Lindberg

unread,
Mar 9, 2015, 9:10:21 AM3/9/15
to puppe...@googlegroups.com
On 2015-08-03 20:10, Bostjan Skufca wrote:
> Hi there,
>
> I like to have my environments organized into multiple subdirectories.
> Puppet configuration supports that by defining multiple paths for
> environmentpath setting, separated by ':'.
>
> However, I find it very convenient to use this simple configuration line:
> environmentpath = /etc/puppet/env/*
>
> instead of this one:
> environmentpath =
> /etc/puppet/env/SUB1:/etc/puppet/env/SUB2:/etc/puppet/env/SUB3:/etc/puppet/env/SUBx
>
>
> The patch for this convenience is a simple one-line change:
> ---------------------------------------------------------------------------
> --- puppet/settings/path_setting.rb.ORIG2015-03-08 19:05:33.758705374 +0000
> +++ puppet/settings/path_setting.rb2015-03-07 01:59:31.127330981 +0000
> @@ -1,7 +1,7 @@
> class Puppet::Settings::PathSetting < Puppet::Settings::StringSetting
> def munge(value)
> if value.is_a?(String)
> - value = value.split(File::PATH_SEPARATOR).map { |d|
> File.expand_path(d) }.join(File::PATH_SEPARATOR)
> + value = value.split(File::PATH_SEPARATOR).map { |d|
> File.expand_path(d) }.map { |d| Dir..glob(d) }.join(File::PATH_SEPARATOR)
> end
> value
> end
> ---------------------------------------------------------------------------
>
> I haven't tested this with adding subdirs AFTER master is already
> started, thought, but a simple 'touch puppetmaster.conf' should do the
> trick if new directories are not picked up by default.
>
> Would there be any interest for merging mentioned change upstream?
>
This convenience looks like a useful addition. Please log a feature
request and submit a PR.

- henrik

--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

Reply all
Reply to author
Forward
0 new messages