Skip to content

Commit f3991af

Browse files
committed
Use osfamily fact for operating system specific config and packages to cover a wider range of distributions.
1 parent d1976c1 commit f3991af

File tree

2 files changed

+45
-59
lines changed

2 files changed

+45
-59
lines changed

manifests/config.pp

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
$uris_space = join($uris, ' ')
66
$uris_comma = join($uris, ',')
77

8-
include "pamldap::config::$operatingsystem"
9-
}
10-
class pamldap::config::common {
118
# defaults
129
File {
1310
owner => 'root',
@@ -51,34 +48,31 @@
5148
require => Class['pamldap::install'],
5249
notify => Class['pamldap::service'],
5350
}
54-
}
5551

56-
class pamldap::config::redhat inherits pamldap::config::common {
57-
file { '/etc/ldap.conf':
58-
ensure => present,
59-
mode => '0444',
60-
content => template('pamldap/ldap.conf.erb'),
61-
require => Class['pamldap::install'],
62-
notify => Class['pamldap::service'],
63-
}
64-
file { [ '/etc/pam_ldap.conf', '/etc/openldap/ldap.conf' ]:
65-
ensure => link,
66-
target => '/etc/ldap.conf',
67-
require => File['/etc/ldap.conf'],
68-
notify => Class['pamldap::service'],
69-
}
70-
}
71-
72-
class pamldap::config::centos inherits pamldap::config::redhat {
73-
# No changes
74-
}
75-
76-
class pamldap::config::ubuntu inherits pamldap::config::common {
77-
file { '/etc/ldap/ldap.conf':
78-
ensure => present,
79-
mode => '0444',
80-
content => template('pamldap/ldap.conf.erb'),
81-
require => Class['pamldap::install'],
82-
notify => Class['pamldap::service'],
52+
case $::osfamily {
53+
'RedHat': {
54+
file { '/etc/ldap.conf':
55+
ensure => present,
56+
mode => '0444',
57+
content => template('pamldap/ldap.conf.erb'),
58+
require => Class['pamldap::install'],
59+
notify => Class['pamldap::service'],
60+
}
61+
file { [ '/etc/pam_ldap.conf', '/etc/openldap/ldap.conf' ]:
62+
ensure => link,
63+
target => '/etc/ldap.conf',
64+
require => File['/etc/ldap.conf'],
65+
notify => Class['pamldap::service'],
66+
}
67+
}
68+
'Debian': {
69+
file { '/etc/ldap/ldap.conf':
70+
ensure => present,
71+
mode => '0444',
72+
content => template('pamldap/ldap.conf.erb'),
73+
require => Class['pamldap::install'],
74+
notify => Class['pamldap::service'],
75+
}
76+
}
8377
}
8478
}

manifests/install.pp

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,26 @@
11
class pamldap::install {
2-
include "pamldap::install::$operatingsystem"
3-
}
4-
5-
class pamldap::install::common {
62
if ! defined(Package['sssd']) {
73
package { 'sssd': ensure => installed }
84
}
9-
}
10-
11-
class pamldap::install::redhat inherits pamldap::install::common {
12-
if ! defined(Package['sssd-client']) {
13-
package { 'sssd-client': ensure => installed }
14-
}
15-
if ! defined(Package['openldap-clients']) {
16-
package { 'openldap-clients': ensure => installed }
5+
case $::osfamily {
6+
'Redhat': {
7+
if ! defined(Package['sssd-client']) {
8+
package { 'sssd-client': ensure => installed }
9+
}
10+
if ! defined(Package['openldap-clients']) {
11+
package { 'openldap-clients': ensure => installed }
12+
}
13+
}
14+
'Debian': {
15+
if ! defined(Package['libnss-sss']) {
16+
package { 'libnss-sss': ensure => installed }
17+
}
18+
if ! defined(Package['libpam-sss']) {
19+
package { 'libpam-sss': ensure => installed }
20+
}
21+
if ! defined(Package['ldap-utils']) {
22+
package { 'ldap-utils': ensure => installed }
23+
}
24+
}
1725
}
1826
}
19-
20-
class pamldap::install::centos inherits pamldap::install::redhat {
21-
# No changes
22-
}
23-
24-
class pamldap::install::ubuntu inherits pamldap::install::common {
25-
if ! defined(Package['libnss-sss']) {
26-
package { 'libnss-sss': ensure => installed }
27-
}
28-
if ! defined(Package['libpam-sss']) {
29-
package { 'libpam-sss': ensure => installed }
30-
}
31-
if ! defined(Package['ldap-utils']) {
32-
package { 'ldap-utils': ensure => installed }
33-
}
34-
}

0 commit comments

Comments
 (0)