Conversation
krnowak
left a comment
There was a problem hiding this comment.
Looks alright, but I don't understand why user units need the symlinks to be created by ignition, while system units don't.
| links: | ||
| - path: /etc/systemd/user/default.target.wants/hello.service | ||
| target: /etc/systemd/user/hello.service | ||
| hard: false |
There was a problem hiding this comment.
So user units require explicit creation of the symlink? As in: it's not enough to specify WantedBy in the unit file, like it's done for system units?
There was a problem hiding this comment.
Good point. I removed the symlink and the unit is not enabled. 🤔
There was a problem hiding this comment.
Meh, I think that this "gotcha" for user units should be spelled out in the example description. But I don't know if this is because it's a user unit, or it's because it's placed in /etc.
There was a problem hiding this comment.
Ignition creates a preset file for systemd to enable the units. For user units, this should be under /etc/systemd/user-preset/ but Ignition doesn't know about that, only /etc/systemd/system-preset/.
There was a problem hiding this comment.
Anyway there is no way to set enabled: true for the user unit because it's created as a file here.
There was a problem hiding this comment.
Small hint, I think you could also add one of these Upholds= drop-ins for default.target.wants but the symlink is better^^
There was a problem hiding this comment.
I have two issues with this configuration actually:
- We can see the logs / the status with
systemctl --user status hello.servicebut we can't get logs withjournalctl --user --unit hello.servicebecausecoreas a UID < 1000 (see: journalctl--user --unitand--user-unitdiffer systemd/systemd#26742) - Even if we define the unit path to be
/etc/systemd/userit lands into/etc/xdg/systemd/userwhich is not a direct issue as systemd looks into this path but can be disturbing to seesystemctl --user cat hello.serviceshowing this path...
There was a problem hiding this comment.
I think we can go ahead with this PR. We won't fix today this journalctl --user -u hello.service issue and it's tracked. The goal of this PR is to show how to create a systemd user unit, one can still get the logs with systemctl --user status hello.service
Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com> Co-authored-by: Kai Lüke <pothos@users.noreply.github.com>
e20c419 to
469693c
Compare
it's not that easy to create a systemd user unit from butane, I think it's nice to document it.