Ask Your Question
2

Collect variables from several resources into one variable?

asked 2013-08-21 21:12:08 -0500

updated 2013-08-21 22:03:24 -0500

Consider a module that declares the class module::singleton and defines the type module::many. Is there any way for the class to see the names of the defined types? Here's an example:

class module::singleton {
  $foo = declared_names_of_type(module::many)   //This doesn't work. Can it even be done?
}

define type module::many { }

include module::singleton
module::many {'first':}
module::many {'second':}

To be more specific, I'm working on a module for SSSD. The config file for SSSD requires that each domain is named at the top, and also has its own config stanza down below. It looks ... (more)

edit retag flag offensive close merge delete

Comments

Seems like the spaceship operator might be able to make this work somehow, but I can't figure it out. http://docs.puppetlabs.com/puppet/2.7/reference/lang_collectors.html

Nic gravatar imageNic ( 2013-08-24 18:32:15 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-08-21 21:45:51 -0500

ramindk gravatar image

updated 2013-08-21 21:46:33 -0500

You might try pumping it through create_resources from within your class.

modules/sssd/manifests/init.pp

class sssd (
  $domains,
  $make_home_dir = false,
  $filter_users = [ 'root' ],
  $filter_groups = [ 'root' ]
) {

  etc etc

  create_resources('sssd::domain', $domains)
}
edit flag offensive delete link more

Comments

I recently added code for create_resources (http://bit.ly/1f3Euiw) but that doesn't help me figure out how to generate the top section of the file which needs a ...(more)

Nic gravatar imageNic ( 2013-08-21 21:58:49 -0500 )edit

Why the second var? If you make $domains a hash of hashes you'd have better luck though you'd need to tweak your existing header template.

ramindk gravatar imageramindk ( 2013-08-21 22:25:42 -0500 )edit

Ah yes, this could be done in the erb template file by requiring a hash of hashes as a parameter. Can you edit your answer to give an example of ...(more)

Nic gravatar imageNic ( 2013-08-21 22:43:59 -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-21 21:12:08 -0500

Seen: 418 times

Last updated: Aug 21 '13