Up until this point, classes and defines were presented as direct opposites with respect to flexibility; defined types are inherently adaptable through different parameter values, whereas classes model just one static piece of state. As the section title suggests, this is not entirely true. Classes, too, can have parameters. Their definition and declaration become rather similar to those of defined types in this case:
class apache::config(Integer $max_clients=100) {
file { '/etc/apache2/conf.d/max_clients.conf':
content => "MaxClients ${max_clients}\n",
}
}
With a definition like the preceding one, the class can be declared with a parameter value:
class { 'apache::config': max_clients => 120, }
This enables some very elegant designs, but introduces some drawbacks as well.
...