-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid using ansible_failed_task in rescue blocks
ansible_failed_task can contain unexpanded Jinja2 templates with variable references that were valid when the task failed, but not valid anymore when using the variable in the rescue block. In this case the problem is with task names (.name) that contain references to storage_provider. Unfortunately this completely prevents using ansible_failed_task even if not using the problematic attribute. Other attribute could have been used if this were not the case, like .tags, but until ansible/ansible#49942 is fixed, it is better to avoid using ansible_failed_task and use the only other special variable describing the failed task: ansible_failed_result. Eliminate the previous workaround to set storage_provider on the tasks that expand ansible_failed_task and use ansible_failed_result with a special value of msg instead. This has a disadvantage of having to use a special msg with the fail module, while usually it is just a free-form message. The fail module does not set another attribute of the result that could be used though, and it is cleaner than the previous workaround.
- Loading branch information
Showing
2 changed files
with
42 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters