voxpupuli / puppet-augeasproviders_sysctl

Augeas-based sysctl type and provider for Puppet
Apache License 2.0
10 stars 36 forks source link

Error: `net.inet.ip.forwarding` is not a valid sysctl key on FreeBSD 11.x -- patch included #24

Closed da125 closed 5 years ago

da125 commented 6 years ago

Hello team,

While using augeasproviders_sysctl for a FreeBSD 11.1 amd64 node with zleslie/bsd module, I came across this issue:

Error: /Stage[main]/Bsd::Network/Sysctl[net.inet.ip.forwarding]: Could not evaluate: Error: net.inet.ip.forwarding is not a valid sysctl key Error: /Stage[main]/Bsd::Network/Sysctl[net.inet6.ip6.forwarding]: Could not evaluate: Error: net.inet6.ip6.forwarding is not a valid sysctl key

This is caused by the fact that the FreeBSD sysctl delimiter is a colon (':') and not an equal sign ('=') as specified in augeasproviders_sysctl/lib/puppet/provider/sysctl/augeas.rb on line 82.

As a quick workaround and possible patch, I've done the following:

if Facter.value(:kernel) == 'FreeBSD' value = line.split(':') else value = line.split('=') end

My puppetserver is at version 5.3.1-1.el7.noarch runnig on a CentOS Linux release 7.4.1708 (Core).

Please let me know if there's a better way to fix this issue.

raphink commented 6 years ago

I don't understand where the 'not a valid sysctl key' error comes from. That is not from this module's code. Are you maybe using another sysctl module in addition?

Savagedlight commented 5 years ago

Seeing this issue here as well. The change suggested by @da125 fixed the problem.

Further info: Checked out this repository and looked for "is not a valid sysctl key":

grep -rn "is not a valid sysctl key" .

./lib/puppet/provider/sysctl/augeas.rb:121:        raise Puppet::Error, "Error: `#{resource[:name]}` is not a valid sysctl key"
./lib/puppet/provider/sysctl/augeas.rb:150:          debug("augeasproviders_sysctl: `#{resource[:name]}` is not a valid sysctl key")
./lib/puppet/provider/sysctl/augeas.rb:153:          raise Puppet::Error, "Error: `#{resource[:name]}` is not a valid sysctl key"

Either way, as @da125 mentioned, FreeBSD use ": " to separate key name from value when running the "sysctl" command. (It still uses name=value when changing values, and in sysctl.conf)

sysctl net.inet6.ip6

net.inet6.ip6.forwarding: 0
net.inet6.ip6.redirect: 1
net.inet6.ip6.hlim: 64
(...)
raphink commented 5 years ago

@da125 @Savagedlight Could you confirm #30 fixes it?

Savagedlight commented 5 years ago

@da125 @Savagedlight Could you confirm #30 fixes it?

I made comments in the PR. Once that's addressed, it seems to work as expected.

da125 commented 5 years ago

I am no longer using puppet and cannot test.

olevole commented 5 years ago

@raphink Same issue. #30 fixes it Tested on: FreeBSD 12,13 Сan you commit it ?

raybellis commented 4 years ago

I'm seeing this issue too on FreeBSD 11.3, and can confirm that the fix now allows me to set a sysctl value.

Please put out a release containing the patch! 🙏

raphink commented 4 years ago

@raybellis I just released 2.4.0