Importing configuration data

Although eBox UI interface greatly eases the system administrator work, some configuration tasks through the interface can be tedious if you have to perform them a large number of times. For example, adding 100 new user accounts or enabling an e-mail account for all of them could be one of these tasks.

These tasks can be automated easily through the Application Programming Interface (API) which is provided by eBox. You only need a basic knowledge of Perl [1], and to know the public methods exposed by the eBox modules you want to use. In fact, eBox web interface uses the same programming interface.

[1]Perl is a high-level, general-purpose, interpreted, dynamic programming language. http://www.perl.org/

An example on how to create a small utility is shown below, using the eBox API to automatically add an arbitrary number of users defined in a Comma Separated Values (CSV) file

#!/usr/bin/perl

use strict;
use warnings;

use EBox;
use EBox::Global;

EBox::init();
my $usersModule = EBox::Global->modInstance('users');

my @users;
open (my $USERS, 'users');

while (my $line = <$USERS>) {
    chomp ($line);
    my $user;
    my ($username, $givenname, $surname, $password) = split(',', $line);
    $user->{'user'} = $username;
    $user->{'givenname'} = $givenname;
    $user->{'surname'} = $surname;
    $user->{'password'} = $password;
    push (@users, $user);
}
close ($USERS);

foreach my $user (@users) {
    $usersModule->addUser($user, 0);
}

1;

Save the file with the name bulkusers and grant it execution permission using the following command: chmod +x bulkusers.

Before running the script, you must have a file called users in the same directory. The appearance of this file should be as follows:

jfoo,John,Foo,jfoopassword,
jbar,Jack,Bar,jbarpassword,

Finally, you must be in the directory where files are placed and run:

sudo ./bulkusers

This section has shown a small example of task automation using the eBox API, but the possibilities are almost unlimited.

Service Advanced Customization

This section discusses two options for system customization for those users with special requirements:

  • Tailor service configuration files managed by eBox Platform.
  • Perform actions in the process of saving changes in configuration.

When a module is responsible for automatically setting up a service, it tries to cover the most common configuration options. Furthermore, there are cases where there are so many configuration settings that it would be impossible for eBox to control them all. In addition to this, one of the eBox platform goals is simplicity. However, there are users who want to adjust some of those unhandled parameters to adapt eBox to their requirements. One of the possibilities is editing directly the configuration files which handle the service.

Before deciding to modify manually a configuration file, you must understand how eBox works internally. The eBox modules, once enabled, overwrite the original system configuration files for the services they manage. They do this through templates that essentially contain the basic structure of a typical configuration file for the service. However, some of their parts are parameterized through variables. The values of these variables are assigned before overwriting the file, taken from the configuration previously set using the eBox web interface.

How the configuration template system works

How the configuration template system works

Therefore, if you want to make your changes persistent, and prevent them from being overwritten every time eBox saves changes, you must edit such templates instead of system configuration files. Those templates are in /usr/share/ebox/stubs and their names are the original configuration file names plus the .mas extension.

It should be remembered that although we make these changes in templates, those changes will be lost if an upgrade is performed. Installing a new module version will overwrite all template files. Thus it is recommended to keep a backup copy of your modifications in order to restore them after the upgrade.

It is possible that you need to perform certain additional actions while eBox is saving changes instead of customizing configuration files. For example, when eBox saves changes related to the firewall, the first thing the firewall module does is to remove all existing rules, and then add the ones configured in eBox. If you manually add a custom iptables rule that is not covered by eBox interface, it will disappear when saving firewall module changes. To prevent that, eBox let us run scripts while the saving changes process is being performed. There are six points during the process when you may execute those scripts, also known as hooks. Two of them are general and the remainder 4 ones are per module:

Before saving changes:
In /etc/ebox/pre-save directory all scripts with running permissions are run before starting the save changes process.
After saving changes:
Scripts with running permissions in /etc/ebox/post-save directory are executed when the process is finished.
Before saving module configuration:
Writing /etc/ebox/hooks/<module>.presetconf file being <module> the module name you want to tailor, the hook is executed prior to overwriting the module configuration. It is the ideal time to modify configuration templates from a module.
After saving module configuration:
/etc/ebox/hooks/<module>.postsetconf file is executed after saving <module> configuration.
Before restarting the service:
/etc/ebox/hooks/<module>.preservice is executed. This script could be useful to load Apache modules, for instance.
After restarting the service:
/etc/ebox/hooks/<module>.postservice is executed. In the firewall case, all the extra rules must be added here.

As you can imagine, these operations have a great potential and allow you to highly customize eBox operation in order to be better integrated with the rest of the system.

Environment for new modules development

This chapter has shown how to resolve some of the configuration limitations from eBox modules. But it is possible that modules provided by eBox may not cover all our needs. This is a big deal, since eBox is designed to have extensibility in mind and it is relatively simple to create new modules.

Anyone with Perl language knowledge may take advantage of the eBox framework to create web interfaces, and also benefit from the integration with the rest of the modules and the common features from the vast eBox library.

eBox design is completely object-oriented and it takes advantage of the Model-View-Controller (MVC) design pattern [2], so the developer only needs to define those features required by the data model. The remaining parts are generated automatically by eBox. As if this was not enough, a development tool called emoddev [3] is provided to ease much more the development of new modules, auto-generating templates depending on the parameters provided by the user. This is a great time saver, however, its explanation and development is out of the scope of this course.

[2]An explanation about Model-View-Controller design pattern http://en.wikipedia.org/wiki/Model_View_Controller.
[3]emoddev SVN repository access svn://svn.ebox-platform.com/ebox-platform/trunk/extra/moddev.

eBox is designed to be installed on a dedicated machine. This recommendation is also extended to the developing scheme. Developing on the same host is completely discouraged. A virtual system to develop is the recommended option as virt-chapter-ref explains deeply.

Bug management policy

Each open source software project has its own bug management policy.

Ubuntu may have more than one version considered as stable and maintained at the same time. That is, maintained means that when a new bug is found, a new public update is released to fix it. Updates will be covered in depth below. These stable versions are supported for a length of time which depends on the kind of the release.

eBox has a single stable version. Some modifications are added to this version to fix several detected bugs. This happens until a new release is published, which already has all these fixes.

The project management tool Trac [4] is used by the eBox development team to manage bugs and their own tasks. It lets users open tickets to report problems and it is opened to all users. Once the ticket is created by a user, its state can be tracked by the user through the web or e-mail. You may reach the eBox Platorm Trac at http://trac.ebox-platform.com.

[4]Trac: is an enhanced Viki and issue tracking system for software development projects http://trac.edgewall.org.

Ubuntu, however, uses Launchpad [5], a tool developed and supported by Canonical to manage their bugs:

[5]Launchpad is available at https://launchpad.net.

It is highly recommended to report a bug when you are fairly sure that your problem is easily reproduced. You should provide detailed instructions to reproduce it. In addition, you should make sure that your problem is really a bug and not just an expected result from the program under determined circumstances. Finally, it would be even better to provide a solution for your problem. This could be done by modifying the application itself through a patch or by following some steps to avoid the problem temporarily (workaround).

Patches and security updates

A patch is a modification in the source code in order to fix a bug or add a new feature to that software. In open source projects, community members are able to send patches to the project maintainers and if they consider the patches suitable, then they will be merged into the application.

Developers themselves often publish official patches too, for example, fixing a known vulnerability. But, typically, what is done in projects such as eBox or Ubuntu is to release a new version of the package including the official patch.

The Ubuntu policy for their official releases is to publish updates to fix security bugs.

By default, when a stable version of Ubuntu is installed, the system is prepared to install security updates afterwards. There is a file called /etc/apt/sources.list where the repositories to get packages from are defined. This file should include a line to specify the security updates similar to the following one:

deb http://security.ubuntu.com/ubuntu/ hardy-security universe main multiverse restricted

You may check out the new updates and install them, as aptitude-ref explains, but if you have eBox installed, then you can manage them using the web interface through the software module [6].

[6]Section Software updates shows this module in depth.

Community support or commercial support

Open source software usually provides technical support to the application users through different means. Ubuntu and eBox are not an exception.

We must distinguish between two kinds of support: the one provided to the community, which is free, and the commercial one where a company offers its services by charging a certain amount of money.

Community support

Community support is provided mainly on the Internet. There are many occasions where the community is able to support itself. That is, application users help each other without an interest. The product development team has usually the main role in the community though.

The community provides an important, even fundamental, improvement in the product development. Users contribute by discovering bugs hidden until that moment and help developers to improve the product so it becomes more attractive to more users.

This uninterested support, logically, does not offer any guarantees. If a user asks a question, it is possible that no reply is given depending on the question format, timing or any other circumstance.

The most typical community support channels are forums, mailing lists and IRC [7] channels.

[7]Internet Relay Chat (IRC) is a real-time communication protocol based on text where users are usually discussing in a defined channel RFC 1459.

These are the main community resources for eBox Platform:

All this information is available, with further documentation, in the community section of the eBox platform web site (http://ebox-platform.com/community/).

Commercial support

The commercial support lets user use other channels, apart from the Internet, to obtain support from a company. Phone and physical presence in client facilities are also possible.

Unlike community support, the commercial support offers several guarantees as follows:

  • Maximum response time: depending on the service package that time will be shorter or longer.
  • Well-trained supporting people: in some cases the development team will be giving the support, otherwise well-trained and certified people will do so.
  • Additional features which add value to the product and are not available to the community.

These advantages are pretty clear for those companies whose business relies on this software. In addition to this, commercial support ensures no time wasted trying to figure out what is going wrong with your installation.

Exercises

Exercise A

Create and run the bulkusers script with the users file and check in the eBox interface that the users have been added correctly.

Exercise B

Create a virtual mail domain and add all users from file users to this virtual domain.

Exercise C

Modify bulkusers script to remove all created users. Check that there are no users left in the system.

Exercise D

Edit Mason template /usr/share/ebox/stubs/dns/named.conf.options.mas adding the following line to the number 3 within options section:

allow-recursion { none; };

Restart the dns module from web interface. Check you are unable to make external queries to your DNS service. For example, using the dig command:

dig @localhost www.google.es
   ; <<>> DiG 9.4.2 <<>> @localhost www.google.es
   ; (1 server found)
   ;; global options:  printcmd
   ;; Got answer:
   ;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 18671
   ;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
   ;; WARNING: recursion requested but not available

   ;; QUESTION SECTION:
   ;www.google.es.                 IN      A

   ;; Query time: 10 msec
   ;; SERVER: 127.0.0.1#53(127.0.0.1)
   ;; WHEN: Wed Mar 25 21:15:54 2009
   ;; MSG SIZE  rcvd: 31

Exercise E

Make the previous modification using hooks and the sed application to modify the template in runtime.

Exercise F

Create a script called 0001-date.sh in /etc/ebox/post-save whose content is the following one:

#!/bin/bash

date >> /tmp/restart-eBox.log

Verify that the script is run after saving changes. Which permission set is /tmp/restart-eBox.log created with?

Exercise G

Create a script to add specific rules to the firewall which are impossible to be set using the eBox web interface, for example, using the SNAT iptables module.

English

Table Of Contents

Other documents