Created
March 11, 2020 16:50
-
-
Save Gurpartap/ed37616f47af6c1c08ee73f01b7fb284 to your computer and use it in GitHub Desktop.
derive a list of dicts from ansible groups and hostvars
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
vars: | |
zookeeper_nodes: "\ | |
{% set _zookeeper_servers = [] %}\ | |
{% for host in groups.zookeeper %}\ | |
{% set _zookeeper_client_port_address = hostvars[host]['zookeeper_client_port_address'] | default('0.0.0.0', true) %}\ | |
{% set _zookeeper_client_port = hostvars[host]['zookeeper_client_port'] | default(2181, true) %}\ | |
{% if _zookeeper_servers.append(dict(['host', 'port'] | zip([_zookeeper_client_port_address, _zookeeper_client_port]))) %}{% endif %}\ | |
{% endfor %}\ | |
{{ _zookeeper_servers }}" | |
# debug: | |
# | |
# "zookeeper_nodes": [ | |
# { | |
# "host": "192.168.1.27", | |
# "port": 2181 | |
# }, | |
# { | |
# "host": "192.168.1.115", | |
# "port": 2181 | |
# }, | |
# { | |
# "host": "192.168.1.13", | |
# "port": 2181 | |
# } | |
# ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment