From 531d97d3b3bd92a1fcbbbb0a482c59e4d0254435 Mon Sep 17 00:00:00 2001 From: chris meyers Date: Tue, 2 Apr 2019 10:18:05 -0400 Subject: [PATCH] pickup insights system_id from ansible facts * Continue to pick up facts from scan_insights.py * This PR adds the ability to pickup facts from /etc/ansible/facts.d/insights.facts * Log what transport the insights system_id was found via --- awx/main/models/jobs.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/awx/main/models/jobs.py b/awx/main/models/jobs.py index 4ccd2f848d..2203b7e31a 100644 --- a/awx/main/models/jobs.py +++ b/awx/main/models/jobs.py @@ -861,8 +861,21 @@ class Job(UnifiedJob, JobOptions, SurveyJobMixin, JobNotificationMixin, TaskMana continue host.ansible_facts = ansible_facts host.ansible_facts_modified = now() - if 'insights' in ansible_facts and 'system_id' in ansible_facts['insights']: - host.insights_system_id = ansible_facts['insights']['system_id'] + ansible_local_system_id = ansible_facts.get('ansible_local', {}).get('insights', {}).get('system_id', None) + ansible_facts_system_id = ansible_facts.get('insights', {}).get('system_id', None) + if ansible_local_system_id: + print("Setting local {}".format(ansible_local_system_id)) + logger.debug("Insights system_id {} found for host <{}, {}> in" + " ansible local facts".format(ansible_local_system_id, + host.inventory.id, + host.name)) + host.insights_system_id = ansible_local_system_id + elif ansible_facts_system_id: + logger.debug("Insights system_id {} found for host <{}, {}> in" + " insights facts".format(ansible_local_system_id, + host.inventory.id, + host.name)) + host.insights_system_id = ansible_facts_system_id host.save() system_tracking_logger.info( 'New fact for inventory {} host {}'.format(