Puppet Class: authconfig
- Inherits:
- authconfig::params
- Defined in:
- manifests/init.pp
Overview
Class: authconfig
A puppet module that enables authconfig configuration simply
Parameters
Authors
Yanis Guenane <yguenane@gmail.com>
Copyright
Copyright 2013 Yanis Guenane, unless otherwise noted.
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 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'manifests/init.pp', line 15
class authconfig (
$ldap = false,
$ldapauth = false,
$ldaptls = false,
$ldapserver = undef,
$ldapbasedn = undef,
$nis = false,
$nisdomain = undef,
$nisserver = undef,
$passalgo = 'md5',
$shadow = true,
$krb5 = false,
$krb5realm = undef,
$krb5kdc = undef,
$krb5kadmin = undef,
$cache = false,
$fingerprint = false,
$winbind = false,
$winbindauth = false,
$smbsecurity = 'ads',
$smbrealm = undef,
$smbservers = undef,
$winbindjoin = undef,
) inherits authconfig::params {
case $::osfamily {
'RedHat' : {
# LDAP
if $ldap {
if $ldapserver == undef {
fail('The ldapserver parameter is required when ldap set to true')
}
if $ldapbasedn == undef {
fail('The ldapbasedn parameter is required when ldap is set to true')
}
}
$ldap_flg = $ldap ? {
true => '--enableldap',
default => '--disableldap',
}
$ldapauth_flg = $ldapauth ? {
true => '--enableldapauth',
default => '--disableldapauth',
}
$ldaptls_flg = $ldaptls ? {
true => '--enableldaptls',
default => '--disableldaptls',
}
if $ldapbasedn {
$ldapbasedn_val = "--ldapbasedn='${ldapbasedn}'"
}
if $ldapserver {
$ldapserver_val = "--ldapserver=${ldapserver}"
}
# NIS
if $nis {
if $nisdomain == undef {
fail('The nisdomain parameter is required when nis set to true')
}
if $nisserver == undef {
fail('The nisserver parameter is required when nis is set to true')
}
}
$nis_flg = $nis ? {
true => '--enablenis',
default => '--disablenis',
}
if $nisdomain {
$nisdomain_val = "--nisdomain=${nisdomain}"
}
if $nisserver {
$nisserver_val = "--nisserver=${nisserver}"
}
# MD5
$md5_flg = $passalgo ? {
md5 => '--enablemd5',
default => '--disablemd5',
}
# hash/crypt algorithm for new passwords
if ($passalgo) {
$passalgo_val = "--passalgo=${passalgo}"
}
# SHADOW
$shadow_flg = $shadow ? {
true => '--enableshadow',
default => '--disableshadow',
}
# Kerberos
if $krb5 {
if $krb5realm == undef {
fail('The krb5realm parameter is required when krb5 set to true')
}
if $krb5kdc == undef {
fail('The krb5kdc parameter is required when krb5 is set to true')
}
if $krb5kadmin == undef {
fail('The krb5kadmin parameter is required when krb5 is set to true')
}
}
$krb_flg = $krb5 ? {
true => '--enablekrb5',
default => '--disablekrb5',
}
if ($krb5realm) {
$krb5realm_val = "--krb5realm=${krb5realm}"
}
if (is_array($krb5kdc)) {
$kdc_joined = join($krb5kdc, ',')
$krb_kdc = "--krb5kdc=${kdc_joined}"
}
else {
$krb_kdc = "--krb5kdc=${krb5kdc}"
}
if ($krb5kadmin) {
$krb5kadmin_val = "--krb5adminserver=${krb5kadmin}"
}
# Winbind
if ($winbind) {
#smbrealm= Active directory domain (e.g. yourcompany.com)
if $smbrealm == undef {
fail('The smbrealm parameter is required when winbind is set to true')
}
#winbindjoin= User name of domain admin user to authenticate the domain join of the machine.
if $winbindjoin == undef {
fail('The winbindjoin parameter is required when winbind is set to true')
}
if $smbservers == undef {
fail('The smbservers parameter is required when winbind is set to true')
}
}
$winbind_flg = $winbind ? {
true => '--enablewinbind',
default => '--disablewinbind',
}
$winbindauth_flg = $winbindauth ? {
true => '--enablewinbindauth',
default => '--disablewinbindauth',
}
if ($smbsecurity) {
$smbsecurity_val = "--smbsecurity=${smbsecurity}"
}
if ($smbrealm) {
$smbrealm_val = "--smbrealm=${smbrealm}"
}
if ($winbindjoin) {
$winbindjoin_val = "--winbindjoin=${winbindjoin}"
}
if (is_array($smbservers)) {
$smbservers_joined = join($smbservers, ',')
$smbservers_val = "--smbservers=${smbservers_joined}"
}
# Cache/nscd
$cache_flg = $cache ? {
true => '--enablecache',
default => '--disablecache',
}
$fingerprint_flg = $fingerprint ? {
true => '--enablefingerprint',
default => '--disablefingerprint',
}
# construct the command
$ldap_flags = $ldap ? {
true => "${ldap_flg} ${ldapauth_flg} ${ldaptls_flg} ${ldapbasedn_val} ${ldapserver_val}",
default => '',
}
$nis_flags = $nis ? {
true => "${nis_flg} ${nisdomain_val} ${nisserver_val}",
default => '',
}
$krb5_flags = $krb5 ? {
true => "${krb_flg} ${krb5realm_val} ${krb_kdc} ${$krb5kadmin_val}",
default => '',
}
$winbind_flags = $winbind ? {
true => "${winbind_flg} ${winbindauth_flg} ${smbsecurity_val} ${smbrealm_val} ${winbindjoin_val} ${smbservers_val}",
default => '',
}
$pass_flags = "${md5_flg} ${passalgo_val} ${shadow_flg}"
$authconfig_flags = "${ldap_flags} ${nis_flags} ${pass_flags} ${krb5_flags} ${winbind_flags} ${cache_flg}"
$authconfig_update_cmd = "authconfig ${authconfig_flags} --update"
$authconfig_test_cmd = "authconfig ${authconfig_flags} --test"
$exec_check_cmd = "/usr/bin/test \"`${authconfig_test_cmd}`\" = \"`authconfig --test`\""
if ($cache) {
package { $authconfig::params::cache_packages:
ensure => installed,
} ->
service { $authconfig::params::cache_services:
ensure => running,
enable => true,
hasstatus => true,
hasrestart => true,
}
}
if ($krb5) {
package { $authconfig::params::krb5_packages:
ensure => installed,
}
}
if ($ldap) {
package { $authconfig::params::ldap_packages:
ensure => installed,
} ->
service { $authconfig::params::ldap_services:
ensure => running,
enable => true,
hasstatus => true,
hasrestart => true,
}
}
package { $authconfig::params::packages:
ensure => installed,
} ->
service { $authconfig::params::services:
ensure => running,
enable => true,
hasstatus => true,
hasrestart => true,
} ->
exec {'authconfig command':
path => '/usr/sbin',
command => $authconfig_update_cmd,
unless => $exec_check_cmd
}
}
default : {
fail("${::osfamily} is not supported")
}
}
}
|