Reloading missing gems in a custom provider during the run

20 views
Skip to first unread message

Karolis Pabijanskas

unread,
Sep 17, 2014, 9:49:07 AM9/17/14
to puppet...@googlegroups.com
Hi,

I have a custom type and provider that are depending on a rest-client gem.

After the pluginsync, when providers get loaded, I do this to avoid it failing:

 30 begin
 31   require 'rest-client'
 32 rescue LoadError => e
 33   Puppet.info "You need the `rest-client` gem for this to work."
 34 end


The rest-client is not present before the run, thus I get an Info message:
"Info: You need the `rest-client` gem for this to work."

The rest-client gem is then installed before the code that uses this type is run, but the actual provider still thinks the rest-client is not present (as it was loaded without it), thus it fails to run.

Is there any way to force puppet to reload the provider before the associated custom type is run, or anything else I can do?

Thanks!
Karolis

Nan Liu

unread,
Sep 17, 2014, 12:36:20 PM9/17/14
to puppet...@googlegroups.com
In older versions of puppet use puppet feature to determine availability. I think the cutover is somewhere in 3.x where you only need to require the gem. Assuming require 'rest-client' is specified in the provider, two possibility:

1. resource order. this can be fixed via autorequire in the custom type to require either the class where rest-client gem is specified or the package rest-client.
2. the rest-client gem is not installed in puppet's ruby library path. For example puppet enterprise should be installed via /opt/puppet/bin/gem, and on versions of Ubuntu/Debian you may have multiple versions of Ruby (puppet might be installed for Ruby 1.8 while the default gem path is for Ruby 1.9).

Thanks,

Nan
Reply all
Reply to author
Forward
0 new messages