mirror of
https://github.com/ansible/awx.git
synced 2026-05-17 14:27:42 -02:30
more gracefully handle fact cache failures for hosts that contain /
see: https://github.com/ansible/awx/issues/1977 related: https://github.com/ansible/ansible/issues/41413
This commit is contained in:
@@ -774,9 +774,13 @@ class Job(UnifiedJob, JobOptions, SurveyJobMixin, JobNotificationMixin, TaskMana
|
|||||||
if not os.path.realpath(filepath).startswith(destination):
|
if not os.path.realpath(filepath).startswith(destination):
|
||||||
system_tracking_logger.error('facts for host {} could not be cached'.format(smart_str(host.name)))
|
system_tracking_logger.error('facts for host {} could not be cached'.format(smart_str(host.name)))
|
||||||
continue
|
continue
|
||||||
with codecs.open(filepath, 'w', encoding='utf-8') as f:
|
try:
|
||||||
os.chmod(f.name, 0o600)
|
with codecs.open(filepath, 'w', encoding='utf-8') as f:
|
||||||
json.dump(host.ansible_facts, f)
|
os.chmod(f.name, 0o600)
|
||||||
|
json.dump(host.ansible_facts, f)
|
||||||
|
except IOError:
|
||||||
|
system_tracking_logger.error('facts for host {} could not be cached'.format(smart_str(host.name)))
|
||||||
|
continue
|
||||||
# make note of the time we wrote the file so we can check if it changed later
|
# make note of the time we wrote the file so we can check if it changed later
|
||||||
modification_times[filepath] = os.path.getmtime(filepath)
|
modification_times[filepath] = os.path.getmtime(filepath)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user