I have had tasks work for each of these 'with_items' scenarios at one point or another:
with_items: ec2.instances
or
with_items: '{{ ec2.instances }}'
or
with_items: "{{ ec2.instances }}"
How do I know when to use the correct one. If I knew, then I wouldn't be running into a trial-and-error situation as much of the time.
Thanks for the help!
Ansible < 2.2 (deprecated since 2.1) – bare variables:
with_items: ec2.instances
Ansible >= 2.2 – templated:
with_items: '{{ ec2.instances }}'
From release notes:
Removed Deprecated:
- with_ 'bare variable' handling, now loop items must always be templated {{ }} or they will be considered as plain strings.
Single or double quotes doesn't matter in this case.
You can read about differences in quotes from other SO questions.