FAQ
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!

--
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 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.

Search Discussions

  • Jcbollinger at Aug 20, 2013 at 1:21 pm

    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+unsubscribe@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.
  • RobH at Aug 22, 2013 at 8:58 pm
    Thanks. These are good pointers.

    --
    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 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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedAug 19, '13 at 3:04p
activeAug 22, '13 at 8:58p
posts3
users2
websitepuppetlabs.com

2 users in discussion

RobH: 2 posts Jcbollinger: 1 post

People

Translate

site design / logo © 2022 Grokbase