11

I have a class in puppet if I have the following code:

class A {
  require B

....
} 

I get circular dependencies error. If I have:

class A {
  include B

....
} 

everything works fine

talg
  • 241
  • 1
  • 3
  • 5

2 Answers2

21

They are very different things, actually. To say require B means B must come before A (and, therefore, can lead to circular dependencies if something in B turns out to require A). And if B is not included at all, it will lead to missing dependencies error.

On the other hand, include B just says B will be applied whenever A gets applied: it says nothing of the order between them.

Daniel C. Sobral
  • 5,713
  • 6
  • 34
  • 48
10

This was just asked (and answered) on the puppet mailing list:

The difference is evident when the catalog needs to be applied. With include you have evaluated its contents at the time of the include - but any resources must be depended on explicitly after the include. With a require - the dependency is created for you - but you have to be careful and ensure that this is your desired result

- Ken Barber in Require vs Include?

danlefree
  • 2,923
  • 1
  • 19
  • 20
larsks
  • 43,623
  • 14
  • 121
  • 180