1
votes

I am trying to create a custom provider for package but for some reasons I keep on getting

err: Could not run Puppet configuration client: Parameter provider failed: Invalid package provider 'piprs' at /usr/local/src/ops/services/puppet/modules/test/manifests/init.pp:5

I have added pluginsync=true in puppet.conf in both client and server. I have created the following rb file in module/test/lib/puppet/provider/package/piprs.rb. I am basically trying to create a custom provider for package resource type

#require 'puppet/provider/package' 

Puppet::Type.type(:package).provide(:piprs,
      :parent => ::Puppet::Provider::Package) do

      commands : pip => "/usr/local/bin/pip"

      desc "Python packages via `pip`."

      def create
            pip "freeze"
      end

      def destroy
      end

      def exists?
      end

    end

In the puppet.conf, there is the following source attribute

      pluginsource = puppet://puppet/plugins

I am not sure what it is. If you need anymore details, please do post a comment.

1

1 Answers

2
votes

First things first - you do realize there is already a Python pip provider in core?

https://github.com/puppetlabs/puppet/blob/master/lib/puppet/provider/package/pip.rb

If that isn't what you want - then lets move on ...

For starters - try your module without a Puppet master - this is going to be better for development anyway. You need to make sure Ruby can find the library path:

export RUBYLIB=<path_to_module>/lib

Then, try writing a small test in a .pp file:

package { "mypackage": provider => "piprs" }

And run it locally:

puppet apply mytest.pp

This will rule out a code bug in your provider versus a plugin sync issue.

I notice there is a space between the colon and the command - that isn't your problem is it?

commands : pip => "/usr/local/bin/pip"

If you can get this working without a puppetmaster, your problem is sync related.

There are a couple of things that can go wrong - make sure the file is sync'd properly on the client:

ls /var/lib/puppet/lib/puppet/provider/package

You should see the piprs.rb file there. If it is, you may need to make sure your libdir is set correctly:

puppet --configprint libdir

This should point to /var/lib/puppet/lib in most cases.