Defined Type: krb5::kdc::realm

Defined in:
manifests/kdc/realm.pp

Summary

Allows you to add a realm to the ``[realms]`` section of ``/var/kerberos/krb5kdc/kdc.conf``.

Overview

Note: The kdc.conf file is *fully managed* by Puppet

Parameters:

  • initialize (Boolean) (defaults to: false)

    If set, auto-initialize the Realm. This will add an initial Principal for this Realm.

  • auto_principal (String) (defaults to: 'puppet_auto')

    If “$initialize“ is set, this principal will be created as an administrative Principal on the Realm.

  • trusted_nets (Simplib::Netlist) (defaults to: pick( getvar('krb5::kdc::trusted_nets'), simplib::lookup('simp_options::trusted_nets', { 'default_value' => ['127.0.0.1']}) ))

    networks to allow access into the KDC realm.

  • acl_file (Stdlib::Absolutepath) (defaults to: "/var/kerberos/krb5kdc/kadm5_${name}.acl")

    The path to the KDC realm ACL file.

  • admin_keytab (Stdlib::Absolutepath) (defaults to: "/var/kerberos/krb5kdc/kadm5_${name}.keytab")

    The path to the KDC realm keytab.

  • database_name (Optional[String]) (defaults to: undef)

    The path to the KDC realm database.

  • default_principal_expiration (Optional[String]) (defaults to: undef)

    The Absolute Time for expiring the principal expiration date for this realm. @see web.mit.edu/kerberos/krb5-devel/doc/basic/date_format.html#abstime

  • default_principal_flags (Array[String]) (defaults to: [])

    An array following the format prescribed in the man page. The absence of a ‘-’ in front of the entry implies that a ‘+’ will be added.

  • dict_file (Stdlib::Absolutepath) (defaults to: '/usr/share/dict/words')

    The path to the dictionary file of strings that are not allowed as passwords.

  • kadmind_port (Optional[Simplib::Port]) (defaults to: undef)

    The port on which kadmind should listen.

  • kpasswd_port (Optional[Simplib::Port]) (defaults to: undef)

    The port on which kpasswd should listen.

  • key_stash_file (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    The path to the KDC realm master key.

  • kdc_ports (Array[Simplib::Port]) (defaults to: [])

    UDP ports upon which the KDC should listen.

  • kdc_tcp_ports (Array[Simplib::Port]) (defaults to: [])

    TCP ports upon which the KDC should listen.

  • master_key_name (Optional[String]) (defaults to: undef)

    The principal associated with the master key.

  • master_key_type (String) (defaults to: 'aes256-cts')

    The master key’s key type.

  • max_life (Optional[String]) (defaults to: undef)

    The maximum time period for which a ticket may be valid. Should be a valid krb5 Time Duration string. @see web.mit.edu/kerberos/krb5-1.13/doc/basic/date_format.html#duration

  • max_renewable_life (Optional[String]) (defaults to: undef)

    The maximum time period during which a valid ticket may be renewed. Should be a valid krb5 Time Duration string.

  • iprop_enable (Optional[Boolean]) (defaults to: undef)

    Whether incremental database propogation is enabled.

  • iprop_master_ulogsize (Optional[Integer]) (defaults to: undef)

    The maximum number of log entries for incremental propogation.

  • iprop_slave_poll (Optional[String]) (defaults to: undef)

    How often the KDC polls for new updates from the master.

  • supported_enctypes (Array[String]) (defaults to: [ 'aes256-cts:normal', 'aes128-cts:normal' ])

    The default key/salt combinations for this realm.

  • reject_bad_transit (Optional[Boolean]) (defaults to: undef)

    Whether to check the list of transited realms for cross-realm tickets.

  • config_dir (Stdlib::Absolutepath) (defaults to: simplib::lookup('krb5::kdc::config_dir', { 'default_value' => '/var/kerberos/krb5kdc/kdc.conf.simp.d' }))

    The path to the Puppet managed config files.

  • ensure (String) (defaults to: 'present')

    Whether to set or clear the key. Valid values are ‘present’ and ‘absent’. Setting anything besides ‘absent’ will default to ‘present’.

  • firewall (Boolean) (defaults to: simplib::lookup('krb5::kdc::firewall', { 'default_value' => false }))

    Whether to add appropriate iptables rules for KDC

See Also:

  • -> REALMS SECTION

Author:

  • Trevor Vaughan <tvaughan@onyxpoint.com>



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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'manifests/kdc/realm.pp', line 52

define krb5::kdc::realm (
  Boolean                        $initialize                   = false,
  String                         $auto_principal               = 'puppet_auto',
  Simplib::Netlist               $trusted_nets                 = pick(
                                                                    getvar('krb5::kdc::trusted_nets'),
                                                                    simplib::lookup('simp_options::trusted_nets', { 'default_value' => ['127.0.0.1']})
                                                                  ),
  Stdlib::Absolutepath           $acl_file                     = "/var/kerberos/krb5kdc/kadm5_${name}.acl",
  Stdlib::Absolutepath           $admin_keytab                 = "/var/kerberos/krb5kdc/kadm5_${name}.keytab",
  Optional[String]               $database_name                = undef,
  Optional[String]               $default_principal_expiration = undef,
  Array[String]                  $default_principal_flags      = [],
  Stdlib::Absolutepath           $dict_file                    = '/usr/share/dict/words',
  Optional[Simplib::Port]        $kadmind_port                 = undef,
  Optional[Simplib::Port]        $kpasswd_port                 = undef,
  Optional[Stdlib::Absolutepath] $key_stash_file               = undef,
  Array[Simplib::Port]           $kdc_ports                    = [],
  Array[Simplib::Port]           $kdc_tcp_ports                = [],
  Optional[String]               $master_key_name              = undef,
  String                         $master_key_type              = 'aes256-cts',
  Optional[String]               $max_life                     = undef,
  Optional[String]               $max_renewable_life           = undef,
  Optional[Boolean]              $iprop_enable                 = undef,
  Optional[Integer]              $iprop_master_ulogsize        = undef,
  Optional[String]               $iprop_slave_poll             = undef,
  Array[String]                  $supported_enctypes           = [ 'aes256-cts:normal', 'aes128-cts:normal' ],
  Optional[Boolean]              $reject_bad_transit           = undef,
  Stdlib::Absolutepath           $config_dir                   = simplib::lookup('krb5::kdc::config_dir', { 'default_value' => '/var/kerberos/krb5kdc/kdc.conf.simp.d' }),
  String                         $ensure                       = 'present',
  Boolean                        $firewall                     = simplib::lookup('krb5::kdc::firewall', { 'default_value' => false })
) {

  if !defined(Class['krb5::kdc']) {
    fail('You must include krb5::kdc before using krb5::kdc::realm')
  }

  if !empty($default_principal_flags) {
    if is_string($_default_principal_flags) {
      $_default_principal_flags = split($default_principal_flags,'\s+')
    }
    else {
      $_default_principal_flags = $default_principal_flags

      $_possible_principal_flags = [
        'allow-tickets',
        'dup-skey',
        'forwardable',
        'hwauth',
        'no-auth-data-required',
        'ok-as-delegate',
        'ok-to-auth-as-delegate',
        'postdateable',
        'preauth',
        'proxiable',
        'pwchange',
        'pwservice',
        'renewable',
        'service',
        'tgt-based'
      ]

      $_possible_principal_flag_check_string = join($_possible_principal_flags, '|')

      simplib::validate_re_array(
        $_default_principal_flags,
        "^([+-]?(${_possible_principal_flag_check_string}))"
      )
    }
  }
  else {
    $_default_principal_flags = []
  }

  if $max_life { krb5::validate_time_duration($max_life) }
  if $max_renewable_life { krb5::validate_time_duration($max_renewable_life) }

  # Formatted for the output file
  $_kdc_ports = join($kdc_ports,',')
  $_kdc_tcp_ports = join($kdc_tcp_ports,',')
  $_supported_enctypes = join($supported_enctypes,',')

  $_name = krb5::munge_conf_filename($name)

  $_upcase_realm = upcase($name)

  file { $acl_file:
    ensure  => 'file',
    owner   => 'root',
    group   => 'root',
    mode    => '0600',
    seltype => 'krb5kdc_conf_t'
  }

  file { "${config_dir}/${_name}__realm":
    owner   => 'root',
    group   => 'root',
    mode    => '0600',
    seltype => 'krb5kdc_conf_t',
    content => template("${module_name}/kdc/realm.erb")
  }

  if $firewall {
    if !empty($kdc_tcp_ports) {
      iptables::listen::tcp_stateful { "${name}_allow_kdc":
        order        => 11,
        trusted_nets => $trusted_nets,
        dports       => $kdc_tcp_ports
      }
    }

    if !empty($kdc_ports) {
      iptables::listen::udp { "${name}_allow_kdc":
        order        => 11,
        trusted_nets => $trusted_nets,
        dports       => $kdc_ports
      }
    }
  }

  if $initialize {
    krb5_acl { "${name}_puppet_auto_admin":
      target         => $acl_file,
      principal      => "${auto_principal}/admin@${_upcase_realm}",
      operation_mask => '*'
    }

    exec { "add_admin_principal_${auto_principal}":
      command => "kadmin.local -q 'addprinc -randkey ${auto_principal}/admin@${_upcase_realm}'",
      unless  => "kadmin.local -q 'get_principal ${auto_principal}/admin' 2>&1 | \
                  grep -q 'Principal: ${auto_principal}/admin'",
      path    => ['/sbin','/bin','/usr/sbin','/usr/bin']
    }

    exec { "create_admin_principal_${auto_principal}_keytab":
      command => "kadmin.local -q 'ktadd -k ${admin_keytab} ${auto_principal}/admin@${_upcase_realm}'",
      unless  => "echo -e 'read_kt ${admin_keytab}\nlist' | ktutil | grep -q '${auto_principal}/admin@${_upcase_realm}'",
      path    => ['/sbin','/bin','/usr/sbin','/usr/bin'],
      require => Exec["add_admin_principal_${auto_principal}"]
    }
  }
}