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

service_mgr: detect systemd, even offline #66071

Merged
merged 2 commits into from Feb 4, 2020

Conversation

jamescassell
Copy link
Contributor

SUMMARY

Currently, systemd is only detected as the service manager if systemd is actually running. This also adds a check that will detect systemd ever if it is not currently running, such as during a container bulid.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

service_mgr

ADDITIONAL INFORMATION

@ansibot ansibot added affects_2.10 This issue/PR affects Ansible v2.10 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Dec 26, 2019
@jamescassell jamescassell reopened this Dec 26, 2019
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Dec 26, 2019
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Jan 3, 2020
@samdoran samdoran removed the needs_triage Needs a first human triage before being processed. label Jan 9, 2020
Comment on lines 60 to 61
if not os.path.exists('/sbin/init'):
return True
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bcoca if I were to remove this section, would you be okay merging it? This would leave only the SUSE family of distros out in the cold. All other systemd-based distros I tried have /sbin/init as a symlink to systemd. Same for debian jessie when in systemd mode. If you switch it to sysVinit mode, /sbin/init is no longer a symlink to systemd but is instead the SysV binary.

I could find no non-systemd distro where systemctl is an available package and /sbin/init is missing... If you can identify such a distro, I can look to see how to handle it.

FWIW, the linux service_mgr code has been unmodified since you originally introduced it, except for a small tweak for openrc.

Copy link
Member

@bcoca bcoca Jan 13, 2020

Choose a reason for hiding this comment

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

off top of my head, gentoo (i used it w/o systemd, but with systemctl installed), but mostly i would just look at previous tickets that posed the issue (i installed systemctl on my workstation just to test this).

IIRC the most common case was using a container for a distro that defaults to systemd, while the host is not using systemd.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for checking. I've removed these lines. I've found that OpenSUSE and friends have an optional systemd-sysvinit package that provides this symlink. (Their initrd has /init symlinked to /usr/lib/systemd/systemd, so no technical need for /sbin/init to be symlinked given that they're using an initrd.)

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. core_review In order to be merged, this PR must follow the core review workflow. and removed stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. core_review In order to be merged, this PR must follow the core review workflow. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jan 14, 2020
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Jan 22, 2020
@samdoran
Copy link
Contributor

samdoran commented Feb 4, 2020

This issue has been discussed extensively in several IRC meetings and we are reluctantly going to merge this.

There a lot of potential unknown issues this autodetection could introduce. While this change is helpful in the use case described above, it very well may break other use cases. We just don't know. This is why we added the use parameter to the service module, allowing playbook authors to specify the service manager rather than relying on the automatic detection.

That's still the approach we favor over improving the autodetection, but @jamescassell has advocated heavily for this change and is willing to help with the fallout.

rebuild_merge

@ansibot ansibot added shipit This PR is ready to be merged by Core and removed core_review In order to be merged, this PR must follow the core review workflow. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Feb 4, 2020
@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. shipit This PR is ready to be merged by Core and removed shipit This PR is ready to be merged by Core needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Feb 4, 2020
@ansibot ansibot merged commit 1bb94ec into ansible:devel Feb 4, 2020
@ansible ansible locked and limited conversation to collaborators Mar 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.10 This issue/PR affects Ansible v2.10 bug This issue/PR relates to a bug. has_issue shipit This PR is ready to be merged by Core support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants