From c4ad0f86c71b41804aa3496d633ca08e859fc872 Mon Sep 17 00:00:00 2001 From: Martin Kopta Date: Fri, 5 May 2017 23:01:30 +0200 Subject: [PATCH] fixed yum.parse_check_update regex (#24331) Output of `yum check-update` can contain lines with long package names and long repository label names, which will be broken into multiple lines, which need to be sanitized. The solution to this has been fixed and refactored in 2.3 in form of parse_check_update(), but it still contains subtle bug, which makes such multi-lines invisible to later logic (such packages aren't included in parse_check_update()) output. The problem is caused by using '\1' in re.sub(), instead of proper r'\1', which literally puts unicode symbol \1 into resulting output. --- lib/ansible/modules/packaging/os/yum.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/modules/packaging/os/yum.py b/lib/ansible/modules/packaging/os/yum.py index 55838c7352d..79e722835e1 100644 --- a/lib/ansible/modules/packaging/os/yum.py +++ b/lib/ansible/modules/packaging/os/yum.py @@ -885,7 +885,7 @@ def parse_check_update(check_update_output): # ceph.x86_64 1:11.2.0-0.el7 ceph # preprocess string and filter out empty lines so the regex below works - out = re.sub('\n[^\w]\W+(.*)', ' \1', + out = re.sub(r'\n[^\w]\W+(.*)', r' \1', check_update_output) available_updates = out.split('\n')