I'm looking at building a simple ensurable custom type that itself
uses Puppet resources to manage a group of files and users.  Because
of the multi-dimensional data structures I'm dealing with, dropping
into Ruby seems to be the best way to go.  I have a feeling that using
file resources is the right way to do this but I'm having trouble with
providers.  First, I'm just trying to get it to run without exceptions
using the following type and provider:

require 'puppet/type'
Puppet::Type.newtype(:foobar) do
  @doc = "foobar"
  newparam(:name, :namevar => true) do
    desc "foobar name."
  end
  ensurable do
    self.defaultvalues
    defaultto :present
  end
end

require 'puppet/resource'
require 'puppet/resource/catalog'
require 'puppet/type'
require 'puppet/type/file'
require 'puppet/type/user'
Puppet::Type.type(:foobar).provide(:posix) do
  desc "foobar"
  defaultfor :operatingsystem => :debian
  def create
    Puppet.notice :create
    catalog = Puppet::Resource::Catalog.new
    catalog.add_resource Puppet::Resource.new(:user, "demo", :ensure => :absent)
    catalog.apply
  end
  def destroy
    Puppet.warn "DevStructure users should never need to be destroyed."
  end
  def exists?
    Puppet.notice :exists?
    false
  end
end

The error is: "err: Got an uncaught exception of type NoMethodError:
undefined method `provider' for #<Puppet::Resource:0x7f1f8f724b78>"
(Full output below.)

The probem seems to be in setting/inheriting the default provider for
the user resource.  How does the main catalog set/inherit default
providers?  Is this use of resources advisable/supported or would I be
best off not using a catalog or not using resources altogether?

Thanks for any help you can provide,

Richard



Here's the full output from this section of a puppetd run:

notice: exists?
debug: //devstructure/Foobar[hooah]: Changing ensure
debug: //devstructure/Foobar[hooah]: 1 change(s)
notice: create
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/transaction.rb:470:in
`prefetch'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/transaction.rb:469:in
`each'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/transaction.rb:469:in
`prefetch'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/transaction.rb:497:in
`prepare'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/transaction.rb:284:in
`evaluate'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/resource/catalog.rb:142:in
`apply'
/var/lib/puppet/lib/puppet/provider/foobar/posix.rb:13:in `create'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/property.rb:403:in
`set_present'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/property.rb:109:in `send'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/property.rb:109:in
`call_valuemethod'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/property.rb:298:in `set'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/property.rb:363:in `sync'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/transaction/change.rb:54:in
`go'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/transaction/change.rb:72:in
`forward'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/transaction.rb:120:in
`apply_changes'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/transaction.rb:113:in
`collect'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/transaction.rb:113:in
`apply_changes'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/transaction.rb:85:in
`apply'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/transaction.rb:251:in
`eval_children_and_apply_resource'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/util.rb:418:in `thinmark'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/util.rb:417:in `thinmark'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/transaction.rb:250:in
`eval_children_and_apply_resource'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/transaction.rb:207:in
`eval_resource'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/transaction.rb:296:in
`evaluate'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/util.rb:418:in `thinmark'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/util.rb:417:in `thinmark'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/transaction.rb:295:in
`evaluate'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/transaction.rb:289:in
`collect'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/transaction.rb:289:in
`evaluate'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/resource/catalog.rb:142:in
`apply'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/configurer.rb:169:in `run'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/util.rb:178:in `benchmark'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/util.rb:177:in `benchmark'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/configurer.rb:168:in `run'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/agent.rb:53:in `run'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/agent/locker.rb:21:in
`lock'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/agent.rb:53:in `run'
/usr/lib/ruby/1.8/sync.rb:230:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/agent.rb:53:in `run'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/agent.rb:134:in
`with_client'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/agent.rb:51:in `run'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/application/puppetd.rb:103:in
`onetime'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/application.rb:226:in
`send'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/application.rb:226:in
`run_command'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/application.rb:217:in `run'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/application.rb:306:in
`exit_on_fail'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/lib/puppet/application.rb:217:in `run'
/usr/lib/ruby/gems/1.8/gems/puppet-0.25.4/bin/puppetd:159
/usr/bin/puppetd:19:in `load'
/usr/bin/puppetd:19
err: Got an uncaught exception of type NoMethodError: undefined method
`provider' for #<Puppet::Resource:0x7f1f8f724b78>
notice: //devstructure/Foobar[hooah]/ensure: created

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to