Ask Your Question
1

Get the list of instances of a class

asked 2013-08-20 05:24:39 -0500

karlito139 gravatar image

updated 2013-08-21 11:37:49 -0500

llowder gravatar image

I'm trying to create a cron module which configure pacemaker to manage this resources.

I'd like to put all my cron task primitives into a pacemaker group. For that I need a list of all the cron task I created inside puppet in order to create this group.

Basicaly I got my cron puppet class which create an array called taskList. I'd like each instances of the cron::crontask class to add there name inside this array. Is-it possible?

Tanks a lot.

EDIT :

Here if the code of my cron class : pastebin. The important part of it ... (more)

edit retag flag offensive close merge delete

Comments

Could you post links to your existing code so we can review it and suggest solutions for you?

GregLarkin gravatar imageGregLarkin ( 2013-08-20 10:31:37 -0500 )edit
1

You need to reference the taskList variable as $cron::taskList from inside your crontask class. After that, I can't say the code will do what you want or not ...(more)

GregLarkin gravatar imageGregLarkin ( 2013-08-20 13:07:44 -0500 )edit

Good question. I just realized this is very similar to a question that I asked recently. https://ask.puppetlabs.com/question/2565/collect-variables-from-several-resources-into-one-variable

Nic gravatar imageNic ( 2013-08-21 21:32:47 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2013-08-21 16:40:19 -0500

llowder gravatar image

One thing I'd like to point out. Classes are singletons, there can only over be a single instance of a class in a given catalog. The cron::crontask item is a defined type, not a class. It is comparable to a user or file resource.

As Greg mentioned, you will need to use $cron::taskList for that variable. However, taskList will cause you some problems, as capital letters are not allowed. Variables, classes and modules should confirm to [a-z][a-z0-9_]*. Depending on your version of puppet, it may or may not work if you use capitals or hyphens, but ... (more)

edit flag offensive delete link more

Comments

Thanks for the explanation of the stdlib module - I need to remember to check that function list in the future, too.

GregLarkin gravatar imageGregLarkin ( 2013-08-21 17:28:17 -0500 )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

Stats

Asked: 2013-08-20 05:24:39 -0500

Seen: 153 times

Last updated: Aug 21 '13