New module - Prefetch provider with @resource params...

40 views
Skip to first unread message

Gavin Williams

unread,
Jun 27, 2014, 7:14:37 AM6/27/14
to puppet...@googlegroups.com
Morning All

I'm starting to work on a new module[1] to support installation and configuration of Apache Karaf.

I've got most of the ground-work laid down, and I'm now starting to work on types and providers to model the various Karaf resources that might need to be managed...

The first one on my list is 'feature', which is effectively the Karaf equivalent of a package. I'm trying to write the providers using a prefetch/flush style to make them as efficient as possible, as the aspiration is for Karaf and the Puppet management agent to be run on minuscule hardware, so reducing the processing required as much as possible is essential... Anyhow, enough background, onto the issue...

The initial version of my type, provider and provider parent look like [2][3][4].
The 'karaf_feature' provider is using a helper function in 'Puppet::Provider::Karaf' called 'karaf_exec', which tries to use resource param values from the type in it's arguments...

What I was aiming to achieve is that the command is executed by Puppet as a specified user, as defined on Line 24 of [4].
However as '@resource' is nil at the point of prefetch call, it's not working :(
A sample log of a run is [5].

Now as I'm typing this, I'm thinking that trying to use values from a specific resource on a prefetch call possibly might not ever work...
But how else could I model this scenario? Or is prefetching doomed to failure?

Any help appreciated.

Regards
Gavin

[1] https://github.com/fatmcgav/fatmcgav-karaf
[2] https://github.com/fatmcgav/fatmcgav-karaf/blob/feature/prefetch_flush_providers/lib/puppet/type/karaf_feature.rb
[3] https://github.com/fatmcgav/fatmcgav-karaf/blob/feature/prefetch_flush_providers/lib/puppet/provider/karaf_feature/karaf_feature.rb
[4] https://github.com/fatmcgav/fatmcgav-karaf/blob/feature/prefetch_flush_providers/lib/puppet/provider/karaf.rb
[5] https://gist.github.com/fatmcgav/ca147ef48ac726d1194f

bert hajee

unread,
Jun 27, 2014, 7:30:13 AM6/27/14
to puppet...@googlegroups.com
Maybe easy_type can help you to make it easy to make a custom type. This takes some of the hard work in making a custom type away fro you, so you can focus on the content. 

We have used easy_type to build custom types for Oracle and webLogic

Let me know how it goes.

Regards,

Bert

Op vrijdag 27 juni 2014 13:14:37 UTC+2 schreef Gavin Williams:

Gavin Williams

unread,
Jun 27, 2014, 8:16:59 AM6/27/14
to puppet...@googlegroups.com
Bert

Cheers for the suggestion - I'll take a look at easy_type and see if it fits...

However I've written both prefetch and non-prefetch style providers before, just not combined a prefetch provider with resource param values... :)

Cheers
Gavin

Felix Frank

unread,
Jun 27, 2014, 8:25:29 AM6/27/14
to puppet...@googlegroups.com
Hi,

since the karaf_exec method is trying to access an instance member
(@resource), it should not be a class method - it needs to be an
instance method.

As such, you cannot use it for prefetching, true.

I think you need to take a step back and think about what the Puppet
agent is expected to do here in the prefetch phase. Can it do its things
as root? If not, is there a cue in some config file that it can rely on
to pick a suitable user?

If both are not the case, you may indeed find it impossible to perform
prefetching, because you cannot pass arguments from your manifest to the
agent at that level of granularity [1].

HTH,
Felix

[1] https://github.com/puppetlabs/puppet/pull/2136#issuecomment-35562203

Gavin Williams

unread,
Jun 27, 2014, 9:14:39 AM6/27/14
to puppet...@googlegroups.com
Felix

Cheers for the response.

Whilst the 'client' command can be run as root, the fact that there are command line args that can be optionally passed in makes it more challenging...
I guess I could look at creating a client config file and use that to define the args if appropriate...

Cheers again
Gavin

Cristian Falcas

unread,
Jul 10, 2014, 7:09:24 PM7/10/14
to puppet...@googlegroups.com
I this correct in your provider/karaf_feature/karaf_feature.rb file?

      if resource = resources[prov.name]

Should that be "=="?

Best regards,
Cristian Falcas



--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/155d2e09-df7e-4f44-86f0-7a6af28252c8%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Felix Frank

unread,
Jul 10, 2014, 7:58:46 PM7/10/14
to puppet...@googlegroups.com
On 07/11/2014 01:08 AM, Cristian Falcas wrote:
I this correct in your provider/karaf_feature/karaf_feature.rb file?

      if resource = resources[prov.name]

Should that be "=="?

Best regards,
Cristian Falcas

Nope. That's your regular old "set and test for nil" thingamajig.

You can link to specific code lines by the way - this one was https://github.com/fatmcgav/fatmcgav-karaf/blob/feature/prefetch_flush_providers/lib/puppet/provider/karaf_feature/karaf_feature.rb#L59

Cheers,
Felix
Reply all
Reply to author
Forward
0 new messages