Puppet Class: dnsclient

Defined in:
manifests/init.pp

Summary

Manage DNS resolver

Overview

This module manages /etc/resolv.conf.

Parameters:

  • nameservers (Array[Stdlib::IP::Address]) (defaults to: ['8.8.8.8', '8.8.4.4'])

    Array of nameservers. The default use Google’s public name servers.

  • nameserver_limit (Optional[Integer[0]]) (defaults to: undef)

    Integer of the number of nameservers to allow in the resolv.conf NOTE: If ‘nameservers’ is over this limit, only the first X nameservers will be used where X is set by this limit. The nameservers over the limit will be discarded.

  • options (Array) (defaults to: ['rotate', 'timeout:1'])

    Array of options. Set to [] if no options line should be present.

  • search (Optional[Array[String[1]]]) (defaults to: undef)

    Optional array of domains for search list. This is mutually exclusive with domain.

  • domain (Optional[Stdlib::Fqdn]) (defaults to: undef)

    Optional domain setting. This is mutually exclusive with search.

  • sortlist (Optional[Array[String[1]]]) (defaults to: undef)

    Optional array of sortlist entries

  • custom_lines (Array[String[1]]) (defaults to: [])

    Array of lines that will be added to the end of /etc/resolv.conf

  • resolver_config_file (Stdlib::Absolutepath) (defaults to: '/etc/resolv.conf')

    Path to resolv.conf

  • resolver_config_file_ensure (String[1]) (defaults to: 'file')

    Value of ensure attribute for the /etc/resolv.conf file resource

  • resolver_config_file_owner (String[1]) (defaults to: 'root')

    User of /etc/resolv.conf

  • resolver_config_file_group (String[1]) (defaults to: 'root')

    Group of /etc/resolv.conf

  • resolver_config_file_mode (Stdlib::Filemode) (defaults to: '0644')

    Mode of /etc/resolv.conf in octal format

  • resolver_config_backup (Optional[Variant[Boolean, String[1]]]) (defaults to: undef)

    Sets the ‘backup’ parameter for /etc/resolv.conf



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'manifests/init.pp', line 46

class dnsclient (
  Array[Stdlib::IP::Address] $nameservers = ['8.8.8.8', '8.8.4.4'],
  Optional[Integer[0]] $nameserver_limit = undef,
  Array $options = ['rotate', 'timeout:1'],
  Optional[Array[String[1]]] $search = undef,
  Optional[Stdlib::Fqdn] $domain = undef,
  Optional[Array[String[1]]] $sortlist = undef,
  Array[String[1]] $custom_lines = [],
  Stdlib::Absolutepath $resolver_config_file = '/etc/resolv.conf',
  String[1] $resolver_config_file_ensure = 'file',
  String[1] $resolver_config_file_owner = 'root',
  String[1] $resolver_config_file_group = 'root',
  Stdlib::Filemode $resolver_config_file_mode = '0644',
  Optional[Variant[Boolean, String[1]]] $resolver_config_backup = undef,
) {

  if $search and $domain {
    fail('search and domain are mutually exclusive and both have been defined.')
  }

  # Only 3 nameservers are generally allowed by resolv.conf, so lets ensure that
  # (While letting people do interesting things in hiera to generate nameserver lists)
  # Also provide a way to override
  if $nameserver_limit {
    $nameservers_slice = $nameservers[0,$nameserver_limit]
  } else {
    $nameservers_slice = $nameservers
  }

  file { 'dnsclient_resolver_config_file':
    ensure  => $resolver_config_file_ensure,
    content => template('dnsclient/resolv.conf.erb'),
    path    => $resolver_config_file,
    owner   => $resolver_config_file_owner,
    group   => $resolver_config_file_group,
    mode    => $resolver_config_file_mode,
    backup  => $resolver_config_backup,
  }
}