-
Notifications
You must be signed in to change notification settings - Fork 35
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I removed the symlink and the unit is not enabled. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have two issues with this configuration actually:
- We can see the logs / the status with
systemctl --user status hello.service
but we can't get logs withjournalctl --user --unit hello.service
becausecore
as a UID < 1000 (see: journalctl--user --unit
and--user-unit
differ systemd/systemd#26742) - Even if we define the unit path to be
/etc/systemd/user
it lands into/etc/xdg/systemd/user
which is not a direct issue as systemd looks into this path but can be disturbing to seesystemctl --user cat hello.service
showing this path...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]> Co-authored-by: Kai Lüke <[email protected]>
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.