10

I can either write

include '::ntp'

or I can write

class { '::ntp':}

What is the difference between them, or do I need both?

dfc
  • 1,341
  • 8
  • 16
x3nr0s
  • 289
  • 2
  • 5
  • 13

2 Answers2

10

There are differences, here are two big ones:

Using include allows multiple declarations of a class. The class declaration can only be used once or you'll see a duplicate resource declaration error.

include will use external data, e.g. hiera, for parameters. Declaring class allows you to specify the parameters.

See https://puppet.com/docs/puppet/latest/lang_classes.html#the-include-function

Mike Marseglia
  • 913
  • 8
  • 18
-1

Include is to tell puppet to apply the class "ntp" to a node and class is to declare the class, the behavior of this class (like ensure file, package, user etc...)

DevOps
  • 720
  • 5
  • 16