Help with Composite Namevars

94 views
Skip to first unread message

Leonard Smith

unread,
Jan 23, 2014, 3:36:38 PM1/23/14
to puppe...@googlegroups.com
To all,

I am on puppet 2.7.3 and I'm working on a custom RabbitMQ type, that will use composite namevar.  I did not see any work out there already for managing rabbitMQ bindings so I've started on one and I'm running into problems with the composite namevar. I have a very basic type ( below ) but when I run the puppet as an agent I still get the error "Error 400 on SERVER: Could not render to pson: you must specify title patterns when there are two or more key attributes"

Any help or pointers would be appreciated.

#Puppet Manifest: 

  rabbitmq_binding { 'testing':

    source      => "src",

    destination => "dest",

  }


# Puppet Type

Puppet::Type.newtype(:rabbitmq_binding) do

  desc 'rabbitmq_binding creates a puppet type for managing rabbitMQ binding'

  def self.title_patterns

    [ [

        /^(.*):(.*)$/,          # pattern to parse <source>:<destination>

        [

          [:source, lambda{|x| x} ],

          [:destination, lambda{|x| x} ]

        ] ]

    ]

  end

  newparam( :source ) do  

    isnamevar

  end

  newparam( :destination ) do

    isnamevar

  end

end

Reid Vandewiele

unread,
Jan 28, 2014, 12:14:54 PM1/28/14
to puppe...@googlegroups.com
I don't know the "right" way to do this but I've worked on a couple of composite namevar types at least enough that I've seen that kind of error before.

In effect, when using a composite namevar you must manually specify how to extract individual parameters from the resource title. It is assumed that the default title pattern is insufficient.

What happens if for a given resource, no pattern in your title_patterns matches? Maybe that's what you're running into?

Jeremy T. Bouse

unread,
Jan 28, 2014, 9:13:51 PM1/28/14
to puppe...@googlegroups.com
On 28.01.2014 12:14, Reid Vandewiele wrote:
> I don't know the "right" way to do this but I've worked on a couple
> of
> composite namevar types at least enough that I've seen that kind of
> error before.
>
> In effect, when using a composite namevar you must manually specify
> how to extract individual parameters from the resource title. It is
> assumed that the default title pattern is insufficient.
>
> What happens if for a given resource, no pattern in your
> title_patterns matches? Maybe that's what you're running into?
>
> Here are a few other title_patterns examples.
>
>
> https://github.com/puppetlabs/puppetlabs-java_ks/blob/master/lib/puppet/type/java_ks.rb#L140
>
> https://github.com/reidmv/puppet-module-yamlfile/blob/master/lib/puppet/type/yaml_setting.rb#L166
>

Not really wanting to sidetrack this thread as it is a topic I've got a
great amount of interest in... But looking at the provided examples it
would appear that
https://github.com/reidmv/puppet-module-yamlfile/blob/master/lib/puppet/type/yaml_setting.rb#L180
is in error and should be :target not :value given
https://github.com/reidmv/puppet-module-yamlfile/blob/master/lib/puppet/type/yaml_setting.rb#L59-63
declares :target as isnamevar while
https://github.com/reidmv/puppet-module-yamlfile/blob/master/lib/puppet/type/yaml_setting.rb#L84-L100
does not list :value as isnamevar at all.
Reply all
Reply to author
Forward
0 new messages