Why not enable templated units?

Martin Pitt mpitt at debian.org
Thu Oct 2 05:56:42 BST 2014


Ryan Kuester [2014-10-01 19:48 -0500]:
> 1. automount-usb-media at .service is instantiated and started as
>    automount-usb-media at sdb1.service by a udev rule when a USB drive is
>    plugged.
> 
> 2. scan-usb-media at .service is instantiated and started as
>    scan-usb-media at sdb1.service by virtue of being symlinked under
>    automount-usb-media at .service.wants/, the symlink coming by means of
>    enabling scan-usb-media at .service.
> 
> Perhaps my example isn't compelling to anyone except me :^), but is
> there a reason to squash what systemctl and systemd seem to allow?
> systemctl seems to allow enabling of templates and systemd instantiates
> them in a reasonable way.

Incidentally I was playing around with instantiated units just a few
days ago (just with 208, not with 215). While systemctl enable
foo at .service formally works with 208 (it creates a symlink), it
doesn't actually do anything, and might even wreak some havoc. grawity
says that due to that 215 doesn't even allow enabling instance
templates any more.

It seems the correct way to add dependencies to an instantiated unit
is via udev rules, like

  SUBSYSTEM=="block", [... some tests for USB ...], ENV{SYSTEMD_WANTS}+="automount-usb-media@$name.service"

So if you run systemctl enable automount-usb-media at sdb1.service, does
that really work for you? (That's essentially what init-system-helpers
would do)

Martin

-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)




More information about the Pkg-systemd-maintainers mailing list