[systemd-devel] Variables in the [Unit] section of a server

Lennart Poettering lennart at poettering.net
Thu Jan 14 06:58:14 PST 2016


On Wed, 13.01.16 10:51, Steve Dickson (SteveD at redhat.com) wrote:

> Hello,
> 
> Is is possible to set a variable in the [Unit]
> section of a service?
> 
> For example in rpc-gssd.service there is
>     ConditionPathExists=/etc/krb5.keytab
> 
> but for some installation the krb5.keytab
> is in a different place. The rpc.gssd daemon
> can be told this by setting a command line
> argument from the EnvironmentFile.
> 
> So people have to edit both the EnvironmentFile
> and the rpc-gssd.service to make this change. 
> 
> So it would be nice if only the EnvironmentFile
> need to be edit and the change would happen
> in both places. 
> 
> Possible?

Unit files are supposed to be configuration files, people can override
and extend if they want to make changes. It's not recommended to use
the EnvironmentFile= logic to externalise configuration. Instead, just
keep the config in one place, in the unit files, to make things less
opaque and more uniform.

And no, unit files are not supposed to be a templating language and do
not support generlized variable expansion and quite frankly I should
never even have added the limited env var expansion via
EnvironmentFile= that ExecStart= supports, since it invites people to
externalise settings that way.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list