Re: [exim] including additional config

Etusivu
Poista viesti
Vastaa
Lähettäjä: Jethro R Binks
Päiväys:  
Vastaanottaja: exim-users
Aihe: Re: [exim] including additional config
I do something which is a bit of a combination of all the solutions
offered so far.

I have mailhosts performing a number of roles, with several of each.
However the bulk of the config is identical, and config choices are made
by consulting macros set in one file per host.

Each mailhost contains exactly the same files, so Paul's
.include_if_exists solution isn't quite suitable, since they all always
exist.

However, what I do near the start of the main exim config is:

.include EXIMDIR/hostconfig.thishost

and that's a symlink to the real file for the host:

hostconfig.thishost -> hostconfig.kojak

The hostconfig file contains macros which set stuff up, like IP addresses
and hostnames and roles:

SYSHOST = kojak
SHORTHOSTNAME = mx1
LONGHOSTNAME = mx1.strath.ac.uk

# One and only one of these should be defined. The other should be
# commented out:
#ROLECMH = yes
ROLEMX = yes

# LOCALHOSTNUMBER must be unique for each server in the enterprise in
# order to guarantee uniqueness of the message ids; range is 0-16
LOCALHOSTNUMBER = 1

and so on.

These macros are then used in the rest of the config file in the
appropriate places:

.ifdef ROLEMX
MYROLE = mx
ROLEHOSTNAMES = ROLEHOSTSMX
.elifdef ROLECMH
MYROLE = cmh
ROLEHOSTNAMES = ROLEHOSTSCMH
.endif

primary_hostname = LONGHOSTNAME
...



I dabbled with a solution similar to that proposed by Graeme a little bit
after doing the above, but didn't really get it finished and didn't really
see much benefit to spending the time on it. But, it would be neater, as
you'd potentially cut down on the numbers of files to be replicated and
have all the variable config stuff in one place rather than scattered in
a file per host.

My system works for me, and I almost never have to touch it.

Jethro.




On Fri, 7 Sep 2012, Graeme Fowler wrote:

> On Fri, 2012-09-07 at 11:17 +0100, Oliver Howe wrote:
> > Or is there a better way of achieving this?
>
> Lookups. Y'know, those things that Exim is really really good at
> doing :)
>
> Make every setting which you require to be a tunable value a lookup
> (either using a macro, or directly) and then use a file of external
> values to set them.
>
> Just as a theoretical (largely untested!) example, a file containing:
>
> foo: 50
> bar: 100
> baz: 1000
>
> on one server, and:
>
> foo: 10
> bar: 1000
> baz: 5
>
> on another
>
> could then be looked up as follows:
>
> recipients_max = ${lookup{foo}lsearch{/path/to/file}{$value}{10}}
> some_other_setting = ${lookup{bar}lsearch{/path/to/file}{$value}{99}}
> a_third_value = ${lookup{baz}lsearch{/path/to/file}{$value}{100}}
>
> Then all you need to do is set the values in the appropriate per-server
> file.
>
> Graeme


. . . . . . . . . . . . . . . . . . . . . . . . .
Jethro R Binks, Network Manager,
Information Services Directorate, University Of Strathclyde, Glasgow, UK

The University of Strathclyde is a charitable body, registered in
Scotland, number SC015263.