Hi James,
First off, if you "inherit server::directories" your server class gets
all the variables in it''s local namespace, so you can just use
$server::directories::data_dir1 as $data_dir1 and don''t have to worry
about two levels of :: namespace :-)
Can''t you just use an array here?
class server (directories = [ $server::directories::data_dirs ] )
inherits server::directories {
#Resource default so we don''t have to write the same parameters out
over and over and over...
File {
ensure => directory,
mode => ''0750'',
owner => ''user1'',
group => ''user1'',
}
file { $directories: }
}
On 30/04/12 15:54, James Dehune wrote:> I need to manage some directories, ensure they are created/present,
> owner/groups/modes are correct. I have a static list of directories
> that will be present on this group of servers. However, down the road
> one of the nodes may need a new partition that the other nodes may not.
>
> I''ve created a "server::directories" class:
>
> class server::directories {
> $data_dir1 = ''/directory1''
> $data_dir2 = ''/directory2''
> }
>
>
> Then in my init.pp:
>
> class server (
> $data_dir1 = $server::directories::data_dir1,
> $data_dir2 = $server::directories::data_dir2,
> $new_dir1 = undef
> ) inherits server::directories {
> file { ''data_dir1'':
> path => $data_dir1,
> ensure => directory,
> mode => ''0750'',
> owner => ''user1'',
> group => ''user1'',
> }
> file { ''data_dir2'':
> path => $data_dir2,
> ensure => directory,
> mode => ''0750'',
> owner => ''user1'',
> group => ''user1'',
> }
> file { ''new_dir1'':
> path => $new_dir1,
> ensure => directory,
> mode => ''0750'',
> owner => ''user1'',
> group => ''user1'',
> }
>
>
>
> Is there a better way to do what I''m trying to do here? Also,
what if
> there a 2 directories I want to add? I can only define one instance
> of a parameterized class per node definition, so I can''t have
> /new_dir2? How would I get around this?
>
> thanks for the advice.
>
>
> --
> 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.
--
Luke Bigum
Information Systems
Ph: +44 (0) 20 3192 2520
luke.bigum@lmax.com | http://www.lmax.com
LMAX, Yellow Building, 1A Nicholas Road, London W11 4AN
FX and CFDs are leveraged products that can result in losses exceeding
your deposit. They are not suitable for everyone so please ensure you
fully understand the risks involved. The information in this email is not
directed at residents of the United States of America or any other
jurisdiction where trading in CFDs and/or FX is restricted or prohibited
by local laws or regulations.
The information in this email and any attachment is confidential and is
intended only for the named recipient(s). The email may not be disclosed
or used by any person other than the addressee, nor may it be copied in
any way. If you are not the intended recipient please notify the sender
immediately and delete any copies of this message. Any unauthorised
copying, disclosure or distribution of the material in this e-mail is
strictly forbidden.
LMAX operates a multilateral trading facility. Authorised and regulated
by the Financial Services Authority (firm registration number 509778) and
is registered in England and Wales (number 06505809).
Our registered address is Yellow Building, 1A Nicholas Road, London, W11
4AN.
--
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.