diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index e7128df0ff..c1a481ba9e 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -1594,7 +1594,6 @@ class OpenBSDHardware(Hardware): In addition, it also defines number of DMI facts and device facts. """ platform = 'OpenBSD' - DMESG_BOOT = '/var/run/dmesg.boot' def populate(self): self.sysctl = self.get_sysctl() @@ -1652,19 +1651,19 @@ class OpenBSDHardware(Hardware): def get_processor_facts(self): processor = [] - dmesg_boot = get_file_content(OpenBSDHardware.DMESG_BOOT) - if not dmesg_boot: - rc, dmesg_boot, err = self.module.run_command("/sbin/dmesg") - i = 0 - for line in dmesg_boot.splitlines(): - if line.split(' ', 1)[0] == 'cpu%i:' % i: - processor.append(line.split(' ', 1)[1]) - i = i + 1 - processor_count = i + for i in range(int(self.sysctl['hw.ncpu'])): + processor.append(self.sysctl['hw.model']) + self.facts['processor'] = processor - self.facts['processor_count'] = processor_count - # I found no way to figure out the number of Cores per CPU in OpenBSD - self.facts['processor_cores'] = 'NA' + # The following is partly a lie because there is no reliable way to + # determine the number of physical CPUs in the system. We can only + # query the number of logical CPUs, which hides the number of cores. + # On amd64/i386 we could try to inspect the smt/core/package lines in + # dmesg, however even those have proven to be unreliable. + # So take a shortcut and report the logical number of processors in + # 'processor_count' and 'processor_cores' and leave it at that. + self.facts['processor_count'] = self.sysctl['hw.ncpu'] + self.facts['processor_cores'] = self.sysctl['hw.ncpu'] def get_device_facts(self): devices = []