1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Cache task_vars to speed up IncludedFile.process_include_results (#39026)

This commit is contained in:
Matt Martz 2018-04-20 11:18:04 -05:00 committed by GitHub
parent fd50248463
commit afcc9ddf8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -54,6 +54,7 @@ class IncludedFile:
@staticmethod
def process_include_results(results, iterator, loader, variable_manager):
included_files = []
task_vars_cache = {}
for res in results:
@ -73,7 +74,11 @@ class IncludedFile:
if 'skipped' in include_result and include_result['skipped'] or 'failed' in include_result and include_result['failed']:
continue
task_vars = variable_manager.get_vars(play=iterator._play, host=original_host, task=original_task)
cache_key = (iterator._play, original_host, original_task)
try:
task_vars = task_vars_cache[cache_key]
except KeyError:
task_vars = task_vars_cache[cache_key] = variable_manager.get_vars(play=iterator._play, host=original_host, task=original_task)
templar = Templar(loader=loader, variables=task_vars)
include_variables = include_result.get('include_variables', dict())