[Puppet-dev] sysctl type/provider

182 views
Skip to first unread message

Paul Lathrop

unread,
Apr 19, 2010, 7:26:19 PM4/19/10
to puppe...@googlegroups.com
Hey all,

I'm not sure where I originally snagged this sysctl type/provider, but
we were using it w/o problems until we upgraded to 0.25.x and I'm
having trouble debugging the issue. The error we're getting is:

Apr 19 15:46:19 s0005 puppetmasterd[21382]:
(//digg-cassandra/Sysctl[net.ipv4.tcp_max_syn_backlog]) Failed to
retrieve current state of resource: No ability to determine if sysctl
exists

Which Luke and James both suggested (in IRC) indicates a missing
'exists?' method, but this type descends from ParsedFile; other
examples don't define their own 'exists?' method either (see the cron
type/provider for example).

Any ideas would be appreciated.

#### modules/sysctl/plugins/puppet/type/sysctl.rb
module Puppet
newtype(:sysctl) do

@doc = "Manages kernel parameters in /etc/sysctl.conf. By
default this will
only edit the configuration file, and not change any
of the runtime
values. If you wish changes to be activated right
away, you can do
so with an exec like so:

exec { load-sysctl:
command => \"/sbin/sysctl -p /etc/sysctl.conf\",
refreshonly => true
}

Set any changes you want to happen right away to
notify this command,
or you can set it as the default:

Sysctl {
notify => Exec[load-sysctl]
}"

ensurable

newparam(:name, :namevar => true) do
desc "Name of the parameter"
isnamevar
end

newproperty(:val) do
desc "Value the parameter should be set to"
end

newproperty(:target) do
desc "Name of the file to store parameters in"
defaultto { if
@resource.class.defaultprovider.ancestors.include?(Puppet::Provider::ParsedFile)
@resource.class.defaultprovider.default_target
else
nil
end
}
end
end
end

##### modules/sysctl/plugins/puppet/provider/sysctl/parsed.rb
require 'puppet/provider/parsedfile'

sysctlconf = "/etc/sysctl.conf"

Puppet::Type.type(:sysctl).provide(:parsed,
:parent => Puppet::Provider::ParsedFile,
:default_target => sysctlconf,
:filetype => :flat
) do

confine :exists => sysctlconf
text_line :comment, :match => /^\s*#/;
text_line :blank, :match => /^\s*$/;

record_line :parsed, :fields => %w{name val}, :joiner => ' = ',
:separator => /\s*=\s*/

end

--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to puppe...@googlegroups.com.
To unsubscribe from this group, send email to puppet-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.

Luke Kanies

unread,
Apr 21, 2010, 12:50:44 PM4/21/10
to puppe...@googlegroups.com
On Apr 19, 2010, at 4:26 PM, Paul Lathrop wrote:

> Hey all,
>
> I'm not sure where I originally snagged this sysctl type/provider, but
> we were using it w/o problems until we upgraded to 0.25.x and I'm
> having trouble debugging the issue. The error we're getting is:
>
> Apr 19 15:46:19 s0005 puppetmasterd[21382]:
> (//digg-cassandra/Sysctl[net.ipv4.tcp_max_syn_backlog]) Failed to
> retrieve current state of resource: No ability to determine if sysctl
> exists
>
> Which Luke and James both suggested (in IRC) indicates a missing
> 'exists?' method, but this type descends from ParsedFile; other
> examples don't define their own 'exists?' method either (see the cron
> type/provider for example).
>
> Any ideas would be appreciated.

I'm pretty stumped by this - ParsedFile has almost no changes in the
last year or so, nor does the FileParsing utility module.

You could do a bit of testing with something like:

$ irb
> require 'puppet'
> resource = Puppet::Type.type(:sysctl).new :name => "something"
> provider = resource.provider
> provider.exists?

This should probably be false (you should likely change the name/args
so the resource is valid), but if what you're seeing is correct, then
it might even fail.

You can also confirm that the provider is an instance of the actual
provider class:

> provider.class

I remember now that not having an actual provider can sometimes appear
with this kind of failure - the resource treats itself as its own
provider when there is no real provider available, so it might be that
you're not getting a real provider.

If that's the problem, then you've probably got some warning or
failure that isn't propagating, or your file is in the wrong
location. I don't know of anything in 0.25 that would have triggered
that, but...

--
Nonreciprocal Laws of Expectations:
Negative expectations yield negative results. Positive expectations
yield negative results.
---------------------------------------------------------------------
Luke Kanies -|- http://puppetlabs.com -|- +1(615)594-8199
Reply all
Reply to author
Forward
0 new messages