I can either write

include '::ntp'

or I can write

class { '::ntp':}

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


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://docs.puppetlabs.com/puppet/latest/reference/lang_classes.html#using-include


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...)

  • class defines a class, while include declares (i.e. uses) it. – Marcello Romani Jan 17 '17 at 16:04

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.