Skip to content

Commit

Permalink
facts: fix SPARC cpu count on linux (ansible#30261)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mator authored and alikins committed Sep 22, 2017
1 parent e1dcfda commit e93ecac
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/ansible/module_utils/facts/hardware/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ def get_cpu_facts(self, collected_facts=None):

# 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'] = []
Expand All @@ -216,6 +217,8 @@ def get_cpu_facts(self, collected_facts=None):
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:
Expand Down

0 comments on commit e93ecac

Please sign in to comment.