We ran into an interesting problem today where we have a single
directory (/opt/company/bin/) and we want to populate it from multiple
modules. Since a number of these modules contain a bunch of files we
don't really want to list out each individually. What we're wanting
to do is something like:
class foo {
file { "files for foo":
path => "/opt/company/bin/",
source => "puppet:///foo/bin",
recurse => "true",
}
}
class bar {
file { "files for bar":
path => "/opt/company/bin/",
source => "puppet:///bar/bin",
recurse => "true",
}
}
This doesn't work as the interpreter bugs out when we set the path to
the same thing twice. I know we could just list multiple sources and
set sourceselect to all, however that would mean we'd be pulling files
we don't need on every system.
Another observation is if we put an extra "/" at the end of the path
in one of the classes it works - we can populate the same directory
from multiple sources, however I doubt this is anything other than
exploiting a bug. So my question is, if it functionally works to just
add an extra '/' to each subsequent file path definition, why can't it
be made to just work?
.r'
> We ran into an interesting problem today where we have a single
> directory (/opt/company/bin/) and we want to populate it from multiple
> modules. Since a number of these modules contain a bunch of files we
> don't really want to list out each individually. What we're wanting
> to do is something like:
Sounds related to the problems that GNU Stow [1] was meant to solve
(multiple packages, all wanting to install things into a common
/usr/local/bin or similar). If that's the case, then my puppet/stow
setup at [2] may help.
[1] http://www.gnu.org/software/stow/
[2]
http://blogs.cae.tntech.edu/mwr/2008/02/01/the-autostow-is-dead-long-live-stowedpackage/
--
Mike Renfro / R&D Engineer, Center for Manufacturing Research,
931 372-3601 / Tennessee Technological University
Puppet operates on the notion of managing uniquely declared resources. The
reason you don't want that to just work is because of the ambiguity it
leads to. What if you had two things managing the same resource and both
did something opposite of what the other did?
So, what you want to do is use overrides. Have the more generic class be
the baseclass and have the more specific class be a subclass. Then you can
use the override to add the additional path to the array of sources and use
sourceselect => all and this should give you want you want.
"sourceselect
Whether to copy all valid sources, or just the first one. This parameter is
only used in recursive copies; by default, the first valid source is the
only one used as a recursive source, but if this parameter is set to all,
then all valid sources will have all of their contents copied to the local
host, and for sources that have the same file, the source earlier in the
list will be used. Valid values are first, all."
--
Digant C Kasundra <dig...@stanford.edu>
Technical Lead, ITS Unix Systems and Applications, Stanford University
Hey thanks, that ended up working. Didn't know about the +> syntax until now.
cheers,
.r'