From f7823a17e282ed1e019193da4c99a85a68c5c2b1 Mon Sep 17 00:00:00 2001 From: Jeremy Frasier Date: Mon, 10 Jun 2024 17:12:14 -0400 Subject: [PATCH] Account for the possibility of a non-zero return code The systemctl is-system-running command can return a nonzero value if the status is degraded: https://man.archlinux.org/man/systemctl.1#System_Commands --- molecule/default/prepare.yml | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml index 422ef9f..d0afbfc 100644 --- a/molecule/default/prepare.yml +++ b/molecule/default/prepare.yml @@ -1,9 +1,7 @@ --- # When installing packages during later steps, the Fedora Docker -# images we are using (geerlingguy/docker-fedora32-ansible:latest and -# cisagov/docker-fedora33-ansible:latest) can throw sporadic errors -# like: "No such file or directory: -# '/var/cache/dnf/metadata_lock.pid'". +# images we are using can throw sporadic errors like: "No such file or +# directory: '/var/cache/dnf/metadata_lock.pid'". # # The fix is to ensure that systemd finishes initializing before # continuing on to the converge tasks. For details see: @@ -23,12 +21,22 @@ # next line. - name: Wait for systemd to complete initialization # noqa command-instead-of-module ansible.builtin.command: systemctl is-system-running - register: systemctl_status - until: "'running' in systemctl_status.stdout" - retries: 30 + changed_when: false delay: 5 + # The systemctl is-system-running command can return a nonzero + # value if the status is degraded: + # https://man.archlinux.org/man/systemctl.1#System_Commands + # + # This often happens when running ARM64 containers under qemu, + # as some services (particularly systemd services) use kernel + # calls that qemu can't emulate. + failed_when: false + retries: 30 + register: systemctl_status + until: > + 'running' in systemctl_status.stdout or + 'degraded' in systemctl_status.stdout when: ansible_service_mgr == "systemd" - changed_when: false - name: Import upgrade playbook ansible.builtin.import_playbook: upgrade.yml