Hi, I have a custom provider that seems to run ok in isolation by itself. In addition, puppet does not complain at all when it runs. However, when I ensure => installed a package the desired package is never installed.
There are a few differences between this and something such as the gem provider, most importantly, I couldn't find anyway to get the provider to run as a different user without doing direct system call. Here's the provider Puppet::Type.type(:package).provide :npm, :parent => Puppet::Provider::Package do desc "node.js package management with npm" commands :npm_cmd => "/home/node/opt/bin/npm" raise Puppet::Error, "The npm provider can only be used as root" if Process.euid != 0 def self.npm_list(hash) begin s = `sudo -u node sh -c \"export PATH=/home/node/opt/bin:$ {PATH}; npm ls installed\"` list = s.split("\n").collect do |set| if npm_hash = npm_split(set) npm_hash[:provider] = :npm if npm_hash[:name] == hash[:justme] npm_hash else nil end else nil end end.compact rescue Puppet::ExecutionFailure => detail raise Puppet::Error, "Could not list npm packages: #{detail}" end list.shift end def self.npm_split(desc) split_desc = desc.split(/ /) installed = split_desc[0] name = installed.split(/@/)[0] version = installed.split(/@/)[1] if (name.nil? || version.nil?) Puppet.warning "Could not match #{desc}" nil else return { :name => name, :ensure => version } end end def install output = `sudo -u node sh -c \"export PATH=/home/node/opt/bin:$ {PATH}; npm install http-console\"` if output =~ /npm not ok/ raise Puppet::ExecutionFailure, "Failed to install #{resource[:name]}" end end def uninstall output = `sudo -u node sh -c \"export PATH=/home/node/opt/bin:$ {PATH}; npm uninstall #{resource[:name]}\"` if output =~ /npm not ok/ raise Puppet::ExecutionFailure, "Failed to uninstall #{resource[:name]}" end end def query version = nil self.class.npm_list(:justme => resource[:name]) end end Does anybody have an idea what's going wrong? The other problem I'm having is that I have to manually copy the provider to puppet lib from the module lib. Thanks. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-us...@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.