Ask Your Question

Custom puppet type provider - exists? returning true causes 'undefined method' exception

asked 2013-06-19 04:02:33 -0600

dmitry gravatar image

updated 2013-06-19 09:14:30 -0600


I'm trying to develop a custom type provider for RabbitMQ, based on existing providers present in the puppetlabs/rabbitmq module. If exists? method returns false - everything works fine. However, if exists? returns true, puppet fails with undefined method 'pattern' exception (stacktrace bellow). Note that pattern is one of my type's parameters.

I'm using Puppet 3.1.1 on CentOS.

The stacktrace:

Error: /Stage[main]//Node[rabbitmq]/Rabbitmq_policy[ha-all@DMITRY_CBMS]: Could not evaluate: undefined method `pattern' for #<Puppet::Type::Rabbitmq_policy::ProviderRabbitmqctl:0x7f5e647471f0>

/usr/lib/ruby/site_ruby/1.8/puppet/property.rb:462:in `send'
/usr/lib/ruby ...
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-06-19 05:22:53 -0600

Type properties need to have getter and setter methods in your provider. If you don't need it you can convert "pattern" and "definition" into parameters. If you'll keep them as properties you must create the required methods.

edit flag offensive delete link more


Switching to parameters solved the issue. Now a policy is created if none with the same name exists. This is workable, but not perfect.

I tried to improve on ...


dmitry gravatar imagedmitry ( 2013-06-19 06:35:04 -0600 )edit

Can you post your latest provider/type code? I'm sure we can work this out

Daniel gravatar imageDaniel ( 2013-06-19 07:18:54 -0600 )edit

Type definition

Puppet::Type.newtype(:rabbitmq_policy) do
  desc 'Type for defining rabbitmq policies'

  ensurable do
    newvalue(:present) do
    newvalue(:absent) do
  end ...
dmitry gravatar imagedmitry ( 2013-06-19 07:46:48 -0600 )edit

and the provider ;-). Seems like i wasn't clear about it. Sorry

Daniel gravatar imageDaniel ( 2013-06-19 09:07:38 -0600 )edit

I was going to add them both, but there seems to be a size limit for comments...

dmitry gravatar imagedmitry ( 2013-06-19 09:11:51 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2013-06-19 04:02:33 -0600

Seen: 749 times

Last updated: Jun 19 '13