New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not cache the loop item label so that it will update with each item #36430
Conversation
shouldn't the jinja2 cache invalidate when the variables involved change? aka 'item'. |
@bcoca jinja is not the "cacher" in this case. https://github.com/ansible/ansible/blob/devel/lib/ansible/template/__init__.py#L470-L473 When templar.template is told to use a cache, it bypasses do_template and jinja completely. If the templated label is sent to do_template, jinja is called and returns the correct result. With a little bit of python-q injection, here's what happens under the covers ...
Without this patch, jinja's environment.compile is never invoked for bar_label. Based on what little I can find out jinja's "caching", there is no cache for results. It only caches template source. https://stackoverflow.com/a/4214506 |
Add integration test for ansible#36430 (ansible#36432) (cherry picked from commit d1f7693) (cherry picked from commit 9fced4f)
SUMMARY
In an item loop, the label is used to display context to the user. The value of the label can be templated with the item. After 2.4.x, the templating operation for the label was cached, and would not update for each item. This patch disabled the caching.
ISSUE TYPE
COMPONENT NAME
task_executor and loop labels
ANSIBLE VERSION
ADDITIONAL INFORMATION
Example output before patch:
Example after patch: