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

Introspect systemd unit deps recursively #52815

Draft
wants to merge 5 commits into
base: devel
from

Conversation

Projects
None yet
3 participants
@webknjaz
Copy link
Member

webknjaz commented Feb 22, 2019

SUMMARY

This patch checks whether the current unit which is being controlled by systemd Ansible module has indirect state (or static state with Install -> Also set in the unit for older systemd versions) and introspects its dependencies recursively, if yes.

Fixes #46744

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

systemd module

ADDITIONAL INFORMATION

N/A

webknjaz added some commits Jan 18, 2019

@webknjaz webknjaz self-assigned this Feb 22, 2019

if installed_unit:
indirect = True
elif out.strip().endswith('indirect'):
indirect = True

This comment has been minimized.

@webknjaz

webknjaz Feb 22, 2019

Author Member

TODO: extract installed_unit here as well.

@@ -307,6 +307,114 @@ def parse_systemctl_show(lines):
return parsed


def unit_is_enabled(module, systemctl_executable, systemd_unit, is_initd):

This comment has been minimized.

@bcoca

bcoca Feb 22, 2019

Member

make module and systemctl globals to avoid repassing them all the time,

is_initd should not be passed in as it would be for the original service and not the ones you depend on (not sure its possible to mix those in systemd)

This comment has been minimized.

@webknjaz

webknjaz Feb 23, 2019

Author Member

I avoid globals, it's just bad. If I wanted shared state I'd go for a different approach which requires refactoring and is out of the scope of this PR.

This comment has been minimized.

@webknjaz

webknjaz Feb 23, 2019

Author Member

Regarding initd, AFAIK init.d scripts usually just point to systemd units... I can make the adjustment, though.

This comment has been minimized.

@bcoca

bcoca Feb 25, 2019

Member

Globals are 'bad' in persistent environments, in this case 'one of scripts' that are designed to end on execution, they become a lot more efficient than passing objects all over.

As for init.d pointing to units are more of an exception than the norm, debian for example ships with initial init.d on services to allow people to switch out of systemd. Many other services don't have systemd units but do have the traditional init scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.