1
votes

I have a bunch of custom types and providers written and tested against Puppet 2.7.whatever. The said types/providers sit in a dedicated module, which contains only lib subdirectory with all extensions under it. The custom types are tested from another module/class under the same modules subdirectory. As far as I understand, this used to belong to 'best practices'. Now, with Puppetserver 2.1.1 at least two things have changed:

The extensions defined in a different module are not loaded. If the class using custom types is declared in manifest under module 'test', and the custom types/providers are under module '_ext', I get Error: Failed to apply catalog: Parameter name failed on Resources[<my_custom_type>]. The extensions are not even downloaded from the server. As soon as I symlink _ext/lib to 'test/lib', it works. Symlink removed, everything is purged from cache on the next agent run. So, what are the new rules of loading plugins defined in modules?

I have several providers for different types, using the same command-line utility. Eventually, I have factored out a few class instance methods into a parent class that inherits from Puppet::Provider and is 'required' and is passed as 'parent' argument to Puppet::Type.type(:).provide function. The require uses the relative path, like in require 'puppet/provider/<parent>.rb' It works with Puppet 2.7 but Puppetserver 2.1.1 throws an excepton:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Evaluation Error: Error while evaluating a Resource Statement, Could not autoload puppet/type/<custom_type>: Could not autoload puppet/provider/<custom_type>/<custom_provider>: no such file to load -- puppet/provider/<parent>

So, what is the best way to include a parent class in this scenario? The full path to class will be different on the server and on the agent, so this is hardly an option.

I have used the default settings on server and minimal agent configuration. pluginsync is set to true on the agent, but that's default anyway.

1

1 Answers

0
votes

1st problem:

module name starts with underscore and is ignored (no idea why). But changing _ext to ext makes all extensions to be downloaded, cached, etc.

2nd problem, a dirty fix:

add the absolute path to ruby-load-path in puppetserver.conf:

ruby-load-path: [/opt/puppetlabs/puppet/lib/ruby/vendor_ruby, /etc/puppetlabs/code/environments/<myenvironment>/modules/ext/lib]

No idea how to make Puppetserver (or rather, the JRuby interpreter) to look into every lib subdirectory for Ruby files, though.

On the client, everything runs smoothly once the 'evaluation' is brought to order on the server.