]> git.donarmstrong.com Git - dsa-puppet.git/blob - modules/site/manifests/limit.pp
Only sync logs once per day since we are only transferring rotated logs
[dsa-puppet.git] / modules / site / manifests / limit.pp
1 # == Define: site::limit
2 #
3 # Apply a ulimit for a particular user on this system. Most commonly used for
4 # increasing the number of open files that are allowed on the system.
5 #
6 # === Parameters
7 #
8 # [*limit_user*]
9 #   The user account to apply the limit to. Can also be a group, see
10 #   http://linux.die.net/man/5/limits.conf or the manual page for limits.conf
11 #   for details.
12 #
13 # [*limit_value*]
14 #   The number that this limit should be increased to.
15 #
16 # [*limit_type*]
17 #   Whether the limit is hard, soft, or '-'.
18 #
19 # [*limit_item*]
20 #   The item to apply the limit to. See http://linux.die.net/man/5/limits.conf
21 #   or the manual page for limits.conf for something accurate for a specific
22 #   OS. This defaults to nofile as this is the most commonly changed limit.
23 #
24 # === Examples
25 #
26 #  site::limit { 'a_jetty_app':
27 #    limit_user => jetty,
28 #    #limit_type => nofile # this is the default so commented out
29 #    limit_type  => hard
30 #    limit_value => 8192
31 #  }
32 #
33 define site::limit (
34         $limit_user,
35         $limit_value,
36         $limit_type = '-',
37         $limit_item = 'nofile',
38         $ensure = 'present'
39 ) {
40
41         case $limit_item {
42                 'as': {}
43                 'chroot': {}
44                 'core': {}
45                 'cpu': {}
46                 'data': {}
47                 'fsize': {}
48                 'locks': {}
49                 'maxlogins': {}
50                 'maxsyslogins': {}
51                 'memlock': {}
52                 'msgqueue': {}
53                 'nice': {}
54                 'nofile': {}
55                 'nproc': {}
56                 'priority': {}
57                 'rss': {}
58                 'rtprio': {}
59                 'sigpending': {}
60                 'stack': {}
61                 default: {
62                         fail("${limit_item} is not a valid ulimit item")
63                 }
64         }
65
66         case $limit_type {
67                 '-': {}
68                 'soft': {}
69                 'hard': {}
70                 default: {
71                         fail("${limit_item} is not a valid ulimit type")
72                 }
73         }
74
75         file { "/etc/security/limits.d/${name}.conf":
76                 ensure  => $ensure,
77                 content => template('site/limits.conf.erb'),
78                 owner   => root,
79                 group   => root,
80                 mode    => '0444'
81         }
82
83 }