(Solved) Separate the Config.pm
Moderator: crythias
-
- Znuny newbie
- Posts: 31
- Joined: 30 Nov 2020, 21:13
- Znuny Version: 6.4.5
- Real Name: Bjoern
(Solved) Separate the Config.pm
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
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.
Re: Separate the Config.pm
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
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.
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.
-
- Administrator
- Posts: 3955
- Joined: 18 Dec 2007, 12:23
- Znuny Version: Znuny and Znuny LTS
- Real Name: Roy Kaldung
- Company: Znuny
- Contact:
Re: Separate the Config.pm
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 ?
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 ?
-
- Znuny newbie
- Posts: 31
- Joined: 30 Nov 2020, 21:13
- Znuny Version: 6.4.5
- Real Name: Bjoern
-
- Administrator
- Posts: 3955
- Joined: 18 Dec 2007, 12:23
- Znuny Version: Znuny and Znuny LTS
- Real Name: Roy Kaldung
- Company: Znuny
- Contact:
Re: Separate the Config.pm
Hi,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.
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;
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 ?
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 ?
-
- Znuny newbie
- Posts: 31
- Joined: 30 Nov 2020, 21:13
- Znuny Version: 6.4.5
- Real Name: Bjoern
Re: Separate the Config.pm
Awesome, thanks for the template!
Again, thank you guys for you help!
Cheers
Again, thank you guys for you help!
Cheers
-
- Znuny newbie
- Posts: 31
- Joined: 30 Nov 2020, 21:13
- Znuny Version: 6.4.5
- Real Name: Bjoern
Re: (Solved) Separate the Config.pm
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 because the compiler was complaining about not finding that module..
Cheers
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);
Cheers
-
- Znuny newbie
- Posts: 31
- Joined: 30 Nov 2020, 21:13
- Znuny Version: 6.4.5
- Real Name: Bjoern
Re: (Solved) Separate the Config.pm
Here is the outsources config file located in /opt/otrs/Kernel/Config/Files/MyConfig.pm
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..
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;
My Perl is not good, barely existent if I'm being honest, so I'm kinda lost here..
-
- Znuny superhero
- Posts: 621
- 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
im using this method to call translate function..
Code: Select all
(-) use Kernel::Language qw(Translatable);
(+) use Kernel::Config::Defaults; # import Translatable()
-
- Znuny newbie
- Posts: 31
- Joined: 30 Nov 2020, 21:13
- Znuny Version: 6.4.5
- Real Name: Bjoern
Re: (Solved) Separate the Config.pm
Thanks, I'll give that a try!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()
Is there anyway to temporarily suppress the ConfigurationDeploySync messages until I'm done with the config file?
Cheers