Skip to content

A success story for Config::Model

April 20, 2012

Hello

Here’s a mail telling how the Config::Model Perl module was used to refactor existing configuration tools in Perl. Some punctuation and blank lines were added to improve the flow of this text. The full name and mail address of gkr is withheld on his request.

I took over a perl script that was responsible to pull data from several sources and push it after validation and re-packaging including some meta data into one of our production systems.

The script was never intended to be used for more then a few month. But as things go, we were still using it after a few years. Only now for a lot more sources. Since all the configuration of sources and meta data were contained as a single hash in this script, it became very unwieldy. Although the configuration seldom changed, once it got added it was not an option to keep it like this especially as we decided to prepare a Debian package for faster installation and version tracking. So I had to re-work it and was looking for some library that was allowing me to define how the configuration has to look like, providing sensible hard coded and computed defaults for some of the values.

This was when I found Config::Model on Cpan. It was, after some digging into the documentation, quite simple to define a rough first version of the complete config, including global default values as ini file and very simple to read in and write out. A more advanced version was not working because the Config::Model in Debian squeeze did not provide needed features.

Switching to yaml as configuration file format not only increased readability but also worked with the standard Squeeze package. Consistency is checked automatically inside the model so broken configurations are more unlikely in the future.

Of course I had some work re-factoring the original source but Config::Model allowed an easy addition of a value-checked and documented configuration file. To access the Config::Model::Instance I added small wrapper packages that allowed an easy access of the config elements by name to make the source easier to understand. The re-factoring needed for creating a Debian package for the Script – which is now a set of modules and a small executable – was simple once I had Config::Model working, since I was able to add new configuration items effortlessly and remove a lot of hard coded parameters.

I don’t use the cli tool yet for configuration editing but that’s going to be the next step.

Many thanks to gkr for this feedback. Let’s hope he will continue to give feedback on his usage of Config::Model.

All the best

From → Config::Model, Perl

3 Comments
  1. Indeed a success story. Planning on learning PERL but I find the learning curve a bit steep.

    • You don’t need Perl knowledge to use Config::Model to edit you configuration files with available models (e.g. OpenSsh, approx, multistrap…)

      You should not need Perl knowledge to create a configuration model for your own project, provided:

      • you use config-model-edit GUI to create your configuration model ( provided by Config::Model::Itself)
      • a backend for the configuration files(s) of your application is already available (i.e. ini files, shell variables, yaml, Perl data structure)

Trackbacks & Pingbacks

  1. Dominique Dumont: A success story for Config::Model | Linux-Support.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: