Closed saz closed 2 months ago
Only timer_wrapper
escapes unit names. manage_unit
and unit_file
are just matching a specific pattern.
Hm well that is actually what systemd-escape
does. Since /
gets replaced by -
, the dash gets replaced by \x2d
.
$ systemd-escape a/b-c
a-b\x2dc
There is the --mangle
option that does ignore -
but it sadly has a sideffect:
and possibly automatically append an appropriate unit type suffix to the string.
systemd-escape -m a/b-c
a-b-c.service
Not sure what we should do here.
systemd::escape
everywhere and have consistent names?systemd::escape
modified to use --mangle
(the call to systemd::escape
should then be used on the full unit name including the type suffix)?_
instead of -
in unit names?BTW \x2d
ist quite common. From my fedora system:
$ systemctl list-units --all | grep '\\x2d' | wc -l
70
BTW
\x2d
ist quite common. From my fedora system:$ systemctl list-units --all | grep '\\x2d' | wc -l 70
Yes, for units containing path names for example, but not "normal" services.
I'd suggest to drop the systemd::escape
usage here and leave it to the user. I wasn't expecting, that my unit name gets changed to prometheus\\x2d\node...
and wondered, why it's not creating the systemd unit.
Hm maybe you are right. Just use the users input and fail if it is an invalid name, e.g. containing /
. This is a holdover I ported from themeier-systemd_cron
But I guess we have to mark it as breaking change then :/
But I guess we have to mark it as breaking change then :/
It might get even more complicated, as the name changes, the old unit won't be managed and will stay on the system, while the new one gets created. But cleaning it up should be pretty easy to do within this module.
Affected Puppet, Ruby, OS and module versions/distributions
How to reproduce (e.g Puppet code you use)
What are you seeing
Due to the usage of
systemd::escape
in https://github.com/voxpupuli/puppet-systemd/blob/45e09532b9dc392fe767b555813945c94113422c/manifests/timer_wrapper.pp#L78 a-
will be escaped and becomes\x2d
.What behaviour did you expect instead
Timer and service are named
prometheus-node-exporter-deleted_libraries-custom
notprometheus\\x2dnode\\x2dexporter\\x2ddeleted_libraries\\x2dcustom
Output log
Any additional information you'd like to impart
Link to the discussion on the usage of
systemd::escape
https://github.com/voxpupuli/puppet-systemd/pull/419#discussion_r1510333656