Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] service not launched on install #93

Open
ze42 opened this issue Jun 24, 2021 · 5 comments · May be fixed by #94
Open

[BUG] service not launched on install #93

ze42 opened this issue Jun 24, 2021 · 5 comments · May be fixed by #94
Labels

Comments

@ze42
Copy link

ze42 commented Jun 24, 2021

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:

  service.running:
    - name: {{ servicename }}
    - enable: True
    - onlyif: systemctl list-units | grep {{ servicename }} >/dev/null 2>&1

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.

systemctl list-units | grep mongod
@ze42 ze42 added the bug label Jun 24, 2021
@noelmcloughlin
Copy link
Member

No, the command lists service files in /usr/lib/systemd and then does a grep to see if mongod service file was installed.

@ze42
Copy link
Author

ze42 commented Jun 24, 2021

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
~# 

@noelmcloughlin
Copy link
Member

noelmcloughlin commented Jun 24, 2021

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.

@ze42
Copy link
Author

ze42 commented Jun 25, 2021

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
~# 

@ze42 ze42 linked a pull request Jun 25, 2021 that will close this issue
@daks
Copy link
Member

daks commented May 18, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants