File tree Expand file tree Collapse file tree 10 files changed +95
-65
lines changed
Expand file tree Collapse file tree 10 files changed +95
-65
lines changed Original file line number Diff line number Diff line change @@ -4,20 +4,19 @@ script: 'bundle exec metadata-json-lint metadata.json && bundle exec rake valida
44matrix :
55 fast_finish : true
66 include :
7- - rvm : 1.9.3
8- env : PUPPET_GEM_VERSION="~> 3" STRICT_VARIABLES="yes"
9- - rvm : 1.9.3
10- env : PUPPET_GEM_VERSION="~> 3" STRICT_VARIABLES="yes" FUTURE_PARSER="yes"
11- - rvm : 2.1
12- env : PUPPET_GEM_VERSION="~> 3" STRICT_VARIABLES="yes"
13- - rvm : 2.1
14- env : PUPPET_GEM_VERSION="~> 3" STRICT_VARIABLES="yes" FUTURE_PARSER="yes"
15- - rvm : 2.2
16- env : PUPPET_GEM_VERSION="~> 4" STRICT_VARIABLES="yes"
17- - rvm : 2.3.1
18- env : PUPPET_GEM_VERSION="~> 4" STRICT_VARIABLES="yes"
19- - rvm : 2.3.1
20- env : PUPPET_GEM_VERSION="~> 4" STRICT_VARIABLES="yes" FORGEDEPLOY=true
7+ - rvm : 2.1.9
8+ env : PUPPET_VERSION="~> 4.9.0" STRICT_VARIABLES="yes"
9+ - rvm : 2.1.9
10+ env : PUPPET_VERSION="~> 4.10.0" STRICT_VARIABLES="yes"
11+ - rvm : 2.4.1
12+ env : PUPPET_VERSION="~> 5.0.0" STRICT_VARIABLES="yes"
13+ - rvm : 2.4.1
14+ env : PUPPET_VERSION="~> 5.1.0" STRICT_VARIABLES="yes"
15+ - rvm : 2.4.1
16+ env : PUPPET_VERSION="~> 5.2.0" STRICT_VARIABLES="yes"
17+ - rvm : 2.4.1
18+ env : PUPPET_VERSION="~> 5.3.0" STRICT_VARIABLES="yes" FORGEDEPLOY=true
19+
2120notifications :
2221 email : false
2322deploy :
Original file line number Diff line number Diff line change @@ -19,6 +19,20 @@ It creates files in `/etc/security/limits.d` and does not manage the file `/etc/
1919 limits::limits{'root/nofile': both => 1048576; }
2020```
2121
22+ ### Parameters
23+
24+ * ` purge_limits_d_dir ` (Boolean, default: true) Whether or not to purge the limits.d directory
25+ * ` manage_limits_d_dir ` (Boolean, default: true) Whether or not to manage the limits.d directory
26+ * ` limits_dir ` : (String) The location of the limits.d directory
27+ * ` entries ` : (Hash) A hash of limits entries, keys should be the name and the value as a hash made up of;
28+ * ` ensure ` : (String, default present) Values can be absent or present
29+ * ` user ` : (String) The user that the limit applies to
30+ * ` limit_type ` (String) The limit type
31+ * ` hard ` : (Integer) the hard value
32+ * ` soft ` : (Integer) the soft value
33+ * ` both ` : (Integer) the value of both soft and hard
34+
35+
2236### Using hiera
2337
2438Puppet:
@@ -39,9 +53,23 @@ Hiera:
3953
4054## Compatibility
4155
42- This module has been tested to work with Puppet v3 (with and without the future
43- parser) and v4 with Ruby versions 1.8.7 (Puppet v3 only), 1.9.3, 2.0.0 and
44- 2.1.0.
56+ ### Puppet 4.9+
57+
58+ This module is compatible with Puppet 4.9+, and Puppet 5.0+
59+
60+ ### Puppet 4.0 - 4.8
61+
62+ To use this module with previous versions of Puppet 4 (prior to Hiera 5) you should update your Hiera data to include the following
63+
64+ ` ` ` yaml
65+ ---
66+ limits::limits_dir : /etc/security/limits.d
67+
68+ lookup_options :
69+ limits::entries :
70+ merge : deep
71+ ` ` `
72+
4573
4674### Purge limits.d directory
4775
Original file line number Diff line number Diff line change 1+ ---
2+ limits::limits_dir : /etc/security/limits.d
3+
4+ lookup_options :
5+ limits::entries :
6+ merge : deep
Original file line number Diff line number Diff line change 1+ ---
2+ version : 5
3+ defaults :
4+ datadir : data
5+ data_hash : yaml_data
6+ hierarchy :
7+ - name : " common"
8+ path : " common.yaml"
Original file line number Diff line number Diff line change 11# == Class: limits
22#
33class limits (
4- $purge_limits_d_dir = true ,
5- $entries_hash = hiera_hash(limits::entries, {}),
6- $manage_limits_d_dir = true ,
7- ) inherits ::limits::params {
4+ String $limits_dir,
5+ Boolean $purge_limits_d_dir = true ,
6+ Boolean $manage_limits_d_dir = true ,
7+ Hash $entries = {},
8+ ) {
89
9- if $manage_limits_d_dir == true {
10- file { $limits::params:: limits_dir :
10+ if $manage_limits_d_dir {
11+ file { $limits_dir:
1112 ensure => ' directory' ,
1213 owner => ' root' ,
1314 group => ' root' ,
1819 }
1920
2021 # ## Create instances for integration with Hiera
21- if $entries_hash != {} {
22- validate_hash($entries_hash )
23- create_resources(limits::limits, $entries_hash )
22+
23+ $entries .each | String $e_name , Hash $e_params | {
24+ limits::limits { $e_name:
25+ * => $e_params ,
26+ }
2427 }
28+
2529}
Original file line number Diff line number Diff line change 1818# Manages:
1919# limit file in limits.d with the values provided
2020define limits::limits (
21- $ensure = present ,
22- $user = undef ,
23- $limit_type = undef ,
24- $hard = undef ,
25- $soft = undef ,
26- $both = undef ,
21+ Enum['absent', 'present'] $ensure = present ,
22+ Optional[String] $user = undef ,
23+ Optional[String] $limit_type = undef ,
24+ Optional[Integer] $hard = undef ,
25+ Optional[Integer] $soft = undef ,
26+ Optional[Integer] $both = undef ,
2727) {
2828
2929 include ::limits
4545 }
4646
4747 if $title =~ /\.conf$/ {
48- $target_file = " ${limits::params:: limits_dir} /${title} "
48+ $target_file = " ${limits::limits_dir} /${title} "
4949 } else {
5050 if $real_user == ' *' {
51- $target_file = " ${limits::params:: limits_dir} /default_${real_type} .conf"
51+ $target_file = " ${limits::limits_dir} /default_${real_type} .conf"
5252 } else {
53- $target_file = " ${limits::params:: limits_dir} /${real_user} _${real_type} .conf"
53+ $target_file = " ${limits::limits_dir} /${real_user} _${real_type} .conf"
5454 }
5555 }
5656
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 3232 }
3333 ],
3434 "requirements" : [
35- {
36- "name" : " pe" ,
37- "version_requirement" : " >= 3.2.0 < 5.0.0"
38- },
3935 {
4036 "name" : " puppet" ,
41- "version_requirement" : " >= 3 .0.0 < 5 .0.0"
37+ "version_requirement" : " >= 4 .0.0 < 6 .0.0"
4238 }
4339 ],
4440 "dependencies" : [
Original file line number Diff line number Diff line change 3636
3737 describe "on supported osfamily: #{ osfamily } " do
3838
39- it { should contain_class ( 'limits::params' ) }
4039
4140 it do
4241 if params [ :manage_limits_d_dir ] == false
Original file line number Diff line number Diff line change 1414 :user => 'username' ,
1515 :limit_type => 'nofile' ,
1616 :ensure => 'present' ,
17- :hard => ' 16384' ,
18- :soft => ' 16384'
17+ :hard => 16384 ,
18+ :soft => 16384
1919 }
2020 end
2121
2626 :user => 'username' ,
2727 :limit_type => 'nofile' ,
2828 :ensure => 'present' ,
29- :hard => ' 16384' ,
30- :soft => ' 16384'
29+ :hard => 16384 ,
30+ :soft => 16384
3131 } )
3232 }
3333 it { should contain_file ( filename ) . with ( {
4545 :user => 'username' ,
4646 :limit_type => 'nofile' ,
4747 :ensure => 'present' ,
48- :hard => ' 16384' ,
49- :soft => ' 16384'
48+ :hard => 16384 ,
49+ :soft => 16384
5050 } )
5151 }
5252 it { should contain_file ( filename ) . with ( {
6464 :user => 'username' ,
6565 :limit_type => 'nofile' ,
6666 :ensure => 'absent' ,
67- :hard => ' 16384' ,
68- :soft => ' 16384'
67+ :hard => 16384 ,
68+ :soft => 16384
6969 }
7070 end
7171 it { should contain_file ( filename ) . with ( {
8484 :user => 'username' ,
8585 :limit_type => 'nofile' ,
8686 :ensure => 'present' ,
87- :both => ' 16384'
87+ :both => 16384
8888 }
8989 end
9090 let ( :title ) { 'username_nofile.conf' }
9191 it { should contain_limits__limits ( 'username_nofile.conf' ) . with ( {
9292 :user => 'username' ,
9393 :limit_type => 'nofile' ,
9494 :ensure => 'present' ,
95- :both => ' 16384'
95+ :both => 16384
9696 } )
9797 }
9898 it { should contain_file ( filename ) . with ( {
110110 let ( :title ) { '*/nofile' }
111111 let :params do
112112 {
113- :both => ' 16384'
113+ :both => 16384
114114 }
115115 end
116116 it { should compile . with_all_deps }
127127 let ( :title ) { 'root/nofile' }
128128 let :params do
129129 {
130- :hard => ' 12345'
130+ :hard => 12345
131131 }
132132 end
133133 it { should contain_file ( '/etc/security/limits.d/root_nofile.conf' ) . with ( {
146146 let :params do
147147 {
148148 :limit_type => 'nofile' ,
149- :both => ' 16384'
149+ :both => 16384
150150 }
151151 end
152152 it { should compile . and_raise_error ( /when not using the title pattern/ ) }
156156 let :params do
157157 {
158158 :user => 'foo' ,
159- :both => ' 16384'
159+ :both => 16384
160160 }
161161 end
162162 it { should compile . and_raise_error ( /when not using the title pattern/ ) }
You can’t perform that action at this time.
0 commit comments