Skip to content

Commit

Permalink
Account for the possibility of a non-zero return code
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jsf9k committed Jun 10, 2024
1 parent 4ebae62 commit f7823a1
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
Expand Down

0 comments on commit f7823a1

Please sign in to comment.