Skip to content

Instantly share code, notes, and snippets.

@rjsalts
Last active January 3, 2016 07:39
Show Gist options
  • Save rjsalts/8430770 to your computer and use it in GitHub Desktop.
Save rjsalts/8430770 to your computer and use it in GitHub Desktop.
Equally divide servers to backends in ansible template
{% for host in groups['systems-server'] %}
{% if host == ansible_fqdn %}
{% set target_sysdb = loop.index0 % groups['sysdb-server']|length()|int() %}
{{ groups['sysdb-server'][target_sysdb] }}
{% endif %}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment