inkblot/puppet-bind

puppetserver 2.2.1 can't find ruby in modules outside of type, function, & providers

hdeadman opened this issue · 4 comments

I was able to get this module to work as-is (5.1.2) on a puppetserver 2.2.1 but only after I added the lib folders for the bind and module_data modules to the ruby-load-path for puppetserver. Maybe this is a bug in puppetserver or maybe they just changed where they look for ruby code. I think the problem is that they can find custom types, functions, and providers but not other ruby code. In the case of this module it was unable to find the puppet_bind/provider/nsupdate.rb code which is sourced in from the dns_rr and resource_record providers.

This guy is having same problem with other modules (and he says this code used to work on old style puppet server)

This is what I did in puppetserver.conf

jruby-puppet: {
    # Where the puppet-agent dependency places puppet, facter, etc...
    # Puppet server expects to load Puppet from this location
    ruby-load-path: [/opt/puppetlabs/puppet/lib/ruby/vendor_ruby, /etc/puppetlabs/code/3rdparty/modules/bind/lib, /etc/puppetlabs/code/3rdparty/modules/module_data/lib]
...

This appears to be a bug in puppetserver that Puppet Labs knows about and has accepted: https://tickets.puppetlabs.com/browse/SERVER-973

There is a workaround linked in the issue. I'll give it a try, but I'll need you to test it.

OK, I should be able to test it within a day of you making a change.

One problem is that module_data also has the problem but I could test your fix and leave module_data in the ruby path so it works. There is also built-in puppet support for module data in the latest versions so I was going to give that a try at some point.

In the case of your module, isn't the code that won't load being shared between a deprecated type and a replacement? Could you just duplicate it for the time being and eventually it will go away when you delete the deprecated type?

I am OK with the hack fix I have for the time being but fixing this might save others some aggravation. It could also just be documented as a temporary issue for people with puppetserver.

In my fork I fixed this issue by duplicating the code that you are sharing between two types. Since one of those types is deprecated, the code won't be duplicated forever since the deprecated stuff will eventually be deleted I assume. Would you be interested in that as a pull request?

I also have a change that prints out the contents of the nsupdate input temp file when there is an error. That is helpful to troubleshoot when an nsupdate call fails.

I hit the same issue and this fixed it:

begin
  require 'puppet_bind/provider/nsupdate'
rescue LoadError
  require 'pathname' # WORK_AROUND #14073 and #7788
  nsupdate = Puppet::Module.find('dns', Puppet[:environment].to_s)
  raise(LoadError, "Unable to find nsupdate module in modulepath #{Puppet[:basemodulepath] || Puppet[:modulepath]}") unless nsupdate
  require File.join nsupdate.path, 'lib/puppet_bind/provider/nsupdate'
end