Puppet Class: pam::limits

Defined in:
manifests/limits.pp

Summary

Manage PAM limits.conf

Overview

Examples:

This class is included by the pam class for platforms which use it.

Parameters:

  • config_file (Stdlib::Absolutepath) (defaults to: '/etc/security/limits.conf')

    Path to limits.conf.

  • config_file_mode (Stdlib::Filemode) (defaults to: '0640')

    Mode for config_file.

  • config_file_lines (Optional[Array]) (defaults to: undef)

    Ordered array of limits that should be placed into limits.conf. Useful for Suse 10 which does not use limits.d.

  • config_file_source (Optional[String]) (defaults to: undef)

    String with source path to a limits.conf

  • limits_d_dir (Stdlib::Absolutepath) (defaults to: '/etc/security/limits.d')

    Path to limits.d directory.

  • limits_d_dir_mode (Stdlib::Filemode) (defaults to: '0750')

    Mode for limits_d_dir.

  • purge_limits_d_dir (Boolean) (defaults to: false)

    Boolean to purge the limits.d directory.

  • purge_limits_d_dir_ignore (Optional[Variant[String[1], Array[String[1]]]]) (defaults to: undef)

    A glob or array of file names to ignore when purging limits.d



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
# File 'manifests/limits.pp', line 31

class pam::limits (
  Stdlib::Absolutepath $config_file    = '/etc/security/limits.conf',
  Optional[Array] $config_file_lines   = undef,
  Optional[String] $config_file_source = undef,
  Stdlib::Filemode $config_file_mode   = '0640',
  Stdlib::Absolutepath $limits_d_dir   = '/etc/security/limits.d',
  Stdlib::Filemode $limits_d_dir_mode  = '0750',
  Boolean $purge_limits_d_dir          = false,
  Optional[Variant[String[1], Array[String[1]]]] $purge_limits_d_dir_ignore = undef,
) {
  include pam

  if $config_file_lines or $config_file_source {
    # config_file_lines takes priority over config_file_source
    if $config_file_lines {
      $config_file_source_real = undef
      $content = template('pam/limits.conf.erb')
    } else {
      $content = undef
      $config_file_source_real = $config_file_source
    }
  } else {
    $content = template('pam/limits.conf.erb')
    $config_file_source_real = undef
  }
  if $facts['os']['family'] == 'Suse' and $facts['os']['release']['major'] == '10' {
    # do nothing
  } else {
    exec { "mkdir_p-${limits_d_dir}":
      command => "mkdir -p ${limits_d_dir}",
      unless  => "test -d ${limits_d_dir}",
      path    => '/bin:/usr/bin',
    }

    file { 'limits_d':
      ensure  => directory,
      path    => $limits_d_dir,
      owner   => 'root',
      group   => 'root',
      mode    => $limits_d_dir_mode,
      purge   => $purge_limits_d_dir,
      recurse => $purge_limits_d_dir,
      ignore  => $purge_limits_d_dir_ignore,
      require => [
        Package[$pam::package_name],
        Exec["mkdir_p-${limits_d_dir}"],
      ],
    }
  }

  file { 'limits_conf':
    ensure  => file,
    path    => $config_file,
    source  => $config_file_source_real,
    content => $content,
    owner   => 'root',
    group   => 'root',
    mode    => $config_file_mode,
    require => Package[$pam::package_name],
  }
}