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:
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 => 'puppet:///modules/admin/ntp_uk.conf', } }
Create the file
modules/admin/files/ntp_uk.conf
with the following contents:driftfile /var/lib/ntp/ntp.drift server 0.uk.pool.ntp.org server 1.uk.pool.ntp.org server 2.uk.pool.ntp.org server 3.uk...