|
35 | 35 |
|
36 | 36 | describe file('/etc/security/limits.d/user_nofile.conf') do |
37 | 37 | it { is_expected.to be_file } |
38 | | - it { is_expected.to contain 'user - nofile 12345' } |
| 38 | + it { is_expected.to contain "# Managed by Puppet\n\n#<domain> <type> <item> <value>\nuser - nofile 12345" } |
| 39 | + end |
| 40 | + end |
| 41 | + |
| 42 | + context 'with target specified managed file' do |
| 43 | + it 'create a puppet managed file' do |
| 44 | + pp = <<-PP |
| 45 | + limits::limits { 'item': |
| 46 | + user => 'user', |
| 47 | + limit_type => 'nofile', |
| 48 | + both => 12345, |
| 49 | + target => '00-item.conf' |
| 50 | + } |
| 51 | + PP |
| 52 | + |
| 53 | + # Run it twice and test for idempotency |
| 54 | + apply_manifest(pp, catch_failures: true) |
| 55 | + expect(apply_manifest(pp, catch_failures: true).exit_code).to be_zero |
| 56 | + end |
| 57 | + |
| 58 | + describe file('/etc/security/limits.d/00-item.conf') do |
| 59 | + it { is_expected.to be_file } |
| 60 | + it { is_expected.to contain "# Managed by Puppet\n\n#<domain> <type> <item> <value>\nuser - nofile 12345" } |
| 61 | + end |
| 62 | + end |
| 63 | + |
| 64 | + context 'with multiple target specified managed limit' do |
| 65 | + it 'create a puppet managed file' do |
| 66 | + pp = <<-PP |
| 67 | + limits::limits { 'item': |
| 68 | + user => 'user', |
| 69 | + limit_type => 'nofile', |
| 70 | + both => 12345, |
| 71 | + target => '00-item.conf' |
| 72 | + } |
| 73 | +
|
| 74 | + limits::limits { 'item2': |
| 75 | + user => 'other_user', |
| 76 | + limit_type => 'nproc', |
| 77 | + both => 54321, |
| 78 | + target => '00-item.conf' |
| 79 | + } |
| 80 | + PP |
| 81 | + |
| 82 | + # Run it twice and test for idempotency |
| 83 | + apply_manifest(pp, catch_failures: true) |
| 84 | + expect(apply_manifest(pp, catch_failures: true).exit_code).to be_zero |
| 85 | + end |
| 86 | + |
| 87 | + describe file('/etc/security/limits.d/00-item.conf') do |
| 88 | + it { is_expected.to be_file } |
| 89 | + it { is_expected.to contain "# Managed by Puppet\n\n#<domain> <type> <item> <value>\nuser - nofile 12345\nother_user - nproc 54321\n" } |
39 | 90 | end |
40 | 91 | end |
41 | 92 | end |
0 commit comments