On Thursday, March 14, 2013 10:26:59 AM UTC-4, jcbollinger wrote:
>
>
>
> On Wednesday, March 13, 2013 8:51:04 PM UTC-5, Ellison Marks wrote:
>>
>> You can just call hiera_hash() from within your manifest, no?
>
>
>
> No.  The OP wants hash merging, and hiera_hash() doesn't do that (as far 
> as I understand).  It will instead return a hash whose keys are hierarchy 
> levels, and whose values are those associated with the requested key at the 
> corresponding level.  Hash merging is supposedly included in Hiera 1.2, 
> which is now at release candidate stage, but I don't know what the API for 
> it looks like.
>

Although we're just dipping out toes into the Hiera waters, I think 
hiera_hash is exactly what we want.

Given this hiera.yaml:
---
:backends:
  - yaml
:yaml:
  :datadir: /etc/puppet/hieradata
:hierarchy:
  - %{::clientcert}
  - %{::environment}
  - common

and these yaml files:

lab.yaml
---
email_aliases:
    root: someone-e...@company.com

common.yaml
---
email_aliases:
    root: some...@company.com
    foo: f...@company.com
    bar: b...@company.com
 

And a manifest like this:
class mail::aliases ( $alias_list )
{
    file { '/etc/aliases':
        mode => 0644,
        owner => root,
        group => root,
        content => template('mail/aliases.erb')
    }

We could then do something like this:
node foo {
    $environment = 'lab'
    class{ 'mail::aliases':
        alias_list => hiera_hash( 'email_aliases' )
}

Node foo should have "root: someone-e...@company.com" for the root alias, 
but also still get foo and bar, because the hiera_hash() function will 
construct a hash from the Hiera data while preserving hierarchy order.  
Environment ("lab") occurs before common, so the "root" element of the 
email_aliases hash should be the one from the lab.yaml file.

We can -- indeed, must -- use declared-type declarations for our modules in 
order to benefit from hiera_hash() in this way.

The reason I was asking about include-type declarations was because we'd 
eventually like to consume some Puppet Forge modules.  To do so means we 
need an intermediary class that performs the hiera_hash() lookups and 
passes the values on to the destination module.  It would be neat if we 
could just name or Hiera values according to the module's parameter names 
and enjoy the magic of autolookup.

I just wanted to confirm that my understanding of the situation is 
correct.  If I'm wrong, I'd love to be corrected.

Thanks!
Scott


 

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to