Replies: 10 comments 27 replies
-
@rhatdan @alexlarsson @vrothberg @mfschumann @MartinX3 WDYT? |
Beta Was this translation helpful? Give feedback.
-
@ygalblum Thanks for unifying the two issues into one and summing up the discussion / questions. I agree that the two issues should be solved together. |
Beta Was this translation helpful? Give feedback.
-
If we took this path, I think this should be Quadlet command, not a Podman command. Let's not leak Quadlet into Podman to have a clear separation of concerns.
What is the use case for using templates? It seems counterintuitive to the simplicity of Quadlet. I am not saying no but I a clear use case may be a better guidance in decision making than an open question.
I don't feel strongly either way as long as it can be changed.
Instead of creating transient units, can't Quadlet write the files to preset paths? For a rootless user, it would be |
Beta Was this translation helpful? Give feedback.
-
I understand your point. However, Quadlet is a systemd-generator and as such adheres to the API defined for generators. So, I don't think we should use the same executable (even if we can make it work). Maybe something else? Maybe we should rename the current Quadlet executable (e.g.
@mfschumann gave an explanation to what he's trying to do here: #17662 (comment).
As a systemd-generator, Quadlet gets as a parameter from systemd the directory to which it can write the generated unit files. It is not supposed to write them anywhere else. |
Beta Was this translation helpful? Give feedback.
-
The upstream systemd issue for better enable is: |
Beta Was this translation helpful? Give feedback.
-
Maybe #20828 can be extended to support this? I.e. have a template .container file and then use drop-ins for enabling individual instances? |
Beta Was this translation helpful? Give feedback.
-
I created a PR for this: #21068 |
Beta Was this translation helpful? Give feedback.
-
I have been using quadlet .container templates to create named toolboxes and .image to change the container image of the toolbox. I can even enable them on login without enabling them the usual way. The DefaultInstance key does not work for me in regular systemd templates neither.
[email protected]# Quadlet container template for toolbox
# copyright 2022 @richiedaze:fedora.im
# SPDX-License-Identifier: GPL-2.1-or-late
# [email protected]
# %i = instance
# %p = program
# %S = state
[Unit]
AssertFileIsExecutable=/usr/bin/toolbox
Description=Quadlet container template for toolbox
Documentation=man:podman-systemd.unit(5)
[Container]
# Quadlet Container settings
# Add Capabilities
AddCapability=CAP_SYS_ADMIN
# Autoupdate mode
AutoUpdate=registry
# The name of the container
ContainerName=%i-%p
# Environmental variables inside container.
Environment=TOOLBOX_NAME=%i-%p
Environment=TOOLBOX_PATH=/usr/bin/%p
# Initial command inside container.
Exec=%p init-container \
--log-level info \
--home %h \
--shell %s \
--user %u \
--uid %U \
--gid %G \
--home-link \
--media-link \
--mnt-link
# Show logs of this Container in Debug mode.
#GlobalArgs=--log-level debug
# Name of the host in the Container.
HostName=%i-%p
# Location of the base image.
Image=toolbox.image
# Container's mounts
Mount=type=devpts,destination=/dev/pts
# The network of the container.
Network=host
# Features otherwise unsupported by the Quadlet generator.
PodmanArgs=--dns none
#PodmanArgs=--group-add keep-groups
PodmanArgs=--ipc host
PodmanArgs=--no-hosts
PodmanArgs=--pid host
#PodmanArgs=--privileged
# Disable security labels
SecurityLabelDisable=true
# Rootless mappings
#
# Default mapping
#UIDMap=0:${UID}:1
#GIDMap=0:${GID}:1
#
#UIDMap=0:1${UID}
#GIDMap=0:1${GID}
#UIDMap=${UID}:0:1
#GIDMap=${GID}:0:1
#UIDMap=${UID}:${UID}:65536
#GIDMap=${GID}:${GID}:65536
# User preferences
User=root:root
UserNS=keep-id
# Volumes
# Bind Non-volatile Overlayered volumes onto the container.
#Volume=%i-%p-etc-dnf:/etc/dnf:O,upperdir=%S/%p/%i-%p/etc/dnf,workdir=%S/%p/%i-%p/workdir/1
Volume=%i-%p-usr:/usr:O,upperdir=%S/%p/%i-%p/usr,workdir=%S/%p/%i-%p/workdir/2
Volume=%i-%p-var:/var:O,upperdir=%S/%p/%i-%p/var,workdir=%S/%p/%i-%p/workdir/3
# Bind host's directories onto the container.
Volume=/dev:/dev:rslave
Volume=/run/user/%U:/run/user/%U
Volume=/run/media:/run/media:rslave
# Bind host's root directory onto the container.
Volume=/:/run/host:rslave
# Bind host's sockets onto the container.
Volume=/run/.heim_org.h5l.kcm-socket:/run/.heim_org.h5l.kcm-socket
Volume=/run/avahi-daemon/socket:/run/avahi-daemon/socket
Volume=/run/dbus/system_bus_socket:/run/dbus/system_bus_socket
Volume=/run/pcscd/pcscd.comm:/run/pcscd/pcscd.comm
# Bind host's toolbox profile and executable onto the container.
Volume=/etc/profile.d/%p.sh:/etc/profile.d/%p.sh:ro
Volume=/usr/bin/%p:/usr/bin/%p:ro
# Bind Home directory onto the container.
# 1. Bind default home directory.
# Use home directory normally. (toolbox default)
#Volume=%h:%h:rslave
# 2. Bind overlay on custom skeleton directory.
# 2a. Temporary (volatile overlayer).
# Use a new overlayered skeleton directory every time.
#Volume=%E/skel:%h:O
# 2b. Permanent (non-volatile overlayer).
# Use saved overlayered skeleton directory.
Volume=%E/skel:%h:O,upperdir=%S/%p/%i-%p%h,workdir=%S/%p/%i-%p/workdir/4
# 3. Bind extra home directories
Volume=%h/.local/src:%h/.local/src:rslave
# Working directory inside the container.
WorkingDir=%h
[Service]
# Show logs of this Service in Debug mode.
#Environment=SYSTEMD_LOG_LEVEL=debug
# Clone missing home skeleton directory.
ExecStartPre=bash -c 'test -d %E/skel || \
cp --recursive /etc/skel %E'
# Create Non-volatile overlayer directories.
ExecStartPre=-bash -c 'mkdir --parents \
--context=system_u:object_r:container_file_t:s0:c1022,c1023 \
%S/%p/%i-%p/etc/dnf \
%S/%p/%i-%p/%h \
%S/%p/%i-%p/usr \
%S/%p/%i-%p/var \
%S/%p/%i-%p/workdir/{1..4} '
# ??? Rebuild volumes after podman auto-update
#ExecStopPost=-podman volume rm --force \
# %i-%p-etc-dnf \
# %i-%p-usr \
# %i-%p-var
# Extend Timeout to allow time to pull the image
TimeoutStartSec=900
# Working directory inside the service.
#WorkingDirectory=%S/%p/%i-%p/workdir/
[Install]
# Start on user login
#WantedBy=graphical-session.target toolbox.image# Quadlet image template for toolbox
# copyright 2022 @richiedaze:fedora.im
# SPDX-License-Identifier: GPL-2.1-or-late
[Image]
# The image to pull. It is recommended to use a fully qualified image name rather than a short name, both for performance and robustness reasons.
# The format of the name is the same as when passed to podman pull. So, it supports using :tag or digests to guarantee the specific image version.
Image=registry.fedoraproject.org/fedora-toolbox:39 |
Beta Was this translation helpful? Give feedback.
-
Howdy everybody. I am playing with .build units on my fedora machine. Version installed from Copr:
My question is: are Here is the contents of /etc/containers/systemd/
I'd like to specify a templated build as the
Here is the container template file
I can work around this, but should templating the |
Beta Was this translation helpful? Give feedback.
-
Just two cents from a system administrator's standpoint. What I expect when I create a It seems like, for the most part, the sysadmin shouldn't even need to know about quadlet. I'm just creating a container unit. I'm reading the blogs/docs on how this works, and I'm thinking, "That's great. They have container units now. But what's all this quadlet business." All I really need to know is that systemd creates services from a container file using a generator, and these services run as pods that I can interact with using podman. That fits cleanly into my existing systemd mental framework. Otherwise, you get mired in a C++ sort of mess, with broken paradigms that require frequent searches to figure out why things don't work in the way that the paradigm intuitively leads me to expect them to work. |
Beta Was this translation helpful? Give feedback.
-
Purpose
This discussion comes to combine the discussions being held in two separate issues about Quadlet enable #17567 and supporting templates #17662. Since both issues present similar discussion points, I would like to explore them together.
The current state
Since systemd considers the service files created by Quadlet and as transient, they cannot be enabled by calling
systemctl enable
.To overcome this obstacle, Quadlet automatically enables services when their corresponding Quadlet unit files contain any of the keys
Alias
,WantedBy
orRequiredBy
in theirInstall
section.In addition, Quadlet currently does not support systemd templates and as a result disregards the
DefaultInstance
key.Automatic Enable
The problem
Automatically enabling services couples between the creator of the Quadlet unit file and its user in terms of when the service is enabled.
For example, when a package consists of an executable and a service unit file, the user may choose if and when the to enable the service. However, in the current Quadlet implementation, a package distributed using a container image and a Quadlet unit file will either get enabled as part of the installation or never (if none of the required keys are set).
Suggested solution
Here: #17567 (comment) @alexlarsson suggested adding a new command
podman quadlet enable <Quadlet unit>
. The question is where would the symlink created by the command should reside.Currently, Quadlet creates the symlinks under its output directory. However, this output directory, in normal operations, is the
runtime
directory (system or user) which does not persist. So, Quadlet will have to recreate the symlinks. This raises the quesion, how will it know which units were enabled.Possible solution: should the symlinks be created somewhere else? E.g. the config dirs as suggested here #17662 (comment)
Supporting Templates
Supporting systemd templates adds another complexity into the mix, but they have direct connection with enabling services and therefore should be addressed together.
DefaultInstace
Currently, Quadlet does not support templates at all and disregards the templating option of unit files with
@
at the end of their name.With the current implementation the solution would be to create the symlink with the value of the
DefaultInstance
after the@
sign. But, what's the point of a template that is used only once.Multiple Instances
Here: #17662 (comment), @mfschumann suggested to add an new
Instances
key that will instruct Quadlet to create a symlink for each instance in Instances.The problem is that such a solution keeps the coupling between the creator and the user of the service.
Questions for Discussion
Automatic Enabling
Should Quadlet keep the current behavior of automatic enabling of the services?
If not, how should the transient storage issue be addressed? Can we use a different (persistent) location? Store the list of enabled services somewhere?
Templates
Should Quadlet support templates?
If yes, The handling of
DefaultInstace
is strait forward. But, the handling of additional instances depends on the decision on the previous question.If the behavior is kept, should Quadlet support an
Instances
key (maybe in a newQuadlet
section)?If not, then the solution would probably be a combination of the two solutions
Beta Was this translation helpful? Give feedback.
All reactions