Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package should use systemd presets instead of enabling/disabling services #102

Open
ziggythehamster opened this issue Feb 13, 2024 · 0 comments

Comments

@ziggythehamster
Copy link

ziggythehamster commented Feb 13, 2024

The spec currently contains these lines:

    systemctl enable systemd-networkd.service
    systemctl enable systemd-resolved.service
    systemctl disable NetworkManager-wait-online.service
    systemctl disable NetworkManager.service

Rather than do this, the package should create a systemd preset file at %{_presetdir}/80-amazon-ec2-net-utils.preset (where %{_presetdir} is defined to be /usr/lib/systemd/system-preset on Enterprise Linux) which looks like this:

enable systemd-networkd.service
enable systemd-resolved.service
disable NetworkManager-wait-online.service
disable NetworkManager.service

The script in the spec would then need to systemctl preset each of those services instead (and probably also systemctl daemon-reload before) since it expects to also start services.

The reason for using presets instead of having the script directly enable/disable services is that it persists the preference/requirement that systemd-networkd is used instead of NetworkManager. If another preset on the system with a lower priority (which may be provided by the OS vendor, a package, or the sysadmin) expresses the preference to enable NetworkManager either directly or indirectly in a preset, then this package will stop working correctly once the preset is applied (which could happen when packages are installed/upgraded or deliberately via systemctl preset-all). Presets are how the Fedora packaging guidelines now recommend doing this (and these guidelines would apply to Enterprise Linux as well). With a preset in place, NetworkManager will not be automatically enabled, and only an explicit enable would cause that to happen.

(Edited: I typed the priority as 98 originally because that's what I had been using all day, but this would have to be <90 since the OS defaults are 90-* and systemd uses whatever comes first and doesn't allow later ones to override it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant