From 5cbda9658ab13d45a210c0581458327a4d975bcc Mon Sep 17 00:00:00 2001 From: Strahinja Kustudic Date: Tue, 14 Aug 2018 13:41:34 +0200 Subject: [PATCH] yum will fail on 'No space left on device', fixes #32791 (#40737) During the installing of packages if yum runs out of free disk space, some post install scripts could fail (like e.g. when the kernel package generates initramfs), but yum would still exit with a status 0. This is bad, especially for the kernel package, because it makes it unable to boot. Because the yum module is usually used for automation, which means the users cannot read every message yum prints, it's better that the yum module fails if it detects that there is no free space on the disk. --- lib/ansible/modules/packaging/os/yum.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/ansible/modules/packaging/os/yum.py b/lib/ansible/modules/packaging/os/yum.py index cced4f00e1c..1c2f9d66800 100644 --- a/lib/ansible/modules/packaging/os/yum.py +++ b/lib/ansible/modules/packaging/os/yum.py @@ -830,6 +830,16 @@ def exec_install(module, items, action, pkgs, res, yum_basecmd): res['changed'] = False module.fail_json(**res) + # Fail if yum prints 'No space left on device' because that means some + # packages failed executing their post install scripts because of lack of + # free space (e.g. kernel package couldn't generate initramfs). Note that + # yum can still exit with rc=0 even if some post scripts didn't execute + # correctly. + if 'No space left on device' in (out or err): + res['changed'] = False + res['msg'] = 'No space left on device' + module.fail_json(**res) + # FIXME - if we did an install - go and check the rpmdb to see if it actually installed # look for each pkg in rpmdb # look for each pkg via obsoletes