Simple example: a host entry

It makes sense to have static host entries in /etc/hosts for some nodes since DNS outages may disrupt the services provided by those nodes. Examples of such services are backups, authentication, and kerberos. We'll use LDAP (authentication) in this example. In this scenario, we'll apply the ldap::server class to any LDAP server and add a collector for Host entries to our base class (the base class will be a default applied to all nodes). First, declare the exported resource in ldap::server, as shown in the following code snippet:

class ldap::server {
  @@host {"ldap-$::hostname":
    host_aliases => ["$::fqdn",'ldap'],
    ip           => "$::ipaddress",
  }
}

This will create an exported entry on any host to which we apply the ldap::server ...

Get Mastering Puppet 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.