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

systemd - fix issue with unknown capabilities in newer kernel #72337

Merged
merged 1 commit into from Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelogs/fragments/71528-systemd-capbpf-workaround.yml
@@ -0,0 +1,4 @@
bugfixes:
- >
systemd - work around bug with ``systemd`` 245 and 5.8 kernel that does not correctly
report service state (https://github.com/ansible/ansible/issues/71528)
11 changes: 11 additions & 0 deletions lib/ansible/modules/systemd.py
Expand Up @@ -400,6 +400,17 @@ def main():
# Check for loading error
if is_systemd and not is_masked and 'LoadError' in result['status']:
module.fail_json(msg="Error loading unit file '%s': %s" % (unit, result['status']['LoadError']))

# Workaround for https://github.com/ansible/ansible/issues/71528
elif err and rc == 1 and 'Failed to parse bus message' in err:
result['status'] = parse_systemctl_show(to_native(out).split('\n'))

(rc, out, err) = module.run_command("{systemctl} list-units '{unit}*'".format(systemctl=systemctl, unit=unit))

Choose a reason for hiding this comment

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

@samdoran I believe you should use systemctl list-units --all . Without --all flag the inactive (dead) services will be not listed. Plz see my comment for more info #71528 (comment)

root@Ubuntu18:/# systemctl list-units actions.runner.monolithprojects-ansible-github_actions_runne.Ubuntu18.service
0 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.

root@Ubuntu18:/# systemctl list-units --all actions.runner.monolithprojects-ansible-github_actions_runne.Ubuntu18.service
UNIT                                                                          LOAD   ACTIVE   SUB  DESCRIPTION                                                                             
actions.runner.monolithprojects-ansible-github_actions_runne.Ubuntu18.service loaded inactive dead GitHub Actions Runner (monolithprojects-ansible-github_actions_runner-testrepo.Ubuntu18)

1 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have you tried with #72363? I believe list-unit-files should take care of this issue.

Choose a reason for hiding this comment

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

Ah sorry, did not notice that open PR. Yes list-unit-files works too. Thanks.

Copy link
Contributor Author

@samdoran samdoran Nov 10, 2020

Choose a reason for hiding this comment

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

Ok, that's great news. Thank you for confirming. I was hoping I didn't have to fix this yet again. :) I have opened backport PRs for 2.9 and 2.10, so this fix will be in the next .z release of Ansible 2.9 and 2.10.

is_systemd = unit in out

(rc, out, err) = module.run_command("{systemctl} is-active '{unit}'".format(systemctl=systemctl, unit=unit))
result['status']['ActiveState'] = out.rstrip('\n')

else:
# list taken from man systemctl(1) for systemd 244
valid_enabled_states = [
Expand Down