RijilV
2008-May-16 19:40 UTC
[Puppet Users] Managing file in a single directory from multiple modules
Hello, 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'' --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Mike Renfro
2008-May-16 19:57 UTC
[Puppet Users] Re: Managing file in a single directory from multiple modules
On 5/16/2008 2:40 PM, RijilV wrote:> 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Digant C Kasundra
2008-May-16 20:04 UTC
[Puppet Users] Re: Managing file in a single directory from multiple modules
--On Friday, May 16, 2008 12:40:59 PM -0700 RijilV <rijilv@gmail.com> wrote:> > Hello, > > 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''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 <digant@stanford.edu> Technical Lead, ITS Unix Systems and Applications, Stanford University --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
RijilV
2008-May-19 18:04 UTC
[Puppet Users] Re: Managing file in a single directory from multiple modules
On 16/05/2008, Digant C Kasundra <digant@stanford.edu> wrote:> 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. >Hey thanks, that ended up working. Didn''t know about the +> syntax until now. cheers, .r'' --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---