Omd.service should be in /usr/lib/systemd/system/

Currently, omd.service is created in /etc/systemd/system/, which is being overwritten everytime Checkmk is updated. Instead, the package should create the service in /usr/lib/systemd/system/, which will work exactly the same, except that if a service with the same name exists in /etc/systemd/system/, it will use that configuration instead. This allows us to customize the omd.service file without risking it being overwritten every update.

There is already a good explanation about the difference here:

1 Like

There is a workaround: create a directory /etc/systemd/system/omd.service.d/ with *.conf files. Any parameter in there will overwrite whatever is in /etc/systemd/system/omd.service.

I think it is the intention that the installed unit file should be this with the highest precedence. Especially if you use the enterprise edition with agent bakery.
I would also say your workaround with the “omd.service.d” folder is the safest way to modify the unit file.

The same is true for the agent’s systemd units.

This intention is not correct. Packages should install their unit files into /usr/lib/systemd so that admins can customize things in /etc/systemd.

2 Likes

Then it should be raised as a bug for the Munich team.
It was only my thinking why it is placed there.

@moritz Ping. Thought you might appreciate this discussion. :slight_smile:

3 Likes

The documentation at systemd.unit contains this handy table (shortened to the relevant parts):

Path Description
/etc/systemd/system System units created by the administrator
/run/systemd/system Runtime units
/usr/local/lib/systemd/system System units installed by the administrator
/usr/lib/systemd/system System units installed by the distribution package manager

No package should install unit files into /etc/systemd.

And yes, Debian based systems use /lib/systemd/system and not /usr/lib/systemd/system.

2 Likes

I’m happy to see this stirred up some good debate regarding the omd.service file location and the same about the Linux agent. Not a big priority since there is a workaround and this isn’t breaking in any way but would appreciate feedback on what is decided in the future.

It’s already fixed for the agent: Linux-Agent: Place systemd units at /usr/lib
It certainly should be addressed for the omd.service as well.

3 Likes

Good to know, thanks. Should I open an issue on Git? I didn’t find the exact piece of code yet for a PR.

I opened an internal ticket already. We are looking into this.
Thanks for the input everyone, it is appreciated! :slight_smile:

2 Likes

Please put the files into the right place when installing.
But for “editing” systemd-units installed by a package I really suggest using “systemctl edit $unit”
which will create a drop-in.

When the maintainers add new stuff in their unit-file which are necessary for something and you just copied over the original file and edit it, the chances are higher that it breaks with future updates.

Only put completely new stuff into /etc/systemd/system that you created.

2 Likes

We will do the fixing. You do the proper configuration guys. :wink:

But that is good advice, thanks @nielsk!

1 Like