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'