On Aug 17, 1:32 pm, Douglas Garstang <doug.garst...@gmail.com> wrote:
> Actually, no, I think you DO need it.


Indeed yes.  You cannot 'require' a resource or class that is not
declared into the node's catalog.  The 'require' parameter does not do
that for you.  The include doesn't necessarily need to be in the same
class, but putting it there ensures that it is present; I consider it
a best practice to do that.

As for the dependency, I think it likely that your File['foo'] depends
on Class['service::common'] by virtue of being declared by that
class.  I didn't previously know that it worked that way, but it makes
sense.  Resources have access to the variables and other resources
declared by their declaring class, and a dependency makes that work.

I can see two possible workarounds;

1) Supposing that you mean the File property defaults to apply only to
files declared in class platform::common, and not to those declared in
other classes included by platform::common, I think you can achieve
that by wrapping all platform::common's own resources into an inner
class:

class platform::common {
    include service::common
    include platform::common::internal

    class platform::common::internal {
        File {
            require => Class['service::common']
        }
        # resources...
    }
}

In general, it's dangerous to include classes into a scope wherein
resource defaults apply.  It's not necessarily wrong, but it does
break encapsulation.


2) You could use the 'require' function or the resource chaining
operators to set up a class dependency, instead of using resource
defaults:

class platform::common {
    require service::common
}

Note that unlike the same-named resource parameter, the 'require'
*function* does make 'include' unnecessary.


John

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to