tasks/main.yml:
...
- name: configure
template:
src: haproxy.cfg.j2
dest: /etc/haproxy/haproxy.cfg
owner: root
group: root
mode: 0644
notify: reload haproxy
...
templates/haproxy.cfg.j2:
...
backend refinery
{% for server, value in haproxy_backends.items() %}
server {{ server }} {{ value.ip }}:8080 check
{% endfor %}
...
defaults/main.yml:
...
haproxy_stats: true
haproxy_backends:
refinery01:
ip: 192.168.5.41
refinery02:
ip: 192.168.5.42
...