Merge pull request #18 from natemccurdy/param_types

Improve the class parameters and switch to proper containment
This commit is contained in:
Geekix 2019-03-10 10:28:11 +01:00 committed by GitHub
commit 498adf96f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 75 deletions

View File

@ -2,49 +2,40 @@
# #
# This class manages the nslcd server and service. # This class manages the nslcd server and service.
class nslcd ( class nslcd (
$package_ensure = $nslcd::params::package_ensure, Variant[Boolean,String[1]] $package_ensure = 'present',
$package_name = $nslcd::params::package_name, String[1] $package_name = $nslcd::params::package_name,
$package_manage = $nslcd::params::package_manage, Boolean $package_manage = true,
$service_ensure = $nslcd::params::service_ensure, Variant[Boolean,Enum['stopped','running']] $service_ensure = 'running',
$service_enable = $nslcd::params::service_enable, Boolean $service_enable = true,
$service_name = $nslcd::params::service_name, String[1] $service_name = 'nslcd',
$service_manage = $nslcd::params::service_manage, Boolean $service_manage = true,
$uid = $nslcd::params::uid, String[1] $uid = 'nslcd',
$gid = $nslcd::params::gid, String[1] $gid = $nslcd::params::gid,
$config = $nslcd::params::config, Stdlib::Unixpath $config = '/etc/nslcd.conf',
$config_user = $nslcd::params::config_user, String[1] $config_user = 'root',
$config_group = $nslcd::params::config_group, String[1] $config_group = $nslcd::params::config_group,
$config_mode = $nslcd::params::config_mode, Stdlib::Filemode $config_mode = $nslcd::params::config_mode,
$ldap_uris = $nslcd::params::ldap_uris, Array[String[1]] $ldap_uris = ['ldap:///'],
$ldap_version = $nslcd::params::ldap_version, Enum['2','3'] $ldap_version = '3',
$ldap_binddn = $nslcd::params::ldap_binddn, Optional[String[1]] $ldap_binddn = undef,
$ldap_bindpw = $nslcd::params::ldap_bindpw, Optional[String[1]] $ldap_bindpw = undef,
$ldap_search_base = $nslcd::params::ldap_search_base, Optional[String[1]] $ldap_search_base = undef,
$ldap_group_base = $nslcd::params::ldap_group_base, Optional[String[1]] $ldap_group_base = undef,
$ldap_search_scope = $nslcd::params::ldap_search_scope, Enum['sub','subtree','one','onelevel','base'] $ldap_search_scope = 'subtree',
$config_options = $nslcd::params::config_options, Hash $config_options = {},
$ldap_filters = $nslcd::params::ldap_filters, Hash $ldap_filters = {},
$ldap_maps = $nslcd::params::ldap_maps, Hash $ldap_maps = {},
$ldap_ssl = $nslcd::params::ldap_ssl, Enum['on','off','start_tls'] $ldap_ssl = 'off',
$ldap_tls_reqcert = $nslcd::params::ldap_tls_reqcert, Enum['never','allow','try','demand','hard' ] $ldap_tls_reqcert = 'allow',
$ldap_tls_cacertfile = $nslcd::params::ldap_tls_cacertfile, Optional[String[1]] $ldap_tls_cacertfile = undef,
) inherits nslcd::params { ) inherits nslcd::params {
# Input validation contain nslcd::install
$valid_ldap_versions = [ '2', '3' ] contain nslcd::config
$valid_ldap_ssl = [ 'on', 'off', 'start_tls' ] contain nslcd::service
$valid_ldap_tls_reqcert = [ 'never', 'allow', 'try', 'demand', 'hard' ]
$valid_ldap_search_scope = [ 'sub', 'subtree', 'one', 'onelevel', 'base' ]
validate_re($ldap_version, $valid_ldap_versions) Class['nslcd::install']
validate_re($ldap_ssl, $valid_ldap_ssl) -> Class['nslcd::config']
validate_re($ldap_tls_reqcert, $valid_ldap_tls_reqcert) ~> Class['nslcd::service']
validate_re($ldap_search_scope, $valid_ldap_search_scope)
anchor { 'nslcd::begin': }
-> class { 'nslcd::install': }
-> class { 'nslcd::config': }
~> class { 'nslcd::service': }
-> anchor { 'nslcd::end': }
} }

View File

@ -3,48 +3,16 @@
# Sets the default parameters for the nslcd class. # Sets the default parameters for the nslcd class.
class nslcd::params { class nslcd::params {
$package_ensure = present
$package_manage = true
$service_ensure = running
$service_enable = true
$service_manage = true
$ldap_uris = ['ldap:///']
$ldap_version = '3'
$ldap_binddn = undef
$ldap_bindpw = undef
$ldap_search_base = undef
$ldap_group_base = undef
$ldap_search_scope = 'subtree'
$config_options = {}
$ldap_filters = {}
$ldap_maps = {}
$ldap_ssl = 'off'
$ldap_tls_reqcert = 'allow'
$ldap_tls_cacertfile = undef
$default_config = '/etc/nslcd.conf'
$default_package_name = 'nslcd'
$default_service_name = 'nslcd'
case $::osfamily { case $::osfamily {
'Debian': { 'Debian': {
$config = $default_config $package_name = 'nslcd'
$package_name = $default_package_name
$service_name = $default_service_name
$uid = 'nslcd'
$gid = 'nslcd' $gid = 'nslcd'
$config_user = 'root'
$config_group = 'nslcd' $config_group = 'nslcd'
$config_mode = '0640' $config_mode = '0640'
} }
'RedHat': { 'RedHat': {
$config = $default_config
$package_name = 'nss-pam-ldapd' $package_name = 'nss-pam-ldapd'
$service_name = $default_service_name
$uid = 'nslcd'
$gid = 'ldap' $gid = 'ldap'
$config_user = 'root'
$config_group = 'root' $config_group = 'root'
$config_mode = '0600' $config_mode = '0600'
} }