Open HanzzM opened 7 years ago
This only happens when I use comment. There are no problems when I leave the comment option out off my code.
sysctl { 'net.ipv4.tcp_syncookies':
ensure => present,
value => '1',
target => '/etc/sysctl.d/90-net.conf',
}
sysctl { 'kernel.panic':
ensure => present,
value => '20',
target => '/etc/sysctl.d/90-kernel.conf',
}
This happens to us, but only if we specify the tart as /etc/sysctl.d/99-sysctl.conf We also have multiple settings going into the file, don't know if that is contributing to the problem.
I've determined this issue is due to these lines: https://github.com/voxpupuli/puppet-augeasproviders_sysctl/blob/78c2bcb9cdab9743152cc973d364e8997bd94420/lib/puppet/provider/sysctl/augeas.rb#L192-L194
When I comment out line 194 (aug.insert
) the comment is updated correctly.
After some testing, I found two options:
first puppet run:
vm.min_free_kbytes = 67584
#kernel.kptr_restrict = 0
kernel.kptr_restrict = 2
# net.ipv4.tcp_invalid_ratelimit: networking tuning
net.ipv4.tcp_invalid_ratelimit = 500
# kernel.kptr_restrict: hiding kernel pointers
second puppet run:
vm.min_free_kbytes = 67584
#kernel.kptr_restrict = 0
# kernel.kptr_restrict: hiding kernel pointers
kernel.kptr_restrict = 2
# net.ipv4.tcp_invalid_ratelimit: networking tuning
net.ipv4.tcp_invalid_ratelimit = 500
# kernel.kptr_restrict: hiding kernel pointers
augopen! do |aug|
if aug.match(resource_path).empty?
# Prefer to create the node next to a commented out entry
commented = aug.match("$target/#comment[.=~regexp('#{resource[:name]}([^a-z\.].*)?')]")
aug.insert(commented.first, resource[:name], false) unless commented.empty?
end
aug.set(resource_path, value)
setvars(aug)
end
I get this error when I use more than one target files. And after changing the value or the comment in the last file (/etc/sysctl.d/90-kernel.conf).
Example code:
The first puppet agent run is going well. But after changing the code (value of kernel.panic changed from 20 into 30):
I get the messages:
It works only when I also chang the order from my code ( move the changing part to the top ) into:
Now the Puppet agent run is going well again: