O'Reilly logo

Puppet 3 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, the same idea works for classes. You can inherit from any class and add resources to it, or override existing resources with modified versions.

In this section we'll use the admin::ntp class we created previously as an example. The NTP servers we set up in the ntpd.conf file are US-based, which makes sense if your server is in a US data center. For UK-located servers, we'll create a modified version of admin::ntp which uses the official UK NTP servers.

How to do it…

Follow these steps to create the example class:

  1. Create the file modules/admin/manifests/ntp_uk.pp with the following contents:
    class admin::ntp_uk inherits admin::ntp { File['/etc/ntpd.conf'] { source => ...

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