Ask Your Question

how to customize the title or name in defined type?

asked 2013-03-06 15:03:28 -0500

redgoal gravatar image

I am creating my own defined type. I want to create my own title/name pattern for a service like this : defined serviceA( ){ serviceB{"servicename:serviceproperty": ensure => true, } But in Type code I ma not able to access this title/name which is "servicename:serviceproperty". I tried like this : newpram(:title) (a , b) = title.split(":") :a = a namevar :b = b end Actually, I want to split title to create two newparams like :a and :b here.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-03-06 16:08:25 -0500

Stefan gravatar image

updated 2013-03-06 16:24:04 -0500

If a parameter is marked as a namevar and the parameter is not explicitly set in a manifest, it will "inherit" the value of the resource's title.

If you have two (or more) parameters marked as a namevar this cannot work automatically anymore and you have to define a title pattern. The title pattern tells puppet which part of the title should set the different namevars. An example can be seen here: link (which seems to be exactly your usecase btw.)

For the record: This should do the trick in your example case:

def self.title_patterns
    # We could define ...
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools


Asked: 2013-03-06 15:03:28 -0500

Seen: 377 times

Last updated: Mar 06 '13