Simple answer - no. Dependencies can only be between objects in
0.24.x...
I believe (but haven''t seen for myself yet) that there are changes to
this coming as its a frequently requested feature...
I used to think it was a good idea, then I sat and thought about it
for a while and now I don''t actually want it... One issue of enabling
this will be potential for a more complex dependency circle. Eg:
class foo {
file { "/tmp/foo": require => File["/tmp/foo2"] }
}
class foo2 {
require => Class[''foo'']
file { "/tmp/foo2": ensure => present }
}
This scenario would create a (possibly hard to see) circular
dependency...
If you have a lot of objects that have a common dependency - use
defines. Common one I had was lots of users requiring a common
resource:
user { "foo": uid => 1000, require => File["/home"] }
This type of thing can be annoying to specify require =>
File["/home"]
for 1000''s of users... Easy way to deal with it:
define luser ($uid) {
user { "$title":
uid => $uid,
require => File["/home"]
}
}
Then use: luser { "foo": uid => 1000 }
Another way is to use the Type defaults to specify this sort of thing.
For example:
User {
require => File["/home"]
}
This makes all users require File["/home"]. This is a bit more
restrictive (overwriting it can in some circumstances be a pain) so it
may not work in all cases...
Specifying each individual dependencies can seem like a pain in the
ass, but your resulting config will be better for it - Puppet will be
more effective when you get it right...
On Jul 24, 7:37 am, lance dillon <riffraff...@gmail.com>
wrote:> How can I have a module/class that is dependent on another class?
>
> Say, /etc/puppet/modules:
>
> module1
> module2
>
> in module2/manifests/init.pp
>
> class module2 {
> file { # blah blah blah
> require => Class["module1"],
> }
> package { }
>
> }
>
> Usually this gives me an error (can''t remember what; I''m
writing this from
> home, and I use it at work).
>
> If this isn''t enough information for a proper question, I can
reply to this
> message tomorrow after testing to get the error message again.
>
> Right now to get around it I just have my main class including several
other
> classes, but because of the dependencies, some of them fail the first time
> around, but succeed after running a second time and one of the other
> conditions had been met from the previous run (like an installed package or
> something). It is not the way I want to do it, of course, but
I''ve still
> been experimenting with different things.
>
> /lsd
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---