Open ze42 opened 3 years ago
No, the command lists service files in /usr/lib/systemd and then does a grep to see if mongod service file was installed.
That is not what I see.
~# service mongod start
~# systemctl list-units | grep mongod
mongod.service loaded active running MongoDB Database Server
~# service mongod stop
~# systemctl list-units | grep mongod
~# service mongod start
~# systemctl list-units | grep mongod
mongod.service loaded active running MongoDB Database Server
~# service mongod stop
~# systemctl list-units | grep mongod
~# cat /etc/debian_version
10.9
~# dpkg -l | grep mongo
ii mongodb-database-tools 100.3.1 amd64 mongodb-database-tools package provides tools for working with the MongoDB server:
ii mongodb-org 4.4.6 amd64 MongoDB open source document-oriented database system (metapackage)
ii mongodb-org-database-tools-extra 4.4.6 amd64 Extra MongoDB database tools
ii mongodb-org-mongos 4.4.6 amd64 MongoDB sharded cluster query router
ii mongodb-org-server 4.4.6 amd64 MongoDB database server
ii mongodb-org-shell 4.4.6 amd64 MongoDB shell client
ii mongodb-org-tools 4.4.6 amd64 MongoDB tools
~# find /etc/systemd/ /usr/lib/systemd/ /lib/systemd/ -name '*mongo*'
/etc/systemd/system/multi-user.target.wants/mongod.service
/usr/lib/systemd/system/mongod.service
/lib/systemd/system/mongod.service
~#
Ahh ... it should be systemctl list-unit-files | grep mongo
...
list-unit-files [PATTERN...]
List unit files installed on the system, in combination with
their enablement state (as reported by is-enabled). If one or
more PATTERNs are specified, only unit files whose name
matches one of them are shown (patterns matching unit file
system paths are not supported)."
-a, --all
When listing units with list-units, also show inactive units
and units which are following other units. When showing
unit/job/manager properties, show all properties regardless
whether they are set or not.
To list all units installed in the file system, use the
list-unit-files command instead.
Yup, guess replacing list-units
by list-unit-files
should do the trick.
~# systemctl list-unit-files | grep mongod
mongod.service enabled
~# service mongod start
~# systemctl list-unit-files | grep mongod
mongod.service enabled
~#
I'm seeing the same behaviour with service not running after running the formula code.
But I don't understand why the onlyif
is used in the service state. Is there any case where the package is installed but not systemd unit?
Your setup
Formula commit hash / release tag
based on dd8a5aa
Versions reports (master & minion)
[old, but not related]
Distribution: Debian/buster
Pillar / config used
[probably not relevant]
Bug details
Describe the bug
On installation (using repository), the service is not launched.
The formula contains:
Steps to reproduce the bug
Install. Have the service not launched, and state.apply
Expected behaviour
Service should be launched, to ensure it is running.
Attempts to fix the bug
Removing the
onlyif
would start the service.Additional context
The following command only shows something if the service is started. Stopping the service, and the command would not show anything anymore.