Top scope variables and hiera

74 views
Skip to first unread message

puppeteer123

unread,
Aug 16, 2015, 4:25:26 AM8/16/15
to Puppet Users
After using hiera for a few months, I started to find a lot of keys with the same value in my common.yam:

---
provisioning::server: 'same.old.node'
kickstart::server: 'same.old.node'
puppet::server: 'same.old.node'

Contextually they are fine, however it seems a little redundant.

Is there a way I can call provisioning server from my kickstart class without having to use the hiera lookup function? And is that acceptable practice?

Doesn't seem like this is possible due to scope.
class kickstart {
  $server = $provisioning::server


This doesn't seem to work either:
$server = $provisioning::server
class kickstart {

I know I can use the hiera() function, but checking to see if this is the only way.

Thanks!

Denmat

unread,
Aug 16, 2015, 5:46:24 AM8/16/15
to puppet...@googlegroups.com
Hi,

The way I see it you have two options.

The hiera function like you said or a profile/parent class that you can use to do the lookup.

class profile::provisioning (
  $server
  {
  class {someclass: server => $server}
  ....
  more
  ...
 }

Then common.yaml has only
profile::provisioning::server: blah.node

Which ever floats your boat will work.

HTH
Den
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/50946780-d02d-4146-b7ae-1ed6ec31e463%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Chris Spence

unread,
Aug 16, 2015, 1:41:35 PM8/16/15
to Puppet Users
The other option is to use anchors and references in the YAML to reduce the duplication.
Reply all
Reply to author
Forward
0 new messages