docker-systemctl-replacement icon indicating copy to clipboard operation
docker-systemctl-replacement copied to clipboard

systemctl show should not include template units

Open srjturner opened this issue 6 years ago • 1 comments

Invoking systemctl show <unitname> returns the properties of both the unit matching the supplied unit name and any template units. For example, systemctl show sshd returns:

Id=sshd.service
Names=sshd.service
Description=OpenSSH server daemon
MainPID=8
SubState=running
ActiveState=active
LoadState=loaded
UnitFileState=enabled
TimeoutStartUSec=1min 30s
TimeoutStopUSec=1min 30s
EnvironmentFile=/etc/sysconfig/sshd

[email protected]
[email protected]
Description=OpenSSH per-connection server daemon
MainPID=0
SubState=dead
ActiveState=inactive
LoadState=loaded
UnitFileState=static
TimeoutStartUSec=1min 30s
TimeoutStopUSec=1min 30s
EnvironmentFile=-/etc/sysconfig/sshd

From observing "real" systemctl on other Linux systems I think this is wrong behaviour. For me it is breaking Ansible's 'service' module which expects a single set of properties from systemctl show, and simply accepts the last value when multiple key/value pairs are returned with the same key.

srjturner avatar Jun 11 '19 14:06 srjturner

The real systemctl has clear opinion on it:

systemctl show [email protected]
Failed to get properties: Unit name [email protected] is neither a valid invocation ID nor unit name.

Therefore the template pattern can not have attributes without an instance / object name. As an additional info - the bare template unit name is a valid argument on other occassions like "systemctl cat [email protected]".

So it seems valid that some subcommands do not hit on template descriptors alone.

gdraheim avatar Jun 11 '19 15:06 gdraheim