From dfa3ecaf849070d8ff22f55c0b1cac1f6522472d Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Mon, 12 Feb 2018 10:21:10 -0500 Subject: [PATCH] fixes to virtual facts fixes #36038 (cherry picked from commit 97b6e99479178addf21c380c1b653f734ddb0cea) --- CHANGELOG.md | 1 + lib/ansible/module_utils/facts/virtual/linux.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95a7f20c22..ea0fc0ed11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,7 @@ Ansible Changes By Release https://github.com/ansible/ansible/pull/34130 * Fix docker_service so a build is not triggered every time https://github.com/ansible/ansible/issues/36145 +* Be more tolerant about spaces when gathering virtual facts (https://github.com/ansible/ansible/pull/36042) diff --git a/lib/ansible/module_utils/facts/virtual/linux.py b/lib/ansible/module_utils/facts/virtual/linux.py index 9ce9132078..ba5055676e 100644 --- a/lib/ansible/module_utils/facts/virtual/linux.py +++ b/lib/ansible/module_utils/facts/virtual/linux.py @@ -144,9 +144,9 @@ class LinuxVirtual(Virtual): if os.path.exists('/proc/self/status'): for line in get_file_lines('/proc/self/status'): - if re.match('^VxID: \d+', line): + if re.match(r'^VxID:\s+\d+', line): virtual_facts['virtualization_type'] = 'linux_vserver' - if re.match('^VxID: 0', line): + if re.match(r'^VxID:\s+0', line): virtual_facts['virtualization_role'] = 'host' else: virtual_facts['virtualization_role'] = 'guest' @@ -200,7 +200,7 @@ class LinuxVirtual(Virtual): if open(f).read().rstrip() == 'vdsm': virtual_facts['virtualization_type'] = 'RHEV' break - except: + except Exception: pass else: virtual_facts['virtualization_type'] = 'kvm'