Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/puppet/provider/sysctl/augeas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
Puppet::Type.type(:sysctl).provide(:augeas, parent: Puppet::Type.type(:augeasprovider).provider(:default)) do
desc 'Uses Augeas API to update sysctl settings'

default_file { '/etc/sysctl.conf' }
default_file do
if Facter.value(:os)['name'] == 'Debian' && Facter.value(:os)['release']['major'].to_i >= 13
'/etc/sysctl.d/99-puppet.conf'
else
'/etc/sysctl.conf'
end
end

lens { 'Sysctl.lns' }

Expand Down
25 changes: 16 additions & 9 deletions spec/acceptance/sysctl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
describe 'Sysctl Tests' do
hosts.each do |host|
context "on #{host}" do
let(:sysctl_conf) do
if fact_on(host, 'os.name') == 'Debian' && (fact_on(host, 'os.release.major') || '0').to_i >= 13
'/etc/sysctl.d/99-puppet.conf'
else
'/etc/sysctl.conf'
end
end
context 'file based updates' do
let(:manifest) do
<<-EOM
Expand All @@ -28,7 +35,7 @@
result = on(host, 'sysctl -n fs.nr_open').stdout.strip
expect(result).not_to eql('100000')

on(host, 'sysctl -p', accept_all_exit_codes: true)
on(host, "sysctl -p #{sysctl_conf}", accept_all_exit_codes: true)
result = on(host, 'sysctl -n fs.nr_open').stdout.strip
expect(result).to eql('100000')
end
Expand Down Expand Up @@ -131,8 +138,8 @@
apply_manifest_on(host, manifest, { catch_changes: true })
end

it 'is not in /etc/sysctl.conf' do
expect(file_contents_on(host, '/etc/sysctl.conf')).not_to match(%r{kernel\.pty\.max})
it 'is not in default config file' do
expect(file_contents_on(host, sysctl_conf)).not_to match(%r{kernel\.pty\.max})
end
end

Expand All @@ -157,8 +164,8 @@
apply_manifest_on(host, manifest, { catch_changes: true })
end

it 'is in /etc/sysctl.conf' do
expect(file_contents_on(host, '/etc/sysctl.conf')).to match(%r{kernel\.pty\.max = 4098})
it 'is in default config file' do
expect(file_contents_on(host, sysctl_conf)).to match(%r{kernel\.pty\.max = 4098})
end

it 'is not changed on the running system' do
Expand All @@ -185,8 +192,8 @@
apply_manifest_on(host, manifest, { catch_changes: true })
end

it 'is not in /etc/sysctl.conf' do
expect(file_contents_on(host, '/etc/sysctl.conf')).not_to match(%r{kernel\.pty\.max})
it 'is not in default config file' do
expect(file_contents_on(host, sysctl_conf)).not_to match(%r{kernel\.pty\.max})
end

it 'is not changed on the running system' do
Expand Down Expand Up @@ -225,8 +232,8 @@
end

it 'has correct file contents' do
expect(file_contents_on(host, '/etc/sysctl.conf')).to match(%r{fs\.nr_open = 100002})
expect(file_contents_on(host, '/etc/sysctl.conf')).not_to match(%r{fs\.inotify\.max_user_watches})
expect(file_contents_on(host, sysctl_conf)).to match(%r{fs\.nr_open = 100002})
expect(file_contents_on(host, sysctl_conf)).not_to match(%r{fs\.inotify\.max_user_watches})
expect(file_contents_on(host, '/etc/sysctl.d/20-fs.conf')).to match(%r{fs\.nr_open = 100001})
expect(file_contents_on(host, '/etc/sysctl.d/20-fs.conf')).to match(%r{fs\.inotify\.max_user_watches = 8193})
end
Expand Down
Loading