Skip to content

Instantly share code, notes, and snippets.

@anryko
Last active February 21, 2018 18:59
Show Gist options
  • Save anryko/8a466db2058369676ddf462b569324c9 to your computer and use it in GitHub Desktop.
Save anryko/8a466db2058369676ddf462b569324c9 to your computer and use it in GitHub Desktop.
ansible_combine.yml
# x → {'a': 111, 'b': 222, 'c': 333}
- set_fact:
x: "{{ x | d({}) | combine({item.0: item.1}) }}"
with_together:
- ['a', 'b', 'c']
- [111, 222, 333]
# y → [{'a':123}, {'b':456}, {'c':789}]
- set_fact:
y: "{{ y | d([]) | union([{item.0: item.1}]) }}"
with_together:
- ['a', 'b', 'c']
- [111, 222, 333]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment