2015-09-17 14:21:17 +02:00

23 lines
814 B
YAML

# 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