diff --git a/changelogs/fragments/solaris_system_vendor.yaml b/changelogs/fragments/solaris_system_vendor.yaml new file mode 100644 index 0000000000..278fcac423 --- /dev/null +++ b/changelogs/fragments/solaris_system_vendor.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: + - On Solaris, the `ansible_product_name` fact is populated for a wider range of older hardware models, and `ansible_system_vendor` fact is populated for certain known vendors. diff --git a/lib/ansible/module_utils/facts/hardware/sunos.py b/lib/ansible/module_utils/facts/hardware/sunos.py index 48993ef6ec..620c60b300 100644 --- a/lib/ansible/module_utils/facts/hardware/sunos.py +++ b/lib/ansible/module_utils/facts/hardware/sunos.py @@ -180,10 +180,26 @@ class SunOSHardware(Hardware): """ if out: system_conf = out.split('\n')[0] - found = re.search(r'(\w+\sEnterprise\s\w+)', system_conf) + # If you know of any other manufacturers whose names appear in + # the first line of prtdiag's output, please add them here: + vendors = [ + "Fujitsu", + "Oracle Corporation", + "QEMU", + "Sun Microsystems", + "VMware, Inc.", + ] + vendor_regexp = "|".join(map(re.escape, vendors)) + system_conf_regexp = (r'System Configuration:\s+' + + r'(' + vendor_regexp + r')\s+' + + r'(?:sun\w+\s+)?' + + r'(.+)') + + found = re.match(system_conf_regexp, system_conf) if found: - dmi_facts['product_name'] = found.group(1) + dmi_facts['system_vendor'] = found.group(1) + dmi_facts['product_name'] = found.group(2) return dmi_facts