Ellison is right, it really doesn't make much sense to create one resource 
with create_resources.  In fact, I'm not even sure it will work with 
classes because I've never tried it.  However, it works great for defined 
types.  I think I understand what you're trying to do so let me give an 
example of how you could accomplish it.

I *think* your goal is to be able to define not only parameters in hiera 
but also classes to be applied to a node.  You need an additional piece in 
your site.pp file to do this. 

include hiera_array('classes',['hiera','puppet'])
The array at the end is optional, and represents defaults.  In our case, we 
included hiera and puppet classes as defaults because there was a chicken 
and the egg scenario on the puppet master.  That's above and beyond this 
example, though.  What the above will do is collect all values defined as 
an array called "classes" from hiera.  It will merge results all the way 
down the hierarchy so you can define your 'base' classes in your global 
hiera file and get more specific as you go down and it will all be picked 
up.  In hiera, define classes like this:
---
classes:
  - 'class1'
  - 'class2::foo'
  - 'class3::bar'
  - etc

Then you can go about adding any parameters that need defined for those 
classes:

class1::param1: 'boom'
class2::array1:
  - 'foo'
  - 'bar'
  - 'baz'
class2::param2: 'thing'

That's it.  You're done.  I hope this helps.  Please let me know if you 
need more help with this example.  

On Monday, February 11, 2013 7:58:08 PM UTC-6, Ygor wrote:
>
> OK.  Lets try it like this: 
>
> <whatever>.pp 
> ------------------------- 
> class main_class_foo::subclass_one ( 
>         $parameter_one_a, 
>         $parameter_one_b 
> ) { 
>  ... 
> } 
>
> class main_class_foo::subclass_two ( 
>         $parameter_two_a, 
>         $parameter_two_b 
> ) { 
>  ... 
> } 
> ------------------------- 
>
> <whatever>.yaml 
> ------------------------- 
> main_class_foo: 
>         subclass_one: 
>                 parameter_one_a: this 
>                 parameter_one_b: that 
>         subclass_two: 
>                 parameter_two_a: other 
>                 parameter_two_b: whatever 
> ------------------------- 
>
>
> <another-whatever>.pp 
> ------------------------- 
> $main_class_stuff = hiera_hash ( 'main_class_foo' ) 
> create resources (main_class_foo, $main_class_stuff ) 
>
> Main_class_foo <| |> 
> ------------------------- 
>
> Or do I need to do it like this: 
>
> Same <whatever>.pp 
>
> <whatever>.yaml 
> ------------------------- 
> main_class_foo::subclass_one: 
>         parameter_one_a: this 
>         parameter_one_b: that 
> main_class_foo::subclass_two: 
>         parameter_two_a: other 
>         parameter_two_b: whatever 
> ------------------------- 
>
> <another-whatever>.pp 
> ------------------------- 
> $main_class_one_stuff = hiera_hash ( 'main_class_foo::subclass_one’ ) 
> create resources (main_class_foo::subclass_one, $main_class_one_stuff ) 
>
> $main_class_two_stuff = hiera_hash ( 'main_class_foo::subclass_two' ) 
> create resources (main_class_foo::subclass_two, $main_class_two_stuff ) 
>
> Main_class_foo::Subclass_one <| |> 
> Main_class_foo::Subclass_two <| |> 
> ------------------------- 
>
> On Feb 11, 2013, at 5:00 PM, Ellison Marks wrote: 
>
> > I don't see your spaceship, but that aside, I believe that your create 
> resources call will try to instantiate two main_class_foo classes, named 
> subclass_one and subclass_two, with the listed parameters. I don't think 
> you can use create_resources to instantiate different kinds of classes. 
> > 
> > On Monday, February 11, 2013 11:41:33 AM UTC-8, Ygor wrote: 
> > OK, I have a collection of related classes -- 
> > 
> > main_class_foo::subclass_one 
> > main_class_foo::subclass_two 
> > ... etc 
> > 
> > And each subclass has parameters, 
> > 
> > class main_class_foo::subclass_one ( $parameter_one_a, $parameter_one_b 
> ) { ... } 
> > class main_class_foo::subclass_two ( $parameter_two_a, $parameter_two_b 
> ) { ... } 
> > 
> > 
> > so can I make a hiera file like this: 
> > 
> > 
> > main_class_foo: 
> >     subclass_one: 
> >         parameter_one_a: this 
> >         parameter_one_b: that 
> >     subclass_two: 
> >         parameter_two_a: other 
> >         parameter_two_b: whatever 
> > 
> > ...and then load it with create_resources and instantiate it with an 
> empty spaceship operator like this: 
> > 
> > $main_class_stuff = hiera_hash ( 'main_class_foo' ) 
> > create resources (main_class_foo, $main_class_stuff ) 
> > 
> > Is that correct ? 
> > 
> > “Sometimes I think the surest sign that intelligent life exists 
> elsewhere in the universe is that none of it has tried to contact us.” 
> > Bill Waterson (Calvin & Hobbes) 
> > 
> > 
> > -- 
> > 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...@googlegroups.com <javascript:>. 
> > To post to this group, send email to 
> > puppet...@googlegroups.com<javascript:>. 
>
> > Visit this group at http://groups.google.com/group/puppet-users?hl=en. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> >   
> >   
>
>

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