From e93ecac0da87741d0bd6daed85af6962f8d5b4d6 Mon Sep 17 00:00:00 2001 From: Anatoly Pugachev Date: Fri, 22 Sep 2017 21:48:00 +0300 Subject: [PATCH] facts: fix SPARC cpu count on linux (#30261) On sparc64, /proc/cpuinfo has no usual 'model name', 'Processor', 'vendor_id', 'Vendor', as a result "ansible_processor_vcpus" is always 1. Add check element "ncpus active" to fix the issue. --- lib/ansible/module_utils/facts/hardware/linux.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/ansible/module_utils/facts/hardware/linux.py b/lib/ansible/module_utils/facts/hardware/linux.py index 95b03355d34..eb1d0fc914a 100644 --- a/lib/ansible/module_utils/facts/hardware/linux.py +++ b/lib/ansible/module_utils/facts/hardware/linux.py @@ -193,6 +193,7 @@ class LinuxHardware(Hardware): # model name is for Intel arch, Processor (mind the uppercase P) # works for some ARM devices, like the Sheevaplug. + # 'ncpus active' is SPARC attribute if key in ['model name', 'Processor', 'vendor_id', 'cpu', 'Vendor', 'processor']: if 'processor' not in cpu_facts: cpu_facts['processor'] = [] @@ -216,6 +217,8 @@ class LinuxHardware(Hardware): cores[coreid] = int(data[1].strip()) elif key == '# processors': cpu_facts['processor_cores'] = int(data[1].strip()) + elif key == 'ncpus active': + i = int(data[1].strip()) # Skip for platforms without vendor_id/model_name in cpuinfo (e.g ppc64le) if vendor_id_occurrence > 0: