Defined Type: dmlite::limits

Defined in:
manifests/limits.pp

Overview

Parameters:

  • domain (Any) (defaults to: 'root')
  • type (Any) (defaults to: 'soft')
  • item (Any) (defaults to: 'nofile')
  • value (Any) (defaults to: '10000')


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'manifests/limits.pp', line 1

define dmlite::limits (
  $domain = 'root',
  $type = 'soft',
  $item = 'nofile',
  $value = '10000'
) {

  # guid of this entry
  $key = "${domain}/${type}/${item}"

  $context = '/files/etc/security/limits.d/90-nproc.conf'

  $path_list  = "domain[.=\"${domain}\"][./type=\"${type}\" and ./item=\"${item}\"]"
  $path_exact = "domain[.=\"${domain}\"][./type=\"${type}\" and ./item=\"${item}\" and ./value=\"${value}\"]"

  augeas { "limits_conf/${key}":
    context => $context,
    onlyif  => "match ${path_exact} size != 1",
    changes => [
      # remove all matching to the $domain, $type, $item, for any $value
      "rm ${path_list}",
      # insert new node at the end of tree
      "set domain[last()+1] ${domain}",
      # assign values to the new node
      "set domain[last()]/type ${type}",
      "set domain[last()]/item ${item}",
      "set domain[last()]/value ${value}",
    ],
  }

}