Hi,

A bit of background, I'm trying to move from node inheritance to hiera. 
With node inheritance I could declare defined types at several levels, for 
example, say for all of preproduction I'd like a yum repository

*manifests/pre-prod.pp*
class preprod {
  yumrepo { 'preprod-repo': ... }
}

Then add other repos in various sub classes where other specialized 
yumrepo(s) are declared
*manifests/qa.pp*
class qa inherits preprod {
  yumrepo { 'qa': ... }
}

*manifests/dev.pp*
class dev inherits preprod {
  yumrepo {'dev': ... }
}

I'm having a hard time getting this to map to hiera cleanly. I'd like to 
have the data in the hierarchy something like this

*preprod.yaml*
yumrepo::name: preprod-repo
...

*qa.yaml*
yumrepo::name: qa-repo
...

My initial thought was to use hiera_include('classes'), but that doesn't 
work for defined types. What folks on superuser.com have 
suggested<http://serverfault.com/questions/549720/hiera-include-equivalent-for-resource-types/549727?noredirect=1#549727>is
 to define a wrapper class for *each* declaration of a defined type. 
Something like

class preprod_repo {
  yumrepo { 'preprod-repo': ... }
}

class qa_repo {
  yumrepo { 'qa-repo': ... }
}

Then in the yaml

*preprod.yaml*
classes:
 - preprod_repo
...

*qa.yaml*
classes:
 - qa_repo
...

I really don't want to define a class for every single type instantiation. 
What I'd prefer would be a single class that could capture a merged hash 
from all the yaml files and write out all the type declarations, but I'm 
having trouble with the implementation. From the yaml side, I've got what I 
want, something like this

*preprod.yaml*
classes:
 - yumrepo_hiera

yumrepo_hiera: {
  'preprod_repo' : {
     # attributes for preprod yum repo
  }
}

*qa.yaml*
classes:
 - yumrepo_hiera

yumrepo_hiera: {
  'qa_repo' : {
     # attributes for qa yum repo
  }
}

Now I'm passing an aggregate data object with all the data needed to the 
yumrepo_hieara class. Problem is how to write out all those type 
declarations. Since there's no looping in RDL. I know it's deprecated, but 
the Ruby DSL seems to be my best bet, yet I can't get the hash from hiera 
passed in.., I'm getting this error when I run the agent

undefined method `merge' for :yumrepo_hiera:Symbol

Here's what I've got so far, bear in mind I know nothing of Ruby, but 
hopefully you can get the idea

hostclass :yumrepo_hiera, :yumrepo_hiera do
   @yumrepo_hiera.each do |name, repo|
        yumrepo( :name,
                 repo[:descr],
                 # other parameters to yumrepo type...
         )       
   end
end

Can someone help me get off the ground with this Ruby DSL, or show me a 
better way in general, one where I don't have to write a class per each 
node declaration?

thanks,

-nathan

-- 
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/804125e1-6473-448c-954b-f2c85f249b7f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to