Hi Matthew, FWIW, I ran into the same issue, and wound up creating an abstraction layer on top of my hiera lookups to do this:
It does a lot more than what you are asking for, but I thought it was worth mentioning since it was written to solve the same problem. https://github.com/bodepd/scenario_node_terminus/blob/master/README.md#data-mappings On Wed, Nov 6, 2013 at 3:41 PM, Matthew Barr <[email protected]> wrote: > 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 [email protected]. > 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. > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CA%2B0t2LxjgVDjzs4Fcrj-xHrWE7y-yjq0NdZ1xa6Lo2esF%3D%2B%3DVQ%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
