Hi folks,

over the last couple of days I've been dabbling with the design
for a new module for Apache httpd: we use our own package & module
currently, which allows for multi-instance configurations, but are
trying to shift towards "standard" Ubuntu 2.4 package (I created a
ppa with a current version: 
https://launchpad.net/~apache-helpdesk/+archive/httpd-ppa )

I've been hitting a snag in the design, because httpd and many of
its modules are complex beasts, and I don't want to try and foresee every
single directive someone might want to use in templates / (defined) type / class
but rather have some form of matcher. Since most of the directives follow
simple patterns, I'd like to handle those, and reject everything else -
rather than handling everything explicitly as is the case now.

For a defined type, or a class, we could introduce the special variables
`$_` and `$*` (I'm not happy with those names. They are short, that's nice
but otherwise, they are too Perlesque, and not very speaking)

    define httpd::mod (
      $ensure   = 'enabled',
      $instance = 'default',
      $*  # all others
    ) {
      validate_re($ensure, 'enabled|disabled')

      Match {
        /_enabled$/ => { validate_bool($_) }
        /_path$/    => { validate_absolute_path($_) }
        /s$/        => { validate_array($_) }
        /_size$/    => { validate_number($_) }
        default     => { fail("${name} We really don't know what to make of 
this directive") } 
      }
    }

alternatively, we could match the front part:

    define httpd::directory (
       $ensure   = 'present',
       $instance = 'default',
       $*
    ) {
      # …
      Match {
        /(proxy|ssl|..)_/ => { httpd::mod { $1: ensure => $ensure, instance => 
$instance, $* }
      }
    }

This is kind of the basic idea, and it's lacking a good way to transform those
matches into actual variables we can access, but I hope you get the basic idea.


The main reason I wish this was supported syntax, is that a 
$catch_all_other_settings
hash generally translates poorly through all the layers of
yaml -> ruby -> puppet dsl -> actual config. The chances for very specific 
failures
are very high simply because of the amount of layers, each of which can 
introduce
their own implementation leak.

Highly welcome your feedback!



-- o/~ i
Igor Galić

Tel: +43 (0) 664 886 22 883
Mail: i.ga...@brainsware.org
URL: http://brainsware.org/
GPG: 8716 7A9F 989B ABD5 100F  4008 F266 55D6 2998 1641

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-dev/306231088.39368.1402493220564.JavaMail.zimbra%40brainsware.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to