Ask Your Question

Is it possible to collect variable values from resources?

asked 2013-12-03 04:23:17 -0500

Vladimir-csp gravatar image

updated 2015-04-04 19:25:11 -0500

ramindk gravatar image

Hi! I would like to know, is it possible to collect variable values from a group of resources to use them in the template in another class? Or is there any other way to collect and reuse values from resources? Let's say, we have a configuration:

define site (var1 =  undef) {
      some code

class sites {
         var1 => 'bla-1-bla',
         var1 => 'some-other-value',

Is it possible to generate the array that contains all var1 values of all 'site' resources, like ['bla-1-bla','some-other-value']?

edit retag flag offensive close merge delete


Since you specify them already in your class, then your codebase contains already everything you need. maybe go for an external facts which parses the manifests and constructs the array.

far4d gravatar imagefar4d ( 2015-06-14 01:52:18 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2015-06-12 07:11:20 -0500

sinned gravatar image

You could of course uses a hiera database backend which you populate with your individual ressource data.

Then you create a view in the database which does the collection and then you reuse that again using hiera in your puppet code.

This is just a scheme of the way I would look into.

edit flag offensive delete link more

answered 2015-04-04 10:53:40 -0500

updated 2016-08-15 20:35:00 -0500

No, it is not.

Edit 2016-08: With the future parser and a lambda it is.

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-12-03 04:23:17 -0500

Seen: 360 times

Last updated: Aug 15 '16