From fbe5878919dda323c7a9b8842a99e548b40bdbe5 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 23 Nov 2016 19:00:48 -0500 Subject: [PATCH] only access match if we actually match fact fixes #18601 --- lib/ansible/module_utils/facts.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index 09a08ca08e..d8deaf9a60 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -1599,9 +1599,11 @@ class SunOSHardware(Hardware): rc returns 1 """ if out: - system_conf = out.split('\n')[0] - self.facts['product_name'] = re.search(r'(\w+\sEnterprise\s\w+)',system_conf).group(1) - + system_conf = out.split('\n')[0] + found = re.search(r'(\w+\sEnterprise\s\w+)',system_conf) + if found: + self.facts['product_name'] = found.group(1) + class OpenBSDHardware(Hardware): """ OpenBSD-specific subclass of Hardware. Defines memory, CPU and device facts: