Using class inheritance and overriding

Just as nodes can inherit from other nodes, to save you duplicating lots of stuff for nodes that are very similar, the same idea works for classes.

For example, imagine you have a class apache which manages the Apache web server, and you want to set up a new Apache machine but with a slightly different config file - perhaps listening on a different port.

You could duplicate the whole of the apache class, except for the config file. Alternatively, you could take the config file out of the apache class and create two new classes, each of which includes the base apache class and adds a different version of the config file.

A cleaner way is to inherit from the apache class, but override just the config file.

Getting ...

Get Puppet 2.7 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.