Re: [Puppet Users] Re: defined types and enc

erkan yanar
Sat, 10 Nov 2012 03:15:07 -0000

Thx for your patience.
On Fri, Nov 09, 2012 at 06:23:21AM -0800, jcbollinger
wrote:
>
>
> On Thursday, November 8, 2012 6:29:47 PM UTC-6, erkules wrote:
> >
> > Hi, Im still confused:
> >
> > On Fri, Oct 26, 2012 at 12:24:52PM -0700, jcbollinger wrote:
> > >
> > >
> > > On Friday, October 26, 2012 11:32:36 AM UTC-5, erkules wrote:
> > > >
> > >
> > > > If not is there a trick to call a class many times for a
node. (Maybe
> > by
> > > > manipulating the name?)
> > > >
> > > >
> > > You can create classes with different names but similar content,
or you
> > can
> > > use one class that wraps all the resources you want.  For
example,
> > >
> > > class mymodule::lxc_application_containers {
> > >   mymodule::lxc_application_container { ''container1:
> > >     application => ''Awesomeness1.1''
> > >     # other parameters
> > >   }
> > >   mymodule::lxc_application_container { ''container2:
> > >     application => ''Moneymaker3.2''
> > >     # other parameters
> > >   }
> > >   # other containers ...
> > > }
> > >
> > > Supposing that the point is to select a subset of the available
> > > applications for each target node, using the one-class approach,
you can
> > do
> > > that via global variables (yuck), class parameters (meh), or data
from
> > an
> > > external source (best bet).
> >
> > So you got a fixed number in here where you filter the right ones?
> >
>
>
> Ideally, you know what the right ones are and your class declares only
> those.  You can, however, use one or another sort of conditional to choose
> which of the possible ones to declare.
>
>
>
> > I would like to call the class with parameters  and for each parameter
> > the defined type is called. Where a parameter is a hash with 3 keys
(where
> > one is the name).
> >
>
>
> That sounds a lot like the behavior of the built-in create_resources()
> function.  Look it up in the Puppet function reference.

++

>
>
>
> > With this I could decide to run more or less containers just by adding
> > parameters.
> >
>
>
> Puppet classes and definitions do not have varargs support.  All the
> parameters they can accept must be pre-defined, though you can assign
> default values to them so that you don''t need to declare each one
each
> time.  Puppet does support arrays and hashes, however, and these can be
> assigned as parameter values.

great

>
>
> >
> > I don''t know if this is a possible way to implement my needs
*kopfkraz*
> >
> >
> It would help if you were clearer about what your actual needs *are*.  I
> have given you rather a lot of information about how you can approach your
> task with Puppet, but you remain unsatisfied.  If I have not been speaking
> to your issue then it is because I don''t know what your issue is.

Ups sorry for the confusion.
Right now Ive got defines like:

 lxc_builder{''starter01'': ensure =>
''define'', ipadd=>''10.0.3.101/24'' }
 lxc_builder{''starter02'': ensure =>
''define'', ipadd=>''10.0.3.102/24'' }
 lxc_builder{''starter03'': ensure =>
''define'', ipadd=>''10.0.3.103/24'' }
 lxc_builder{''starter04'': ensure =>
''define'', ipadd=>''10.0.3.104/24'' }

The build an LXC application container on the host.
This works sufficient. Depending of the host there can be easily 100 Containers
on
every host. (It is no KVM :)

So adding a container is writing a new line.

My intention was to put my configuration into an ENC.
Thats where the trouble started, as no place for defined types in ENC.

And now I wonder how a class would look like to transform my defined types into
a representation suitable for ENC


thx a lot