FAQ
NOTE: of course, I just wrote this whole thing, and I think using a hiera
lookup in the parameter might be about the same. That's at the end of
this. I'd still like to know if it breaks scope or the renderer...

However, it might be an option for overriding params.pp settings, without
having to do the inherit pattern on the other classes in a module?
   of course, when we get hiera 2, that'll make life much easier.


------------------------

I just needed to do something a bit strange with hiera & 2 modules.

I know it works, since I just ran it.. but I'm not sure it's a good idea...
  or if it's just luck.
(Assume puppet 3.x)

Problem:
db_url & amqp_url are both set the same across all machines in a specific
environment, but different per environment: dev, stage, prod.

Perfect, you'd put this info into Hiera. No problem.

Automatic lookups- This also gives the option of overriding a value from
hiera in the node scope..

So:
webserver::db_url: mysql://dev-url
webserver ::amqp_url: amqp://dev-url

+

class webserver( $db_url, $amqp_url)
{ blah
}

-----
node 'Web' {
   include webserver
}

node 'WebTest' {
   class {'webserver':
      db_url=> 'mysql://testbox'
   }
}
----


But what happens when you want to use it with a second class? And they
need the exact same data? You clearly don't want to replicate the keys in
Hiera!

- The worker class is screwed :)

class worker ($db_url, $amqp_url)
{ other blah }



The obvious thought is to put the data into a common key in hiera:
  - I'd also like to preserve the option of overriding a specific parameter,
like for testing with vagrant etc.

Here's the way I thought of:


---
centralconfig::db_url: mysql://dev-url
centralconfig ::amqp_url: amqp://dev-url

----

class webserver {
  require centralconfig
  $db_url = $centralconfig::db_url
  $amqp_url = $centralconfig::amqp_url

blah
}


-------
node 'Web' {
   include webserver
}

node 'worker' {
   include worker
}

node 'webtest' {
   class {'centralconfig':
      db_url=> 'mysql://testbox'
   }
   include webserver
}


----

Now, if this is bad...
You could convert the automatic lookups to be actual hiera_lookup calls.

class webserver(
   $db_url = hiera('centralconfig::db_url')
   $amqp_url = hiera('centralconfig::db_url')
  ){
blah
}


And.. this might be the easiest, cleanest option..

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CACCqFtj1aML4OpNF32X3LkafiEtGo-yecoZjMnM%3DySatVGWyFw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 2 | next ›
Discussion Overview
grouppuppet-users @
categoriespuppet
postedNov 6, '13 at 11:41p
activeNov 7, '13 at 2:51a
posts2
users2
websitepuppetlabs.com

2 users in discussion

Dan Bode: 1 post Matthew Barr: 1 post

People

Translate

site design / logo © 2022 Grokbase