Ask Your Question
0

Is create_resources best way for Hiera data in defines?

asked 2014-03-23 19:28:46 -0600

tlambertx gravatar image

updated 2014-03-23 19:30:44 -0600

Hello,

I have a custom resource like so:

define foo::bar($var1 = 'awesome') { notify { "You entered ${var1}": } }

I also have a the base class 'foo':

class foo ($hieradata = undef) { if $hieradata { create_resources('foo::bar',$hieradata) } }

Is this still the best way to go about creating modules to use hiera data for custom resources like 'foo::bar'?

Seems a little wonky and didn't know if there was perhaps a more elegant, straightforward solution.

Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-04-03 08:27:00 -0600

ffrank gravatar image

The class parameter is not necessary. Avoid.

class foo {
  $hieradata = hiera("key",false)
  if $hieradata {
    create_resources("foo::bar", $hieradata, { default params hash })
  }
}

I'm not sure what's particularly wonky to you, I've found it to be quite elegant and powerful.

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

1 follower

Stats

Asked: 2014-03-23 19:28:46 -0600

Seen: 866 times

Last updated: Apr 03 '14