Skip to content

Commit

Permalink
make fact saving code more robust to unexpected fact data
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanpetrello committed Mar 3, 2020
1 parent d009ce4 commit 5432f43
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions awx/main/models/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,8 +829,10 @@ def finish_job_fact_cache(self, destination, modification_times):
continue
host.ansible_facts = ansible_facts
host.ansible_facts_modified = now()
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)
ansible_local = ansible_facts.get('ansible_local', {}).get('insights', {})
ansible_facts = ansible_facts.get('insights', {})
ansible_local_system_id = ansible_local.get('system_id', None) if isinstance(ansible_local, dict) else None
ansible_facts_system_id = ansible_facts.get('system_id', None) if isinstance(ansible_facts, dict) else None
if ansible_local_system_id:
print("Setting local {}".format(ansible_local_system_id))
logger.debug("Insights system_id {} found for host <{}, {}> in"
Expand Down

0 comments on commit 5432f43

Please sign in to comment.