OS - Red Hat Enterprise Linux 8

I've created a .spec file to build and package my application. My rpm also includes my_app.service file for systemd to start it. However, by default one has to enable this with systemctl enable my_app.service. I'd like to have it enabled after the rpm has been installed. I've googled and found that I can use systemd.preset, which says:

It is not recommended to ship preset files within the respective software packages implementing the units, but rather centralize them in a distribution or spin default policy, which can be amended by administrator policy.

Does it mean I should not be adding .preset file in my rpm? Also, later in the man page it says:

If no preset files exist, systemctl preset will enable all units that are installed by default.

If I read it correctly, then my application's service file should be automatically enabled, but it is not happening, or this implies the manual systemctl preset ?

1 Answer 1


Does it mean I should not be adding .preset file in my rpm?

Yes, you shouldn't put the .preset file in your service's package RPM

but it is not happening

It's not happening because the systemd package in RHEL ships with a default preset at /usr/lib/systemd/system-preset/90-systemd.preset.

If you want to stick to distribution packaging guidelines you have two options, namely:

  • contact operating system's packager for including your application service to the default preset
  • more feasible, create your own package for shipping preset. typically you ship your preset in your own repository's "release" package. An example of this is epel-release, which installs /usr/lib/systemd/system-preset/90-epel.preset among other things.
  • thanks for feedback! What priority value should I put in /usr/lib/systemd/system-preset/<priority>-myapp.preset file? The larger the value, the lower the priority? (man systemd.preset is not very specific about this)
    – Mark
    Apr 5 at 21:39
  • 1
    I'm not sure. I'd assume the higher number is the higher priority. As in alphabetical/numerical order, the priority 99 would override 10 thus having higher priority. Apr 6 at 12:07
  • So, I've added /usr/lib/systemd/system-preset/99-default-myapp.preset and added enable myapp.service line in it. My file is in lexicographic order and should be pulled in the last. After reboot, I was expecting to see systemctl status myapp.service would show ... vendor preset: enabled, however it has not happened. What am I missing?
    – Mark
    Apr 15 at 2:05
  • After I renamed /usr/lib/systemd/system-preset/99-default-myapp.preset to /usr/lib/systemd/system-preset/98-default-myapp.preset it works. I still don't understand why 99-default-myapp.preset does not get picked up after 99-default-disable.preset, although alphabetically 99-default-myapp.preset is the last one.
    – Mark
    Apr 17 at 1:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.