next up previous
Next: pica.conf Up: Configuration Previous: Basic syntax

The Perl PreProcessor

This PICA component is the one that reads your files first, to transform them into what PICA will really read. In fact, is a Perl sub (well, two), not an independent program or CPAN module or something. The idea is being able to change (in a general and efficient way) the configuration files, depending on variables (yes, local variables) and some other checks. All of that, using arbitrary Perl expressions, that can not only return boolean values for conditions, but also generate part of the configuration or distribution files.

As the preprocessor is used on every PICA configuration and distribution file, the results become terribly dynamic. Imagine generating a configuration file for your servers, based on the name of the host, the name of the final file to be installed, the time of the day or some other external file or condition! You have all the power of Perl in your hands!

The directives recognized by PPP are:

To support your nifty conditions, there are sub definitions (actually, only two, ingroup and members) and some variables ($picahost and $picaobject, only defined for objects.conf; more on that later). Subs are defined in, a special module to put all of that stuff, placed in the PICA directory, usually /var/lib/pica. The user is supposed to modify that file if he wants to add a new function. The current list of defined subs is:

Takes one argument and returns true if the current processing host (that is, picahost) belongs to the given group.
Takes one argument, and returns the list of members of the given group, or "" if there aren't any.

To add a function, you have to write it in and add it to the EXPORT and EXPORT_OK variables. Moreover, if you want to access a new variable, you'll have to make a glob to see it and be able to modify it's value. You can copy and paste the current subs and globs.

next up previous
Next: pica.conf Up: Configuration Previous: Basic syntax
Esteban Manchado Velázquez 2002-12-13