Enhancement
Cloud-init's systemd service templates have grown in complexity over time. Changes to unit files have a broad impact, so to limit risk to other distros templates are sometimes used when making changes. Over time these templates have grown very complex, which has made them even more difficult to maintain and increased the risk of changes breaking one distro or another[1]. Some changes were made in the past to simplify these service files[2][3], but much complexity remains.
This complexity falls into four different categories:
Foregone spring cleaning
Is this is actually needed? Systemd loads the selinux security policy prior to running any cloud-init code (including the systemd generator), so won't the security policy already be the default one upon creation? If this actually is needed, it probably belongs somewhere besides this service file - either in cloud-init's code directly or elsewhere.
Unnecessary templating
Systemd allows ordering and dependency on units to behave correctly when referenced units do not exist. Ordering After=wicked.service will not harm distros which do not use Wicked[5]. Ordering After=networking.service will not harm those distros not using ifupdown.
The dbus issue
Cloud-init can update hostname very early in boot. Some distro implementations in cloud-init[4] implement this with hostnamectl, which depends on D-bus. Those distros have to run all of cloud-init's services much later in boot after D-bus is available.
I see two ways to resolve this divergent behavior:
- implement
_write_hostname() without hostnamectl (some distros do it already)
- wait for hostnamctl to become Varlink-aware since existing systemd APIs will slowly acquire Varlink interfaces (eta: unknown)
How to contribute
If you are a distro maintainer, your participation and help with this issue would be greatly appreciated. A comment if you have anything to add (or disagree with any of the above), or even just a thumbs up to indicate that you think the approach seems reasonable would go a long ways.
Appendix: A
[1] #5755
[2] ec7dde8
[3] #5620
[4] RHEL, arch, opensuse, aosc, and photon, as well as distros derived from these in cloud-init's code
[5] note that the current suse dbus ordering misses host renames that could happen during Local stage - this is actually a bug
Appendix: B (completed)
Enhancement
Cloud-init's systemd service templates have grown in complexity over time. Changes to unit files have a broad impact, so to limit risk to other distros templates are sometimes used when making changes. Over time these templates have grown very complex, which has made them even more difficult to maintain and increased the risk of changes breaking one distro or another[1]. Some changes were made in the past to simplify these service files[2][3], but much complexity remains.
This complexity falls into four different categories:
Foregone spring cleaning
Is this is actually needed? Systemd loads the selinux security policy prior to running any cloud-init code (including the systemd generator), so won't the security policy already be the default one upon creation? If this actually is needed, it probably belongs somewhere besides this service file - either in cloud-init's code directly or elsewhere.
Unnecessary templating
Systemd allows ordering and dependency on units to behave correctly when referenced units do not exist. Ordering
After=wicked.servicewill not harm distros which do not use Wicked[5]. OrderingAfter=networking.servicewill not harm those distros not using ifupdown.The dbus issue
Cloud-init can update hostname very early in boot. Some distro implementations in cloud-init[4] implement this with
hostnamectl, which depends on D-bus. Those distros have to run all of cloud-init's services much later in boot after D-bus is available.I see two ways to resolve this divergent behavior:
_write_hostname()withouthostnamectl(some distros do it already)How to contribute
If you are a distro maintainer, your participation and help with this issue would be greatly appreciated. A comment if you have anything to add (or disagree with any of the above), or even just a thumbs up to indicate that you think the approach seems reasonable would go a long ways.
Appendix: A
[1] #5755
[2] ec7dde8
[3] #5620
[4] RHEL, arch, opensuse, aosc, and photon, as well as distros derived from these in cloud-init's code
[5] note that the current suse dbus ordering misses host renames that could happen during Local stage - this is actually a bug
Appendix: B (completed)
network.servicedoesn't appear used anywhere, if it ever was. The only reference that I can find tonetwork.serviceis a systemd commit from 2015 which fixed a typo fromnetwork.servicetonetwork.target.cloud-init-local.serviceis ordered beforeNetworkManager.serviceand beforenetwork-pre.target, yetNetworkManager.serviceis itself ordered afternetwork-pre.target. In this example,cloud-init-local.servicedoesn't need to be ordered beforeNetworkManager.service. Other redundant orderings like this exist.