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

Compatibility fix of centos release version #494

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ceph_deploy/hosts/centos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ def choose_init(module):

Returns the name of a init system (upstart, sysvinit ...).
"""
with open("/etc/rpm/macros.dist", 'r') as file:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think we should rely on an rpm macro for determining the distro's release version. user does not necessarily have this package installed.

lines = file.readlines()
for line in lines:
if 'centos' in line:
release_info = line.split()[1]
if release_info.isdigit() and int(release_info) >= 7:
return 'systemd'

if module.normalized_release.int_major < 7:
return 'sysvinit'
Expand Down