From 005dc82b674d23278239dc6049bcb24cd0f44dfa Mon Sep 17 00:00:00 2001 From: Charles Short Date: Thu, 13 Jun 2019 14:32:13 +0000 Subject: [PATCH] Fix prescribe.py Take into account ansible-inventory output changes with newer versions of anisble. Specifically for 'facter_processor' ansible fact and 'processtor_type'. Change-Id: I9a34e0aff9758d34b3f38907abcdaa050df612dc Signed-off-by: Charles Short --- browbeat/prescribe.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/browbeat/prescribe.py b/browbeat/prescribe.py index 518a9f9bb..35c19a677 100644 --- a/browbeat/prescribe.py +++ b/browbeat/prescribe.py @@ -45,15 +45,24 @@ class Metadata(object): hardware_dict['virtualization_type'] = sys_data[item]['ansible_virtualization_type'] hardware_dict['total_mem'] = sys_data[item][ 'ansible_memory_mb']['real']['total'] - hardware_dict['total_logical_cores'] = sys_data[item][ - 'facter_processorcount'] + if 'facter_processorcount' in sys_data[item]: + hardware_dict['total_logical_cores'] = sys_data[item][ + 'facter_processorcount'] + else: + hardware_dict['total_logical_cores'] = sys_data[item][ + 'facter_processors']['count'] hardware_dict['os_name'] = sys_data[item]['ansible_distribution'] + \ sys_data[item]['ansible_distribution_version'] hardware_dict['ip'] = sys_data[item]['ansible_default_ipv4']['address'] hardware_dict['num_interface'] = len(sys_data[item]['ansible_interfaces']) hardware_dict['machine_make'] = sys_data[item]['ansible_product_name'] - hardware_dict['processor_type'] = ' '.join(sys_data[item][ - 'facter_processor0'].split()) + # facter_processor0 is gone in ansible 2.8 + if 'facter_processor0' in sys_data[item]: + hardware_dict['processor_type'] = ' '.join(sys_data[item][ + 'facter_processor0'].split()) + else: + hardware_dict['processtor_type'] = sys_data[item][ + 'facter_processors']['models'][0] hard_dict['hardware_details'].append(hardware_dict) return hard_dict