O'Reilly logo

Puppet 2.7 Cookbook by John Arundel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required