How to set environment variables in systemd service for Ganeti with some cluster of CEPH!

Best practices:

The current best way to do this is to run ‘systemctl edit service’, which will create an override file for you or let you edit an existing one.

In normal installations this will create a directory /etc/systemd/system/service.service.d, and inside that directory create a file whose name ends in .conf (typically, override.conf), and in this file you can add to or override any part of the unit shipped by the distribution.

For instance:

1
2
3
# systemctl edit ganeti-noded
>>> in vim env you can see
>>> "/etc/systemd/system/ganeti-noded.service.d/.#override.conf6940d208e8dfaced" 0L, 0C

Content may be any, for example:

1
2
3
4
# cat /etc/systemd/system/ganeti-noded.service.d/override.conf
[Service]
Environment="SECRET=123"
Environment="ANOTHER_SECRET=456"

Also note that if the directory exists and is empty, your service will be disabled! If you don’t intend to put something in the directory, ensure that it does not exist.

Scroll to top