mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 19:10:07 -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:
parent
3cdc332497
commit
eb27233e5c
@ -123,15 +123,12 @@ class FactBrokerWorker(ConsumerMixin):
|
||||
if job.store_facts is True:
|
||||
if module_name == 'insights':
|
||||
system_id = facts.get('system_id', None)
|
||||
if system_id:
|
||||
host_obj.insights_system_id = system_id
|
||||
try:
|
||||
host_obj.save()
|
||||
except IntegrityError:
|
||||
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))
|
||||
else:
|
||||
logger.warn('Failed to find insights system id in insights fact scan.')
|
||||
host_obj.insights_system_id = system_id
|
||||
try:
|
||||
host_obj.save()
|
||||
except IntegrityError:
|
||||
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))
|
||||
self._do_gather_facts_update(host_obj, module_name, facts, self.timestamp)
|
||||
|
||||
message.ack()
|
||||
|
||||
@ -52,16 +52,13 @@ def main():
|
||||
|
||||
system_uuid = get_system_uuid(INSIGHTS_SYSTEM_ID_FILE)
|
||||
|
||||
if system_uuid is not None:
|
||||
results = {
|
||||
'ansible_facts': {
|
||||
'insights': {
|
||||
'system_id': system_uuid
|
||||
}
|
||||
results = {
|
||||
'ansible_facts': {
|
||||
'insights': {
|
||||
'system_id': system_uuid
|
||||
}
|
||||
}
|
||||
else:
|
||||
results = dict(skipped=True, msg="Insights system id not found")
|
||||
}
|
||||
module.exit_json(**results)
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user