Puppet Class: aixldap::configure

Defined in:
manifests/configure.pp

Overview

Avoid modifying private classes. Configure AIXLDAP



4
5
6
7
8
9
10
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
39
40
41
42
43
44
45
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
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
# File 'manifests/configure.pp', line 4

class aixldap::configure {
  assert_private('Please use aixldap main class')

  if ($aixldap::use_ssl == 'yes' or $aixldap::use_ssl == 'SSL' or $aixldap::use_ssl == 'TLS') {
    # SSL Certificate
    file { $aixldap::ssl_ca_cert_file:
      ensure  => 'file',
      content => $aixldap::ssl_ca_cert_content,
      source  => $aixldap::ssl_ca_cert_source,
      mode    => '0644',
      owner   => 'root',
      group   => 'security',
      notify  => Exec['trust-adldap-cert'],
    }

    $kdb_file = $aixldap::kdb_file
    $kdb_dir = dirname($kdb_file)
    $kdb_file_prefix = basename($kdb_file, '.kdb')
    exec { 'check-for-bad-keydb':
      command  => "mkdir -p ${kdb_dir}/keydb-sav$$ && mv ${kdb_dir}/${kdb_file_prefix}.* ${kdb_dir}/keydb-sav$$",
      unless   => "[ ! -f ${kdb_file} ] || gsk8capicmd_64 -cert -list -db \'${kdb_file}\' -pw \'${aixldap::kdb_password}\' -type cms",
      provider => 'shell',
      before   => [ Exec['create-keydb'], File[$aixldap::ssl_ca_cert_file] ],
    }

    exec { 'create-keydb':
      command => "gsk8capicmd_64 -keydb -create -db \'${kdb_file}\' -pw \'${aixldap::kdb_password}\' -type cms -stash -empty -strong",
      creates => $kdb_file,
      notify  => Exec['trust-adldap-cert'],
    }

    # NOTE: If the keydb file exists, but has the wrong password, this will fail
    exec { 'trust-adldap-cert':
      command     => "gsk8capicmd_64 -cert -add -db \'${kdb_file}\' -pw \'${aixldap::kdb_password}\' -type cms -file \'${aixldap::ssl_ca_cert_file}\' -trust enable -format ascii -label \'${aixldap::ssl_ca_cert_label}\'", # lint:ignore:140chars
      refreshonly => true,
      require     => Exec['create-keydb'],
      before      => Exec['mksecldap'],
      notify      => Service['secldapclntd'],
    }

    $ssl_options = "-n 636 -k \'${kdb_file}\' -w \'${aixldap::kdb_password}\'"
  } else {
    $ssl_options = '-n 389'
  }

  # run mksecldap - This seems to do a lot more than just setup the ldap.cfg, so we are going to execute it
  exec { 'mksecldap':
    command => "mksecldap -c -h \'${aixldap::ldapservers}\' -a \'${aixldap::bind_dn}\' -p \'${aixldap::bind_password}\' -d \'${aixldap::base_dn}\' ${ssl_options} -A ${aixldap::auth_type} -D ${aixldap::default_loc}", # lint:ignore:140chars
    creates => '/usr/lib/libibmldap.a',
    before  => File[$aixldap::ldap_cfg_file],
    timeout => 600,
  }


  # Default ldap config settings
  $ldap_cfg_defaults =  {
    ldapservers          => $aixldap::ldapservers,
    binddn               => $aixldap::bind_dn,
    bindpwd              => $aixldap::bind_password_crypted,
    basedn               => $aixldap::base_dn,
    ldapsslkeyf          => $aixldap::kdb_file,
    ldapsslkeypwd        => $aixldap::kdb_password_crypted,
    authtype             => $aixldap::auth_type,
    defaultentrylocation => $aixldap::default_loc,
    useSSL               => $aixldap::use_ssl,
    userattrmappath      => $aixldap::user_map_file,
    groupattrmappath     => $aixldap::group_map_file,
    userbasedn           => "CN=Users,${aixldap::base_dn}",
    groupbasedn          => "OU=Microsoft Exchange Security Groups,${aixldap::base_dn}",
    hostbasedn           => "OU=Disabled,OU=ENT-Services,${aixldap::base_dn}",
  }

  $ldap_cfgs = merge ($ldap_cfg_defaults, $aixldap::ldap_cfg_options)

  file { $aixldap::ldap_cfg_file:
    ensure  => 'file',
    owner   => 'root',
    group   => 'security',
    content => template('aixldap/ldap.cfg.erb'),
    notify  => Service['secldapclntd'],
  }

  file { $aixldap::user_map_file:
    ensure  => 'file',
    owner   => 'root',
    group   => 'security',
    mode    => '0644',
    content => $aixldap::user_map_content,
    source  => $aixldap::user_map_source,
    notify  => Service['secldapclntd'],
  }

  file { $aixldap::group_map_file:
    ensure  => 'file',
    owner   => 'root',
    group   => 'security',
    mode    => '0644',
    content => $aixldap::group_map_content,
    source  => $aixldap::group_map_source,
    notify  => Service['secldapclntd'],
  }

  # Kerberos Config (crutch exec)
  exec { 'mkkrb5clnt':
    command => "mkkrb5clnt  -l ${aixldap::ldapservers} -r ${aixldap::kerb_realm_real} -d ${aixldap::domain} -i LDAP -D",
    creates => '/etc/krb5/krb5.conf',
    require => Exec['mksecldap'],
  }

  if (aixldap::enable_ldap) {
    chsec { 'user-default-registry':
      ensure    => present,
      file      => '/etc/security/user',
      stanza    => 'default',
      attribute => 'registry',
      value     => 'KRB5LDAP',
      require   => Service['secldapclntd'],
    }

    chsec { 'user-default-SYSTEM':
      ensure    => present,
      file      => '/etc/security/user',
      stanza    => 'default',
      attribute => 'SYSTEM',
      value     => 'compat or KRB5LDAP',
      require   => Service['secldapclntd'],
    }

    # This will cause the user's attributes to be modified after defaults are changed
    Chsec['user-default-registry', 'user-default-SYSTEM'] -> User <| title != 'root' |>
  }

  # Ensure new local users are configured with SYSTEM=compat and registry=files
  ['user', 'admin'].each | String $stanza | {
    chsec { "mkuser.default-${stanza}-system":
      ensure    => present,
      file      => '/etc/security/mkuser.default',
      stanza    => $stanza,
      attribute => 'SYSTEM',
      value     => 'compat',
    }
    chsec { "mkuser.default-${stanza}-registry":
      ensure    => present,
      file      => '/etc/security/mkuser.default',
      stanza    => $stanza,
      attribute => 'registry',
      value     => 'files',
    }
  }

  # Lets just place this file - chsec is acting strange about this one
  file { '/etc/methods.cfg':
    ensure => 'file',
    source => 'puppet:///modules/aixldap/methods.cfg',
    owner  => 'root',
    group  => 'system',
    mode   => '0644',
  }

  # Manage /etc/netsvc.conf hosts line
  if $aixldap::netsvc_hosts {
    file_line { 'netsvc.conf-hosts':
      path  => '/etc/netsvc.conf',
      line  => "hosts = ${aixldap::netsvc_hosts}",
      match => '^hosts',
    }
  }

}