Skip to content

Instantly share code, notes, and snippets.

@muresan
Created November 8, 2018 16:41
Show Gist options
  • Save muresan/da7c24302931a83dfb39dd2e1916ec2f to your computer and use it in GitHub Desktop.
Save muresan/da7c24302931a83dfb39dd2e1916ec2f to your computer and use it in GitHub Desktop.
jinja2 walk hash
vars:
es_nodes:
elastic1:
es_port: 9200
elastic2:
es_port: 9201
elastic3:
es_port: 9202
elastic4:
es_port: 9203
elastic5:
es_port: 9204
hosts => [{% for k,v in es_nodes.items() %}"http://{{ k }}:{{ v.es_port }}"{% if not loop.last %},{% endif %}{% endfor %}]
hosts => ["http://elastic3:9202","http://elastic2:9201","http://elastic1:9200","http://elastic5:9204","http://elastic4:9203"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment