Last active
September 3, 2015 13:35
-
-
Save bryanwb/309a4f9a26fc4ed94e92 to your computer and use it in GitHub Desktop.
modifying a dictionary in a loop
This file contains hidden or 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 fails on the "set" tag | |
- set_fact: instances="{%- set instances = dict() %} | |
{%- for group in group_names %} | |
{%- for host in groups[group] %} | |
{%- if hostvars[host].get('InstanceId', None) %} | |
{%- if hostvars[host].get('Platform', None) == 'windows' %} | |
{%- set tmp = instances.setdefault(host, hostvars[host]['InstanceId']) %} | |
{%- endif %} | |
{%- endif %} | |
{%- endfor %} | |
{%- endfor %}{{instances}}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment