The message generated by systemctl has been updated in9321e23c40
, which requires a corresponding change in the systemd module. In addition, this fixes the module when the SYSTEMD_OFFLINE environment variable is set. (cherry picked from commita1a50bb3cd
)
This commit is contained in:
parent
4cfe2cf8dc
commit
ac248cf34a
3 changed files with 13 additions and 3 deletions
3
changelogs/fragments/71197-systemctl-ignore-message.yaml
Normal file
3
changelogs/fragments/71197-systemctl-ignore-message.yaml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
bugfixes:
|
||||||
|
- systemd - fixed chroot usage on new versions of systemd, that broke because of upstream changes in systemctl output
|
||||||
|
- systemd - made the systemd module work correctly when the SYSTEMD_OFFLINE environment variable is set
|
|
@ -277,7 +277,7 @@ def is_deactivating_service(service_status):
|
||||||
|
|
||||||
|
|
||||||
def request_was_ignored(out):
|
def request_was_ignored(out):
|
||||||
return '=' not in out and 'ignoring request' in out
|
return '=' not in out and ('ignoring request' in out or 'ignoring command' in out)
|
||||||
|
|
||||||
|
|
||||||
def parse_systemctl_show(lines):
|
def parse_systemctl_show(lines):
|
||||||
|
@ -535,8 +535,8 @@ def main():
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
module.fail_json(msg="Unable to %s service %s: %s" % (action, unit, err))
|
module.fail_json(msg="Unable to %s service %s: %s" % (action, unit, err))
|
||||||
# check for chroot
|
# check for chroot
|
||||||
elif is_chroot(module):
|
elif is_chroot(module) or os.environ.get('SYSTEMD_OFFLINE') == '1':
|
||||||
module.warn("Target is a chroot. This can lead to false positives or prevent the init system tools from working.")
|
module.warn("Target is a chroot or systemd is offline. This can lead to false positives or prevent the init system tools from working.")
|
||||||
else:
|
else:
|
||||||
# this should not happen?
|
# this should not happen?
|
||||||
module.fail_json(msg="Service is in unknown state", status=result['status'])
|
module.fail_json(msg="Service is in unknown state", status=result['status'])
|
||||||
|
|
|
@ -72,4 +72,11 @@
|
||||||
- result is failed
|
- result is failed
|
||||||
- result is search("Could not find the requested service {{ fake_service }}")
|
- result is search("Could not find the requested service {{ fake_service }}")
|
||||||
|
|
||||||
|
- name: check that the module works even when systemd is offline (eg in chroot)
|
||||||
|
systemd:
|
||||||
|
name: "{{ running_names.stdout_lines|random }}"
|
||||||
|
state: started
|
||||||
|
environment:
|
||||||
|
SYSTEMD_OFFLINE: 1
|
||||||
|
|
||||||
when: 'systemctl_check.rc == 0'
|
when: 'systemctl_check.rc == 0'
|
||||||
|
|
Loading…
Reference in a new issue