(Solved) Separate the Config.pm

Moderator: crythias

Post Reply
liquidxtc13
Znuny newbie
Posts: 30
Joined: 30 Nov 2020, 21:13
Znuny Version: 6.4.5
Real Name: Bjoern

(Solved) Separate the Config.pm

Post by liquidxtc13 »

Hey all,

so I'm about to implement the third LDAP connection for authentication and sync - customers as well as agents - and tbh the config file is starting to get really clogged. I do have a real clean way of structuring my code and config files, but the sheer amount of config lines is bloating the Config.pm

Is there a way to separate the configs? Ideally I would like to outsource the LDAP configuration into a separate file per customer and just include them in the main Config.pm

Is this possible? I do have a coding background, but I've never gotten around to Perl. From what I can tell, the config directives are inside a function called load ( sub load {} ), which has me fearing that there is no way of separating the config.

Any help is appreciated!
Cheers
Last edited by liquidxtc13 on 25 Mar 2021, 23:51, edited 1 time in total.
wurzel
Znuny guru
Posts: 3224
Joined: 08 Jul 2010, 22:25
Znuny Version: x.x.x
Real Name: Florian

Re: Separate the Config.pm

Post by wurzel »

Hi,

yes, create a new .pm file in $OTRSHOME/Kernel/Config/Files and be happy.
(don't forget to rebuild your config to get the files read)

Flo
OTRS 8 SILVER (Prod)
OTRS 8 auf Debian 11 (Test)
Znuny 7.x latest version testing auf Debian 11

-- Ich beantworte keine Forums-Fragen PN - No PN please

I won't answer to unfriendly users any more. A greeting and regards are just polite.
root
Administrator
Posts: 3934
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: Separate the Config.pm

Post by root »

wurzel wrote: 25 Mar 2021, 23:29 (don't forget to rebuild your config to get the files read)
This is only needed if it's a .xml file.
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
liquidxtc13
Znuny newbie
Posts: 30
Joined: 30 Nov 2020, 21:13
Znuny Version: 6.4.5
Real Name: Bjoern

Re: Separate the Config.pm

Post by liquidxtc13 »

wurzel wrote: 25 Mar 2021, 23:29 yes, create a new .pm file in $OTRSHOME/Kernel/Config/Files and be happy.
No way! It's that easy? I feel pretty dumb now :lol:

Thank you!

Are these files kept even if there is an update?
root
Administrator
Posts: 3934
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: Separate the Config.pm

Post by root »

liquidxtc13 wrote: 25 Mar 2021, 23:14 Is this possible? I do have a coding background, but I've never gotten around to Perl. From what I can tell, the config directives are inside a function called load ( sub load {} ), which has me fearing that there is no way of separating the config.
Hi,

Use this a blueprint and add your settings.

Code: Select all

# VERSION:1.1
# --
# Copyright (C) 2012-2021 Znuny GmbH, http://znuny.com/
# --
# 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.
# --

package Kernel::Config::Files::ZZZCustomerXX;

use strict;
use warnings;

use utf8;

use Kernel::Language qw(Translatable);

sub Load {
    my ($File, $Self) = @_;


    return 1;
}

1;

Name the according to the package name.

Be aware that if you create a support bundle passwords are not removed from this file like it's done with Kernel/Config.pm

- Roy
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
liquidxtc13
Znuny newbie
Posts: 30
Joined: 30 Nov 2020, 21:13
Znuny Version: 6.4.5
Real Name: Bjoern

Re: Separate the Config.pm

Post by liquidxtc13 »

Awesome, thanks for the template!

Again, thank you guys for you help! 8)
Cheers
liquidxtc13
Znuny newbie
Posts: 30
Joined: 30 Nov 2020, 21:13
Znuny Version: 6.4.5
Real Name: Bjoern

Re: (Solved) Separate the Config.pm

Post by liquidxtc13 »

Damn, unfortunately I was to rash..

So I did as you told me, but I kept getting the following errors in the system log, paired with A LOT of tickets and mails:

There was an error executing ConfigurationDeploySync: Attempt to reload Kernel/Config/Files/MyConfig.pm aborted.

Running perl -cw MyConfig.pm tells me that at least the Syntax is fine. Although I had to comment

Code: Select all

use Kernel::Language qw(Translatable);
because the compiler was complaining about not finding that module..

Cheers
liquidxtc13
Znuny newbie
Posts: 30
Joined: 30 Nov 2020, 21:13
Znuny Version: 6.4.5
Real Name: Bjoern

Re: (Solved) Separate the Config.pm

Post by liquidxtc13 »

Here is the outsources config file located in /opt/otrs/Kernel/Config/Files/MyConfig.pm

Code: Select all

# VERSION:1.1
# --
# Copyright (C) 2012-2021 Znuny GmbH, http://znuny.com/
# --
# 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.
# --

package Kernel::Config::Files::MyConfig;

use strict;
use warnings;

use utf8;

use Kernel::Language qw(Translatable);

sub Load {
    my ($File, $Self) = @_;

        # ---------------------------------------------------- #
        # Customer LDAP configuration                          #
        # ---------------------------------------------------- #

        # ---------------------------------------------------------- #
        # Customer LDAP Authentication                     #
        # ---------------------------------------------------------- #
        $Self->{'Customer::AuthModule2'} = 'Kernel::System::CustomerAuth::LDAP';
        $Self->{'Customer::AuthModule::LDAP::Host2'} = '';
        $Self->{'Customer::AuthModule::LDAP::BaseDN2'} = '';
        $Self->{'Customer::AuthModule::LDAP::UID2'} = 'mail';
        $Self->{'Customer::AuthModule::LDAP::GroupDN2'} = '';
        $Self->{'Customer::AuthModule::LDAP::SearchUserDN2'} = '';
        $Self->{'Customer::AuthModule::LDAP::SearchUserPw2'} = '';

        # ----------------------------------------------------------- #
        # Customer data sync                                #
        # ----------------------------------------------------------- #
        $Self->{CustomerUser2} = {
                Name => 'XXX AD',
                Module => 'Kernel::System::CustomerUser::LDAP',
                Params => {
                        Host => '',
                        BaseDN => '',
                        SSCOPE => 'sub',
                        UserDN => '',
                        UserPw => '',
                        AlwaysFilter => '(memberOf=CN=OTRS_Users,OU=groups,OU=[....])',
                        SourceCharset => 'utf-8',
                        Params => {
                                port => 389,
                                scheme => 'ldap',
                                timeout => 120,
                                async => 0,
                                version => 3,
                        },
                },
                CustomerKey => 'mail',
                CustomerID => 'mail',
                CustomerUserListFields => ['sAMAccountName', 'cn', 'mail'],
                CustomerUserSearchFields => ['sAMAccountName', 'cn', 'mail'],
                CustomerUserPostMasterSearchFields => ['mail'],
                CustomerUserNameFields => ['givenname', 'sn'],
                Map => [
                                # ['UserSalutation', 'Title', 'title', '1', '0', 'var'],
                                ['UserFirstname', 'Firstname', 'givenname', '1', '1', 'var'],
                                ['UserLastname', 'Lastname', 'sn', '1', '1', 'var'],
                                ['UserLogin', 'Login', 'mail', '1', '1', 'var'],
                                ['UserEmail', 'Email', 'mail', '1', '1', 'var'],
                                ['UserCustomerID', 'CustomerID', 'mail', '0', '1', 'var'],
                                ['UserPhone', 'Phone', 'telephonenumber', '1', '0', 'var'],
                                # ['UserAddress', 'Address', 'postaladdress', '1', '0', 'var'],
                                # ['UserComment', 'Comment', 'description', '1', '0', 'var'],
                ],
        };
        # ---------------------------------------------------------- #
        # Customer Login End                                         #
        # ---------------------------------------------------------- #

    return 1;
}

1;
I have removed all customer-related information. The config itself is working, as we use it productively. What I've done is, cut the configuration from Config.pm, added your suggested template to MyConfig.pm and included the configuration..

My Perl is not good, barely existent if I'm being honest, so I'm kinda lost here..
skullz
Znuny superhero
Posts: 618
Joined: 24 Feb 2012, 03:58
Znuny Version: LTS and Features
Real Name: Mo Azfar
Location: Kuala Lumpur, MY
Contact:

Re: (Solved) Separate the Config.pm

Post by skullz »

im using this method to call translate function..

Code: Select all

(-) use Kernel::Language qw(Translatable);
(+) use Kernel::Config::Defaults; # import Translatable()
liquidxtc13
Znuny newbie
Posts: 30
Joined: 30 Nov 2020, 21:13
Znuny Version: 6.4.5
Real Name: Bjoern

Re: (Solved) Separate the Config.pm

Post by liquidxtc13 »

skullz wrote: 26 Mar 2021, 01:30 im using this method to call translate function..

Code: Select all

(-) use Kernel::Language qw(Translatable);
(+) use Kernel::Config::Defaults; # import Translatable()
Thanks, I'll give that a try!

Is there anyway to temporarily suppress the ConfigurationDeploySync messages until I'm done with the config file?

Cheers
Post Reply