On Sun, Sep 5, 2010 at 11:15 AM, Markus Roberts <[email protected]>wrote:
> > I was thinking a function could work for the people who really want
> > this feature and that way we're not creating issues with the way the
> > file type actually works.
> >
> > $mypath = "/usr/local/foo/bin"
> >
> > file { path_components($mypath):
> > ensure => directiory,
> > }
> >
> > and path_components just returns an array:
> >
> > ['/usr', '/usr/local', '/usr/local/foo', '/usr/local/bin']
>
> +1 Sweet!
>
>
The only problem I see with this solution is what to do about duplicate
declarations?
The second time you use this method somewhere, File["/"] and likely
File["/usr"] will exist in the catalog multiple times.
The way I solve this problem now and in the past is to have a class for
common LSB filesystem locations, like so:
module "filesystem"
# <modulepath>/filesystem/manifests/skeleton.pp
define filesystem::skeleton ($prefix=false) {
$prefix_real = $prefix ? {
false => $name,
default => $prefix,
}
file {
[ "${prefix_real}",
"${prefix_real}/bin",
"${prefix_real}/sbin",
"${prefix_real}/lib",
"${prefix_real}/lib64",
"${prefix_real}/share",
"${prefix_real}/man", ]:
owner => "0",
group => "0",
mode => "0755",
ensure => directory;
}
}
# <modulepath>/filesystem/manifests/usr.pp
class filesystem::usr {
filesystem::skeleton { "/usr": }
}
# <modulepath>/filesystem/manifests/usrlocal.pp
class filesystem::usrlocal {
filesystem::skeleton { "/usr/local": }
}
Using this method, the class may be included multiple times without causing
duplicate definition problems.
--
Jeff McCune
http://www.puppetlabs.com/
--
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en.