Generate subclasses from hiera

42 views
Skip to first unread message

puppeteer123

unread,
Aug 16, 2015, 6:59:39 PM8/16/15
to Puppet Users
Is it posible to generate a subclass from a value in hiera?

i.e.


class yum (
  $subclass_name = undef,
) {
     class yum::repo::$subclass_name


I want to be able to create yumrepos individually without having to generate a template file for each one. 

Idea is:

include yum::repo::epel
include yum::repo::kernel

I haven't tested this, but wanted to see if anyone has tried this, if it will work, and any implications.

Thanks!

jcbollinger

unread,
Aug 17, 2015, 9:23:30 AM8/17/15
to Puppet Users
You should be able to interpolate Hiera data to form a class name, which you then use with the include() function or in the title of a resource-like class declaration.

However, you should not plan on a class parameterized with a single repository name.  Because each class can be declared at most once, that route limits you to declaring only one repository.


John

Reply all
Reply to author
Forward
0 new messages