Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- list1:
- - { endpoint: {address: "addr1", port: "port1"}}
- - { endpoint: {address: "addr2", port: "port2"}}
- elasticache_facts:
- region: "{{ terraform.region }}"
- name: "{{ cluster }}-{{ env }}"
- register: elasticache
- #declare an empty var in vars file to be used as accumulator
- memcache_hosts: ""
- # iterate through the list of nodes and append the fields to my string; I will have some extra spaces(separators) but that's ok
- set_fact:
- memcache_hosts: "{{ memcache_hosts }} {{item.endpoint.address}}:{{item.endpoint.port}}"
- with_items: "{{ elasticache.elasticache_clusters[0].cache_nodes}}"```
- Is there some less ugly way to filter the list to the desired format?
- Maybe there is a magic filter I don't know about.
- I can also obtain two lists, one with hosts, one with ports, zip them, make a dict out of that, but I found only some ugly to_json and then regex to make it a string.
- I am also considering to write a custom filter in python, but seems also overdoing it.
- Thanks for the help!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement