-
Notifications
You must be signed in to change notification settings - Fork 23.9k
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
Allow loop on dict keys like python #53042
Conversation
The test
The test
|
In python, you can loop on dict just like list: for key in my_dict: val = my_dict[key] print(val) this is handy for usage and consistent in syntax. But ansible loop forbid that, which is unnature and unnecessary. This patch enables this feature with tiny change. Example: - hosts: localhost vars: my_list: - item0 - item1 my_dict: key0: val0 key1: val1 tasks: - debug: var=item loop: '{{my_list}}' - debug: var=my_dict[item] loop: '{{my_dict}}' Signed-off-by: Guo Qiao <guoqiao@gmail.com>
Thank you very much for your contribution. While we agree that ansible/proposals#99 If you have further questions please stop by IRC or the mailing list:
|
thanks |
Allow ansible to loop dict like python:
SUMMARY
Fix #53041
ISSUE TYPE
COMPONENT NAME
loop/task_executor
ADDITIONAL INFORMATION
Refer to #53041