Puppet Class: hosts

Defined in:
manifests/init.pp

Summary

Manage /etc/hosts entries

Overview

Parameters:

  • entries (Hash[String[1], Hash[String[1], Any]]) (defaults to: {})

    A hash of hosts entries to manage

  • default_entries (Hash[String[1], Hash[String[1], Any]]) (defaults to: {})

    A hash of hosts entries to manage by default

  • purge (Boolean) (defaults to: true)

    unmanaged host resources

  • manage_fqdn (Boolean) (defaults to: true)

    manage the fqdn entry



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'manifests/init.pp', line 11

class hosts (
  Hash[String[1], Hash[String[1], Any]] $entries = {},
  Hash[String[1], Hash[String[1], Any]] $default_entries = {},
  Boolean $purge = true,
  Boolean $manage_fqdn = true,
) {
  $all_hosts = $default_entries + $entries

  $all_hosts.each |$n, $params| {
    host { $n:
      * => $params,
    }
  }

  if $purge {
    resources { 'host':
      purge => true,
    }
  }

  if $manage_fqdn {
    host { $facts['networking']['fqdn']:
      ensure       => present,
      ip           => $facts['networking']['ip'],
      host_aliases => $facts['networking']['hostname'],
    }
  }
}