mirror of
https://github.com/ansible/awx.git
synced 2026-02-24 06:26:00 -03:30
clear insights system id if not found
* Host previously found to have an insights system id that then later are found to not have an insights system id, have their system id cleared.
This commit is contained in:
@@ -123,15 +123,12 @@ class FactBrokerWorker(ConsumerMixin):
|
|||||||
if job.store_facts is True:
|
if job.store_facts is True:
|
||||||
if module_name == 'insights':
|
if module_name == 'insights':
|
||||||
system_id = facts.get('system_id', None)
|
system_id = facts.get('system_id', None)
|
||||||
if system_id:
|
host_obj.insights_system_id = system_id
|
||||||
host_obj.insights_system_id = system_id
|
try:
|
||||||
try:
|
host_obj.save()
|
||||||
host_obj.save()
|
except IntegrityError:
|
||||||
except IntegrityError:
|
host_obj.insights_system_id = None
|
||||||
host_obj.insights_system_id = None
|
logger.warn('Inisghts system_id %s not assigned to host %s because it already exists.' % (system_id, host_obj.pk))
|
||||||
logger.warn('Inisghts system_id %s not assigned to host %s because it already exists.' % (system_id, host_obj.pk))
|
|
||||||
else:
|
|
||||||
logger.warn('Failed to find insights system id in insights fact scan.')
|
|
||||||
self._do_gather_facts_update(host_obj, module_name, facts, self.timestamp)
|
self._do_gather_facts_update(host_obj, module_name, facts, self.timestamp)
|
||||||
|
|
||||||
message.ack()
|
message.ack()
|
||||||
|
|||||||
@@ -52,16 +52,13 @@ def main():
|
|||||||
|
|
||||||
system_uuid = get_system_uuid(INSIGHTS_SYSTEM_ID_FILE)
|
system_uuid = get_system_uuid(INSIGHTS_SYSTEM_ID_FILE)
|
||||||
|
|
||||||
if system_uuid is not None:
|
results = {
|
||||||
results = {
|
'ansible_facts': {
|
||||||
'ansible_facts': {
|
'insights': {
|
||||||
'insights': {
|
'system_id': system_uuid
|
||||||
'system_id': system_uuid
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else:
|
}
|
||||||
results = dict(skipped=True, msg="Insights system id not found")
|
|
||||||
module.exit_json(**results)
|
module.exit_json(**results)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user