On Sat, Sep 24, 2011 at 01:43:05AM +0200, Steve Traylen wrote: > Hi, > I'm trying to add my first custom type to puppet largely copying > examples whilst working with puppet-2.6.6. > > My error: > > err: Could not retrieve catalog from remote server: Error 400 on > SERVER: Could not render to pson: you must specify title patterns when > there are two or more key attributes > > What is a title pattern? > > My extremely trivial files: > > The type "metric" > http://pastebin.com/9F7sVYjp > > The provider "lemon". > http://pastebin.com/eJEvsV6v >
Puppet 2.6 has basic support for types with composite namevars. That
means that not only one parameter identifies a resource but the
combination of parameters. One example is a port in /etc/services. What
really identifies an entry in /etc/services is not only the port's name
it is the name AND the protocol.
But when you write your manifest and describe a resource it is common
to not set any namevar explicitly but implicitly via the title. Example:
file { '/tmp/foo':
ensure => file,
}
The namevar of the fileresource is called `path` and because I haven't
specified the path parameter explicitly it is implicitly set to /tmp/foo (the
resource's title). If we have more then one namevar (I prefer the term
keyattribute by the way) the type developer has to specify a title pattern.
The title pattern is basically as special array that determines how to
convert the title of a resource into values for the different key attributes.
So to pick up the previous example of a port entry in /etc/services a resource
title could look like this:
inet_port { 'telnet/tcp':
ensure => present
number => '22',
}
With the correct title pattern puppet can now set the name parameter to
'telnet' and the protocol parameter to 'tcp'.
Long story short:
You see this message because your type does not implement the title
pattern method but you have a type with more than one keyattribute:
1. »id« which you explicitly marked with the isnamevar method
2. »name« which is implicitly always treated as a keyattribute
If the second one is not what you want you have to rename your
parameter.
-Stefan
pgpfo1fqXIvj3.pgp
Description: PGP signature
