From bede7ae065d36efde5e583c9885f04767efd0e02 Mon Sep 17 00:00:00 2001 From: Steve Brasier Date: Thu, 6 Mar 2025 12:29:37 +0000 Subject: [PATCH] fail fast if ansible-init failed --- ansible/bootstrap.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ansible/bootstrap.yml b/ansible/bootstrap.yml index 27559952c..22d98c2d6 100644 --- a/ansible/bootstrap.yml +++ b/ansible/bootstrap.yml @@ -8,7 +8,16 @@ stat: path: /etc/systemd/system/ansible-init.service register: _stat_ansible_init_unitfile - + - name: Check ansible-init status + command: systemctl is-failed ansible-init + register: _ansible_init_failed + failed_when: false # rc != 0 for non-failure! + changed_when: false + - name: Check ansible-init hasn't failed (yet) + # NB: only allows early exit if it has, does not catch future failures! + assert: + that: "'failed' not in _ansible_init_failed.stdout" + fail_msg: "ansible-init has failed - check journalctl -xeu ansible-init" - name: Wait for ansible-init to finish wait_for: path: /var/lib/ansible-init.done