Ubuntu's boot order for Tailscale service

In part this depends on the exact semantics that you want, systemd provides a number of options. In this case we’re focusing on two dependency axes, though there are others:

  • Wants dependencies: a wants dependency is “weak”, so if the dependency fails, the dependent continues to start
  • Requires dependencies: a requires dependency is “hard”, so if the dependency fails, so does the dependent.

You do not need to modify units configurations in order to add dependencies, you can use the CLI and it will add symlinks as described here. e.g.

systemctl add-wants postgresql tailscaled
# or
systemctl add-requires postgresql tailscaled

If you add a Wants dependency, then if tailscaled fails to start, postgresql will start anyway. This maintains availability, but given the original problem description it may or may not be the desired outcome.

If you add a Requires dependency, then if tailscaled fails to start, postgresql will not start. This reduces availability - postgresql will only start if tailscaled is running.

You could also modify the dependencies of the network-online target, however doing so can have additional consequences for other software on the system that are unique to your distribution and configuration so you should make sure you understand what units depend on network-online.target before you do that.

2 Likes