# TODO - hosts: [{{host}}] sudo: yes vars: config_dir: {src: {{ config_dir['src'] }}, dst: {{ config_dir['dst'] }}} haproxy_ip: {{ ip }} haproxy_services: {% for single in config %} - name: {{ single['name'] }} listen_port: {{ single['listen_port'] }} protocol: {{ single['protocol'] }} servers: {% for backend in single['backends'] %} - name: {{ backend['server'] }}_{{ backend['port'] }} ip: {{ backend['server'] }} port: {{ backend['port'] }} {% endfor %} {% endfor %} tasks: - file: path={{ config_dir['src'] }}/ state=directory - file: path={{ config_dir['src'] }}/haproxy.cfg state=touch - template: src={{templates_dir}}/haproxy.cfg dest=/etc/haproxy/haproxy.cfg