Hello,

I currently have a systemd unit that I have to reference a lot which has a rather long name. I would prefer to be able to reference this unit as a short alias.

Example: I have a container unit called 'systemd-nspawn@gitlab.service' and I would like to be able to refer to it as simply 'sd-gitlab.service' I've added an override.conf with the following:

[Install]
WantedBy= # To clear out previous wantedby params, though this doesn't seem to work like that. Documentation doesn't say it should, so I'm not surprised. Alias=sd-gitlab.service # I've also tried Alias=machines.target.wants/gitlab.service and omitted the following WantedBy decl.
WantedBy=machines.target

When I run enable, it does not make the symlinks:

#systemctl enable systemd-nspawn@gitlab.service
Created symlink from /etc/systemd/system/machines.target.wants/systemd-nspawn@gitlab.service to /etc/systemd/system/systemd-nspawn@gitlab.service


However, if I edit the systemd-nspawn@gitlab.service base unit file (systemctl edit --full systemd-nspawn@gitlab.service) and change the Install section to:

[Install]
Alias=gitlab.service          # Only added this one line
WantedBy=machines.target

and enable the service:

#systemctl enable systemd-nspawn@gitlab.service
Created symlink from /etc/systemd/system/gitlab.service to /etc/systemd/system/systemd-nspawn@gitlab.service. Created symlink from /etc/systemd/system/machines.target.wants/systemd-nspawn@gitlab.service to /etc/systemd/system/systemd-nspawn@gitlab.service.

Is there a way I can have it only enable the alias of the unit? Or do both have to be enabled?
Also, is there any way to specify a unit alias within an override.conf?

Thanks in advance!


_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to