Puppet Class: pam::limits
- Defined in:
- manifests/limits.pp
Overview
Class: pam::limits
This module manages the pam_limits.so module for PAM. The pam_limits PAM module sets limits on the system resources that can be obtained in a user-session.
Parameters
- ensure
-
Controls the software installation Valid values:
present
,absent
- change_uid
-
Change real uid to the user for who the limits are set up. Use this option if you have problems like login not forking a shell for user who has no processes. Be warned that something else may break when you do this. Valid values:
true
,false
- conf
-
Indicate an alternative limits.conf style configuration file to override the default Valid values:
/path/to/limits.conf
- conf_d
-
Path to limits.d directory containing individual conf files It is not clear in the man page of pam_limits how this directory is determined so until further testing has been done this should probably be used with caution (as in - providing another value rather than default). Valid values:
/path/to/limits.d
- purge_conf_d
-
Determines if Puppet should discard any foreign files found in the conf_d directory Valid values:
true
,false
- debug
-
Print debug information Valid values:
true
,false
- noaudit
-
Do not report logins from disallowed hosts and ttys to the audit subsystem Valid values:
true
,false
- utmp_early
-
Some broken applications actually allocate a utmp entry for the user before the user is admitted to the system. If some of the services you are configuring PAM for do this, you can selectively use this module argument to compensate for this behavior and at the same time maintain system-wide consistency with a single limits.conf file. Valid values:
true
,false
- source
-
Pam limits.conf file source Valid values:
puppet:///modules/mymodule/path/to/file.conf
- content
-
Pam limits.conf file content
- source_d
-
Path to source directory for conf_d Valid values:
puppet:///modules/mymodules/path/to/dir
Sample Usage
-
Installing with default settings class { ‘pam::limits’: }
-
Uninstalling the software class { ‘pam::limits’: ensure => absent }
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 |
# File 'manifests/limits.pp', line 74
class pam::limits (
$ensure = 'present',
$change_uid = 'UNDEF',
$conf = 'UNDEF',
$conf_d = 'UNDEF',
$purge_conf_d = 'UNDEF',
$debug = 'UNDEF',
$noaudit = 'UNDEF',
$utmp_early = 'UNDEF',
$source = 'UNDEF',
$content = 'UNDEF',
$source_d = 'UNDEF'
) {
include pam
include pam::params
# puppet 2.6 compatibility
$change_uid_real = $change_uid ? {
'UNDEF' => $pam::params::limits_change_uid,
default => $change_uid
}
$conf_real = $conf ? {
'UNDEF' => $pam::params::limits_conf,
default => $conf
}
$conf_d_real = $conf_d ? {
'UNDEF' => $pam::params::limits_conf_d,
default => $conf_d
}
$purge_conf_d_real = $purge_conf_d ? {
'UNDEF' => $pam::params::limits_purge_conf_d,
default => $purge_conf_d
}
$debug_real = $debug ? {
'UNDEF' => $pam::params::limits_debug,
default => $debug
}
$noaudit_real = $noaudit ? {
'UNDEF' => $pam::params::limits_noaudit,
default => $noaudit
}
$utmp_early_real = $utmp_early ? {
'UNDEF' => $pam::params::limits_utmp_early,
default => $utmp_early
}
$source_real = $source ? {
'UNDEF' => $pam::params::limits_source,
default => $source,
}
$content_real = $content ? {
'UNDEF' => $pam::params::limits_template ? {
'' => '',
default =>template($pam::params::limits_template),
},
default => $content
}
$source_d_real = $source_d ? {
'UNDEF' => $pam::params::limits_source_d,
default => $source_d
}
# Input validation
validate_re($ensure, $pam::params::valid_ensure_values)
validate_bool($debug_real)
validate_bool($noaudit_real)
validate_bool($change_uid_real)
validate_bool($utmp_early_real)
validate_bool($purge_conf_d_real)
# Sanitized string builder variables
# for pam_access.so options
$conf_entry = " conf=${conf_real}"
$change_uid_entry = $change_uid_real ? {
true => ' change_uid',
false => '',
}
$debug_entry = $debug_real ? {
true => ' debug',
false => '',
}
$noaudit_entry = $noaudit_real ? {
true => ' noaudit',
false => '',
}
$utmp_early_entry = $utmp_early_real ? {
true => ' utmp_early',
false => ''
}
$pam_limits_parameters = "${conf_entry}${change_uid_entry}${debug_entry}${noaudit_entry}${utmp_early_entry}"
# Debuntu uses pam-auth-update to build pam configuration
case $::operatingsystem {
'Ubuntu', 'Debian': {
file { 'pam_auth_update_limits_file':
ensure => $ensure,
path => $pam::params::pam_auth_update_limits_file,
owner => root,
group => root,
mode => '0644',
content => template($pam::params::pam_auth_update_limits_tmpl),
notify => Exec['pam_auth_update']
}
}
default: { }
}
case $ensure {
present: {
if $source_real != '' {
File['pam_limits_conf'] {
source => $source_real
}
}
elsif $content_real != '' {
File['pam_limits_conf'] {
content => $content_real
}
}
if $purge_conf_d_real {
File['pam_limits_conf_d'] {
purge => true,
force => true,
recurse => true
}
}
if $source_d_real != undef {
File['pam_limits_conf_d'] {
source => $source_d_real
}
}
file { 'pam_limits_conf':
ensure => present,
path => $conf_real,
owner => 'root',
group => 'root',
mode => '0644'
}
file { 'pam_limits_conf_d':
ensure => directory,
path => $conf_d_real,
owner => 'root',
group => 'root',
mode => '0644',
}
File <| tag == 'pam_limits_conf_d' |>
}
default: {
# Don't know how to best unmanage the limits.conf file
# This section would 'reset' it in case it
# finds # MANAGED BY PUPPET in the file
exec { 'insert_blank_access_conf_file':
command => "echo '## UNMANAGED FILE' > ${conf_real}",
onlyif => "grep '^# MANAGED BY PUPPET' ${conf_real} >/dev/null",
path => [ '/bin', '/sbin', '/usr/bin', '/usr/sbin' ]
}
}
}
}
|