[systemd-devel] Alias for template/instance service unit
Hans Gruber
moocan2112 at yahoo.fr
Thu Apr 22 18:18:01 UTC 2021
Hello,
I am having problems with the aliases and "Alias=' directive related to the template service unit.
According to https://www.freedesktop.org/software/systemd/man/systemd.unit.html
> "A template instance may only be aliased by another template instance, and the instance part must be identical. A template may be aliased by another template (in which case the alias applies to all instances of the template). As a special case, a template instance (e.g. "alias at inst.service") may be a symlink to different template (e.g. "template at inst.service"). In that case, just this specific instance is aliased, while other instances of the template (e.g. "alias at foo.service", "alias at bar.service") are not aliased. Those rule preserve the requirement that the instance (if any) is always uniquely defined for a given unit and all its aliases."
I have exactly these two cases and requirements and cannot find example.
> "A template may be aliased by another template (in which case the alias applies to all instances of the template)"
eg: How to create an alias using `Alias=` for a service template core at .service which will have maybe 8 or 16 instances (eg: core at cpu01.service core at cpu02.service ..) which will apply to all instances when enabled using eg allcores at .service.
> "As a special case, a template instance (e.g. "alias at inst.service") may be a symlink to different template (e.g. "template at inst.service"). In that case, just this specific instance is aliased, while other instances of the template (e.g. "alias at foo.service", "alias at bar.service") are not aliased"
eg: How to create an alias using `Alias=` for a service template tailoutput at .service which will have maybe 2 instances (eg: tailoutput at tty11.service tailoutput at tty12.service ..) which will apply to only instance tailoutput at tty12.service when enabled using eg: tty12-tailoutput at tty12.service.
I can't apply any alias using "Alias=" directive for two different template .service unit.Whatever I use for "Alias=" directive in the two cases inside the templates, instance service works, all symlink are created when instance is enabled, instance services are started as expected using their names, but all alias are always reporting
"Loaded: error (Reason: unit alasname failed to load properly: File exists)"
Alias=allcores at .service
Alias=allcores@%i.serviceAlias=alias@*.service
Alias=tty12-tailoutput@%i.service
Alias=%i-tailoutput at .service
Alias=alias at tty12.serviceAlias=alias-%n
Thank you in advance.
Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20210422/09337af6/attachment.htm>
More information about the systemd-devel
mailing list