Hi,

On Fri, 2012-09-28 at 06:47 -0700, jcbollinger wrote:
> 
> 
> On Friday, September 28, 2012 3:31:11 AM UTC-5, pierre-emmanuel degand
> wrote:
>         Hi, I try to include or import a lot of configuration files in
>         a node, but it doesn't work :/
>         
>         
>         I create a module to configure bind, but i have a lot of
>         domains to configure in the node of my server, so i decided to
>         create an other module just to register my configuration with
>         1 file per domain (i have around 200 domains, so arount 200
>         files...). 
>         
>         
>         My tree (for the configuration module) : 
>         module/
>                 conf_bind/
>                         manifests/
>                                 init.pp
>                                  bind/
>                                         domain1_conf.pp
>                                         ...
>                                         domain200_conf.pp
>         
>         
>         Init.pp :
>         class conf_bind {
>         }


Ouch, that looks like a painful way to do it.

> You don't describe the contents of your bind/domainX_conf.pp
> manifests, but with the layout you describe, each should be of this
> form:
> 
> class conf_bind::bind::domainX_conf {
>   # declarations for configuring domain X...
> }
> 
> Then in the module's init.pp you would have:
> 
> class conf_bind {
>   include 'conf_bind::bind::domain1_conf'
>   include 'conf_bind::bind::domain2_conf'
>   # ...
>   include 'conf_bind::bind::domain200_conf'
> }
> 
> Puppet DSL does not provide a way to use pattern matching to assign
> classes to nodes, and it does not provide for textual interpolation in
> the manner of the C preprocessor's "#include" directive.  In
> particular, Puppet's 'include' function performs a fundamentally
> different job than does cpp's "#include".

So, John answered the question you actually asked, and I'm going to try
to answer the question you probably should have asked, which is, "what
is the smart way to achieve this?"

I think you probably want a custom type with enough parameters to
satisfy your particular needs.  Eg, if the master is always the same and
the slaves are always the same, all you really need is the domain name.
If you need more parameterization per domain, you could make zones be a
hash with the additional information keyed carried in it.

I'd set it up something like:

class bind::params {
        $domains = [
                domain1,
                ...,
                domain200,
        ]
}

class bind {
        package { 'bind': }
        service { 'bind': }
}

define bind::master_zone {
        include bind

        file { "/etc/bind9/zones/masters/${name}.conf":
                content => template('bind/master_zone.conf.erb'),
                notify  => Service['bind']
        }
}

define bind::slave_zone {
        include bind

        file { "/etc/bind9/zones/slaves/${name}.conf":
                content => template('bind/slave_zone.conf.erb'),
                notify  => Service['bind']
        }
}


class bind::master {
        include bind
        include bind::params

        $zones = $bind::params::zones
        bind::master_zone { $zones }
}

class bind::slave {
        include bind
        include bind::params

        $zones = $bind::params::zones
        bind::slave_zone { $zones }
}

This is off the top of my head, and leaves out an awful lot of
boilerplate.  Hopefully you see what I'm trying to say and it gets you
to somewhere more manageable.

Cheers,
-- 
Stephen Gran
Senior Systems Integrator - guardian.co.uk

Please consider the environment before printing this email.
------------------------------------------------------------------
Visit guardian.co.uk - newspaper of the year

www.guardian.co.uk    www.observer.co.uk     www.guardiannews.com 

On your mobile, visit m.guardian.co.uk or download the Guardian
iPhone app www.guardian.co.uk/iphone and iPad edition www.guardian.co.uk/iPad 
 
Save up to 37% by subscribing to the Guardian and Observer - choose the papers 
you want and get full digital access. 
Visit guardian.co.uk/subscribe 

---------------------------------------------------------------------
This e-mail and all attachments are confidential and may also
be privileged. If you are not the named recipient, please notify
the sender and delete the e-mail and all attachments immediately.
Do not disclose the contents to another person. You may not use
the information for any purpose, or store, or copy, it in any way.
 
Guardian News & Media Limited is not liable for any computer
viruses or other material transmitted with or as part of this
e-mail. You should employ virus checking software.

Guardian News & Media Limited

A member of Guardian Media Group plc
Registered Office
PO Box 68164
Kings Place
90 York Way
London
N1P 2AP

Registered in England Number 908396

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to