OTRS : mise en place d'un outil de ticketing

From Deimos.fr / Bloc Notes Informatique
Jump to: navigation, search
OTRS

Software version 2.4.14
Operating System Debian 6
Website OTRS Website
Last Update 31/10/2012
Others

1 Introduction

Open-source Ticket Request System (OTRS, littéralement « système open source de requêtes par tickets »), est un logiciel open source de gestion de la relation client ou de gestion des services d'assistance. Une entreprise, une organisation ou une institution peuvent l'utiliser pour assigner des « tickets » aux requêtes qui leur sont faites via le centre d'assistance ou le service de dépannage. Ce système permet de faciliter le traitement des demandes d'assistance ou de dépannage et toute demande faite par téléphone ou courrier électronique. OTRS est distribué sous GNU Affero General Public License.[1]

Pour la mise en place de cette version, j'ai utilisé la documentation officielle[2] et y ai apporté quelques petites retouches.

2 Prérequis

Vérifez que vos locales sont correctement définies :

Command dpkg-reconfigure
dpkg-reconfigure locales

3 Installation

Nous allons avoir besoin de ces packages :

Command aptitude
aptitude install libapache2-mod-perl2 libdbd-pg-perl libnet-dns-perl libnet-ldap-perl libio-socket-ssl-perl libpdf-api2-perl libsoap-lite-perl libgd-text-perl libgd-graph-perl libapache-dbi-perl postgresql aspell aspell-en dbconfig-common dictionaries-common javascript-common libalgorithm-diff-perl libalgorithm-diff-xs-perl libaspell15 libauthen-sasl-perl libbit-vector-perl libcarp-clan-perl libcrypt-passwdmd5-perl libdate-pcalc-perl libemail-valid-perl libio-socket-inet6-perl libjs-prototype libjs-yui libmail-pop3client-perl libnet-domain-tld-perl libnet-imap-simple-perl libnet-imap-simple-ssl-perl libnet-smtp-ssl-perl libsocket6-per libtext-csv-perl libtext-csv-xs-perl libtext-diff-perl libxml-feedpp-perl libxml-treepp-perl procmail wwwconfig-common

Vous noterez que j'utilise PostgreSQL et non pas MySQL. Ensuite nous installons OTRS (j'ai volontairement pas prit la dernière version, mais vous pouvez le faire sans soucis) :

Command
useradd -r -d /opt/otrs/ -c 'OTRS user' otrs
usermod -g www-data otrs
cd /opt
wget http://ftp.otrs.org/pub/otrs/otrs-2.4.14.tar.gz
tar -xzf otrs-2.4.14.tar.gz
rm -f otrs-2.4.14.tar.gz
mv otrs-* otrs && cd otrs
cp Kernel/Config.pm.dist Kernel/Config.pm
cp Kernel/Config/GenericAgent.pm.dist Kernel/Config/GenericAgent.pm
perl bin/SetPermissions.pl --otrs-user=otrs --otrs-group=otrs --web-user=www-data --web-group=www-data /opt/otrs

4 Configuration

4.1 Apache

Nous allons créer cette configuration dans Apache :

Configuration File /etc/apache2/conf.d/otrs
# --
# added for OTRS (http://otrs.org/)
# $Id: apache2-httpd-new.include.conf,v 1.5 2008/11/10 11:08:55 ub Exp $
# --
 
# agent, admin and customer frontend
ScriptAlias /otrs/ "/opt/otrs/bin/cgi-bin/"
Alias /otrs-web/ "/opt/otrs/var/httpd/htdocs/"
 
# if mod_perl is used
<IfModule mod_perl.c>
 
    # load all otrs modules
    Perlrequire /opt/otrs/scripts/apache2-perl-startup.pl
 
    # Apache::Reload - Reload Perl Modules when Changed on Disk
    PerlModule Apache2::Reload
    PerlInitHandler Apache2::Reload
    PerlModule Apache2::RequestRec
 
    # set mod_perl2 options
    <Location /otrs>
        ErrorDocument 403 /otrs/index.pl
        ErrorDocument 404 /otrs/index.pl
        SetHandler  perl-script
        PerlResponseHandler ModPerl::Registry
        Options +ExecCGI +FollowSymLinks
        PerlOptions +ParseHeaders
        PerlOptions +SetupEnv
        Order allow,deny
        Allow from all
       #<IfModule mod_rewrite.c>
       #   RewriteEngine On
       #   RewriteCond /usr/share/otrs/var/httpd/htdocs/maintenance.html -l
       #   RewriteRule ^.*$ /otrs-web/maintenance.html
       #</IfModule>
    </Location>
 
</IfModule>
 
# directory settings
<Directory "/opt/otrs/bin/cgi-bin/">
    AllowOverride None
    Options +ExecCGI -Includes
    Order allow,deny
    Allow from all
</Directory>
<Directory "/opt/otrs/var/httpd/htdocs/">
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

Puis on redémarre apache :

Command service
service apache2 restart

4.2 PostgreSQL

Nous allons configurer la partie authentification :

Configuration File /etc/postgresql/8.4/main/pg_hba.conf
[...]
# Database administrative login by UNIX sockets
local   all         postgres                          ident
 
# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
 
# OTRSlocal   otrs    otrs    md5host    otrs    otrs    127.0.0.1/32    md5# "local" is for Unix domain socket connections only
local   all         all                               ident
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5

Et créer les utilisateurs, bases, donner les accès :

Command
su postgres
psql
create user otrs password 'otrs' nosuperuser;
create database otrs owner otrs;

Puis nous redémarrons le tout pour s'assurer la nouvelle configuration est active :

Command
service postgresql restart

Et enfin, nous importons les schemas :

Command psql
psql -U otrs -W -f scripts/database/otrs-schema.postgresql.sql otrs
psql -U otrs -W -f scripts/database/otrs-initial_insert.postgresql.sql otrs
psql -U otrs -W -f scripts/database/otrs-schema-post.postgresql.sql otrs

4.3 OTRS

Il ne reste plus qu'à configurer OTRS. Ici j'ai mis du LDAP :

Configuration File /opt/otrs/Kernel/Config.pm
# --
# Kernel/Config.pm - Config file for OTRS kernel
# Copyright (C) 2001-2009 OTRS AG, http://otrs.org/
# --
# $Id: Config.pm.dist,v 1.21 2009/02/16 12:01:43 tr Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --
#  Note:
#
#  -->> OTRS does have a lot of config settings. For more settings
#       (Notifications, Ticket::ViewAccelerator, Ticket::NumberGenerator,
#       LDAP, PostMaster, Session, Preferences, ...) see
#       Kernel/Config/Defaults.pm and copy your wanted lines into "this"
#       config file. This file will not be changed on update!
#
# --
 
package Kernel::Config;
 
sub Load {
    my $Self = shift;
    # ---------------------------------------------------- #
    # ---------------------------------------------------- #
    #                                                      #
    #         Start of your own config options!!!          #
    #                                                      #
    # ---------------------------------------------------- #
    # ---------------------------------------------------- #
 
    # ---------------------------------------------------- #
    # database settings                                    #
    # ---------------------------------------------------- #
    # DatabaseHost
    # (The database host.)
    $Self->{DatabaseHost} = 'localhost';
    # Database
    # (The database name.)
    $Self->{Database} = 'otrs';
    # DatabaseUser
    # (The database user.)
    $Self->{DatabaseUser} = 'otrs';
    # DatabasePw
    # (The password of database user. You also can use bin/CryptPassword.pl
    # for crypted passwords.)
    $Self->{DatabasePw} = 'otrs';
    # DatabaseDSN
    # (The database DSN for MySQL ==> more: "man DBD::mysql")
    #$Self->{DatabaseDSN} = "DBI:mysql:database=$Self->{Database};host=$Self->{DatabaseHost};";
 
    # (The database DSN for PostgreSQL ==> more: "man DBD::Pg")
    # if you want to use a local socket connection
    $Self->{DatabaseDSN} = "DBI:Pg:dbname=$Self->{Database};";
    # if you want to use a tcpip connection
#    $Self->{DatabaseDSN} = "DBI:Pg:dbname=$Self->{Database};host=$Self->{DatabaseHost};";
 
    # ---------------------------------------------------- #
    # fs root directory
    # ---------------------------------------------------- #
    $Self->{Home} = '/opt/otrs';
 
    # ---------------------------------------------------- #
    # insert your own config settings "here"               #
    # config settings taken from Kernel/Config/Defaults.pm #
    # ---------------------------------------------------- #
    # $Self->{SessionUseCookie} = 0;
    # $Self->{CheckMXRecord} = 0;
 
    # ---------------------------------------------------- #
 
    # ---------------------------------------------------- #
    # data inserted by installer                           #
    # ---------------------------------------------------- #
    # $DIBI$
 
    ##############
    # AGENT PART #
    ##############
    # Permet de définir la vue Agent (accessible via index.pl)
 
    $Self->{SecureMode} = 1;
    $Self->{FQDN} = 'ldap.deimos.fr';
    $Self->{AdminEmail} = 'deimos@deimos.fr';
    $Self->{ProductName} = 'Deimosfr';
    $Self->{DefaultLanguage} = 'fr';
    $Self->{DefaultCharset} = 'utf-8';
    $Self->{'LogModule::SysLog::Charset'} = 'utf-8';
    $Self->{'AuthModule::LDAP::Charset'} = 'utf-8';
    $Self->{'AuthSyncModule::LDAP::Charset'} = 'utf-8';
 
    $Self->{'AuthModule'} = 'Kernel::System::Auth::LDAP';
    $Self->{'AuthModule::LDAP::Host'} = 'ldap.deimos.fr';
    $Self->{'AuthModule::LDAP::BaseDN'} = 'ou=users,dc=deimos,dc=fr';
    $Self->{'AuthModule::LDAP::UID'} = 'uid';
    $Self->{'AuthModule::LDAP::UserLowerCase'} = 1;
    $Self->{'AuthModule::LDAP::Params'} = {
        port    => 389,
        timeout => 120,
        async   => 0,
        version => 3,
    };
 
    #############
    # SYNC PART #
    #############
    # Le sync permet de synchroniser en base de données les informations des customers une fois l'authentification réussie
 
    $Self->{'AuthSyncModule'} = 'Kernel::System::Auth::Sync::LDAP';
    $Self->{'AuthSyncModule::LDAP::Host'} = 'ldap.deimos.fr';
    $Self->{'AuthSyncModule::LDAP::BaseDN'} = 'ou=users,dc=deimos,dc=fr';
    $Self->{'AuthSyncModule::LDAP::UID'} = 'uid';
    $Self->{'AuthSyncModule::LDAP::UserSyncMap'} = {
        # DB -> LDAP
        UserFirstname => 'givenName',
        UserLastname  => 'sn',
        UserEmail     => 'mail',
    };
    $Self->{'AuthSyncModule::LDAP::Params'} = {
        port    => 389,
        timeout => 120,
        async   => 0,
        version => 3,
    };
    $Self->{'AuthSyncModule::LDAP::UserSyncInitialGroups'} = [
        'users',
    ];
 
    #################
    # CUSTOMER PART #
    #################
    # Permet de définir la vue Customer (accessible via customer.pl)
 
    $Self->{'Customer::AuthModule'} = 'Kernel::System::CustomerAuth::LDAP';
    $Self->{'Customer::AuthModule::LDAP::Host'} = 'localhost';
    $Self->{'Customer::AuthModule::LDAP::BaseDN'} = 'dc=deimos,dc=fr';
    $Self->{'Customer::AuthModule::LDAP::UID'} = 'uid';
 
    $Self->{CustomerUser} = {
        Name => 'LDAP Backend',
        Module => 'Kernel::System::CustomerUser::LDAP',
        Params => {
            # ldap host
            Host => 'localhost',
            # ldap base dn
            BaseDN => 'dc=deimos,dc=fr',
            # search scope (one|sub)
            SSCOPE => 'sub',
            SourceCharset => 'utf-8',
            DestCharset => 'iso-8859-1',
            Die => 0,
            # Net::LDAP new params (if needed - for more info see perldoc Net::LDAP)
            Params => {
                port    => 389,
                timeout => 120,
                async   => 0,
                version => 3,
            },
        },
        # customer uniq id
        CustomerKey => 'uid',
        # customer #
        CustomerID => 'mail',
        CustomerUserListFields => ['cn', 'mail'],
        CustomerUserSearchFields => ['uid', 'cn', 'mail'],
        CustomerUserSearchPrefix => '',
        CustomerUserSearchSuffix => '*',
        CustomerUserSearchListLimit => 250,
        CustomerUserPostMasterSearchFields => ['mail'],
        CustomerUserNameFields => ['givenname', 'sn'],
        # show not own tickets in customer panel, CompanyTickets
        CustomerUserExcludePrimaryCustomerID => 0,
        # add a ldap filter for valid users (expert setting)
        # CustomerUserValidFilter => '(!(description=gesperrt))',
        # admin can't change customer preferences
        AdminSetPreferences => 0,
        # cache time to life in sec. - cache any ldap queris
        CacheTTL => 0,
        Map => [
            # note: Login, Email and CustomerID needed!
            # var, frontend, storage, shown (1=always,2=lite), required, storage-type, http-link, readonly
            [ 'UserFirstname',  'Firstname',  'givenname',       1, 1, 'var', '', 0 ],
            [ 'UserLastname',   'Lastname',   'sn',              1, 1, 'var', '', 0 ],
            [ 'UserLogin',      'Username',   'uid',             1, 1, 'var', '', 0 ],
            [ 'UserEmail',      'Email',      'mail',            1, 1, 'var', '', 0 ],
       #    [ 'UserCustomerID', 'CustomerID', 'mail',            0, 1, 'var', '', 0 ],
            [ 'UserCustomerID', 'CustomerID', 'o',               0, 1, 'var', '', 0 ],
            [ 'UserCustomerIDs', 'CustomerIDs', 'customerids',   1, 0, 'var', '', 0 ],
            [ 'UserPhone',      'Phone',      'telephoneNumber', 1, 0, 'var', '', 0 ],
        ],
    };
 
    $Self->{'SendmailModule'} = 'Kernel::System::Email::SMTP';
    $Self->{'SendmailModule::Host'} = 'localhost';
    $Self->{'SendmailModule::Port'} = '25';
    $Self->{'CustomerGroupSupport'} = '1';
 
    # ---------------------------------------------------- #
    # ---------------------------------------------------- #
    #                                                      #
    #           End of your own config options!!!          #
    #                                                      #
    # ---------------------------------------------------- #
    # ---------------------------------------------------- #
}
 
# ---------------------------------------------------- #
# needed system stuff (don't edit this)                #
# ---------------------------------------------------- #
use strict;
use warnings;
 
use vars qw(@ISA $VERSION);
use Kernel::Config::Defaults;
push (@ISA, 'Kernel::Config::Defaults');
 
use vars qw(@ISA $VERSION);
$VERSION = qw($Revision: 1.21 $)[1];
 
# -----------------------------------------------------#

Vérifiez à bien configurer la partie PostgreSQL et commenter celle de MySQL, ainsi que remplir correctement tous les champs. Nous allons également utiliser Apache::DBI pour booster les performances. Editez ce fichier afin de décommenter ces lignes :

Configuration File /opt/otrs/scripts/apache2-perl-startup.pl
[...]
use Apache::DBI ();Apache::DBI->connect_on_init('DBI:mysql:otrs', 'otrs', 'password');use DBI ();
 
# enable this if you use mysql#use DBD::mysql ();#use Kernel::System::DB::mysql; 
# enable this if you use postgresql
use DBD::Pg ();use Kernel::System::DB::postgresql;[...]

Il ne reste plus qu'à initialiser la crontab :

Command Cron.sh
/opt/otrs/bin/Cron.sh start otrs

Votre serveur OTRS est accessible via : http://server-otrs/otrs :-)

5 API

Vous aurez peut être envie d'utiliser l'API pour x ou y raison. Je vais donc vous donner un exemple pour créer un Ticket et un Article (servant aux réponses du ticket) :

Configuration File create_ticket
#!/usr/bin/perl
 
use strict;
use warnings;
 
# Load lib folders from OTRS directory
use lib "/opt/otrs";
 
# Load modules
use Kernel::Config;
use Kernel::System::Encode;
use Kernel::System::Log;
use Kernel::System::Time;
use Kernel::System::Main;
use Kernel::System::DB;
use Kernel::System::Ticket;
use DBI;
use Encode ;
 
# Load objects
my $ConfigObject = Kernel::Config->new();
my $EncodeObject = Kernel::System::Encode->new( ConfigObject => $ConfigObject, );
 
my $LogObject = Kernel::System::Log->new(
    ConfigObject => $ConfigObject,
    EncodeObject => $EncodeObject,
);
 
my $TimeObject = Kernel::System::Time->new(
    ConfigObject => $ConfigObject,
    LogObject    => $LogObject,
);
 
my $MainObject = Kernel::System::Main->new(
    ConfigObject => $ConfigObject,
    EncodeObject => $EncodeObject,
    LogObject    => $LogObject,
);
 
my $DBObject = Kernel::System::DB->new(
    ConfigObject => $ConfigObject,
    EncodeObject => $EncodeObject,
    LogObject    => $LogObject,
    MainObject   => $MainObject,
);
 
my $TicketObject = Kernel::System::Ticket->new(
    ConfigObject => $ConfigObject,
    LogObject    => $LogObject,
    DBObject     => $DBObject,
    MainObject   => $MainObject,
    TimeObject   => $TimeObject,
    EncodeObject => $EncodeObject,
);
 
# Encoding to avoir errors
my $subject = "Mon sujet :-)"; 
Encode::encode( 'UTF-8', $subject ) or die("Cannot encode subject into UTF-8");
 
# Create Ticket
my $TicketID = $TicketObject->TicketCreate(
    Title			=> $subject, # now encoded in UTF-8
    CustomerID		        => 'pmavro',
    Queue			=> 'queue',
    Lock			=> 'unlock',
    Priority		        => '1 demande d\'information',
    State			=> 'new',
    Type			=> 'default',
    CustomerUser	        => 'pmavro',
    OwnerID			=> 1,
    UserID			=> 1,
);
 
# Create Article
my $ArticleID = $TicketObject->ArticleCreate(
    TicketID    => $TicketID,
    ArticleType => 'note-internal',    # email-external|email-internal|phone|fax|...
    SenderType  => 'agent',                           # agent|system|customer4
    From        => 'Some Agent <email@example.com>',  # not required but useful
    To          => 'Some Customer A <customer-a@example.com>',  # not required but useful
    Subject     => $subject,           # required
    Body        => 'the message text',                 # required
    Charset     => 'UTF-8',
    MimeType    => 'text/plain',
    HistoryType => 'OwnerUpdate',
    HistoryComment => 'Some free text!',
    UserID         => 1,
);

6 References

  1. ^ http://fr.wikipedia.org/wiki/OTRS
  2. ^ http://wiki.otterhub.org/index.php?title=Installation_on_Debian_6_with_Postgres