On Monday, August 19, 2013 10:03:03 AM UTC-5, RobH wrote:
>
> I'm using Hiera with Puppet and I want to pass the same parameter value to 
> multiple classes without repeating it. Right now I've got (in Yaml):
>
> ---
> class_a::database_server: myoraclebox.example.com
> class_b::database_server: myoraclebox.example.com
>
>
> This works, but how can I specify the server only once and still use 
> Puppet's automatic parameter lookup? (I'd rather not embed an explicit 
> Hiera lookup in my manifest, since that would couple it to Hiera.)
>
> Thanks!
>

The appropriate mechanism(s) for doing this depend in part on what you mean 
to express.  Is it meaningful that parameters to two different classes have 
the same value, or is it a random coincidence?  If meaningful, then is that 
meaning tied specifically to your site, or is it general to the nature of 
the classes involved?  Here are some of your better options:

   1. YAML has a mechanism for expressing a value in the form of a 
   reference to another value in the same document.  I think this will work 
   with the YAML parser Hiera is using.  Look up "anchors" and "aliases" in 
   the YAML spec (http://www.yaml.org/spec/1.2/spec.html).  I would use this 
   only if it is a requirement peculiar to your site that the two class 
   parameters take the same value, there is no likelihood of that requirement 
   changing in the foreseeable future, and (2) below does not apply.
   2. Alternatively, if the requirement for the two parameters to take the 
   same value can be construed as part of the nature of the classes involved, 
   then you could have one class reference the other's parameter instead of 
   defining its own, or else create a third class on which the parameter can 
   reside, and have both the others rely on it.

If, however, it is not deeply significant that the two classes take the 
same parameter value, then I would retain the data duplication.  It better 
expresses the nature of the coincidence, and it minimizes your risk of 
breaking things when the circumstances giving rise to the coincidence 
change.



John

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to