On Jan 18, 4:32 am, Antidot SAS <antidot...@gmail.com> wrote:
> Hi everyone,
>
> I am just rediting an old post because don't see any answer regarding this
> matter:

I observe that your thread title refers to "import", but there is no
importing in the examples you asked about.  I point this out only to
be sure you recognize that there is a big difference between "import"
and "include" -- much bigger, in fact, than the one between "include"
and "inherits".

As for the questions posed:


> In a class, what's the diff between:
>
> *don't take in count syntax, please.
>
> ----------------------------------
>
> class class_B {
>
> package { fortune }
>
> file { dummy }
>
> }
>
> ----------------------------------
>
> example 1)
>
> class class_A {
>
> include class_B
> package { foo }
>
> }


In this case, any node that declares class_A, directly or indirectly,
will also declare class_B (on account of the "include" statement).
Furthermore, Puppet will ensure that class_B's definition is evaluated
before anything following the "include" line inside class_A's
definition.  All of these are server-side considerations.


> example 2)
>
> class class_A {
>
> file { bogus
>
> before = > Package [foo],
>
> }
> package { foo
>
> require =>Class["class_B"],
>
> }
>
> }


In this case, the Puppet agent will manage all resources declared by
class_B before managing Package foo, and it will manage File bogus
before it manages Package foo *provided that* the node's manifests are
compiled successfully.  There is no guarantee that the manifests will
compile, however, because class_A does not ensure that class_B has
been evaluated before refering to it (contrary to Mr. Bria's
assertion).  One way to solve that problem would be to "include"
class_B, as in example (1).


> example 3)
>
> class class_A inherits class_B {
>
> package { foo }
>
> }


Functionally, this is the same as example (1), but as Felix describes,
it is an inappropriate use of class inheritance.

Just to muddy the waters, I'll add that in addition to the "require"
metaparameter, there is a "require" function related to both the
metaparameter and to the "include" function.  To illustrate its use,
these two examples are thoroughly equivalent:

example 4)

class_A {
  include "class_B"
  package { "foo": }
}

# On nodes, apply class_B before class_A
Class['class_B'] -> Class['class_A']

---

example 5)

class_A {
  # include class_B AND apply it to nodes
  # before this class
  require "class_B"
  package { "foo": }
}


HTH,

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