haproxy.cfg as docker config

This commit is contained in:
Andrea Dell'Amico 2020-12-29 22:20:28 +01:00
parent ef2a73b6c2
commit c988d55de6
2 changed files with 16 additions and 1 deletions

View File

@ -12,6 +12,7 @@ haproxy_docker_container: False
haproxy_docker_version: '{{ haproxy_version }}.6'
haproxy_docker_image: 'haproxytech/haproxy-debian:{{ haproxy_docker_version }}'
haproxy_docker_compose_dir: /srv/haproxy_swarm
haproxy_docker_mount_conf_file: False
# Source volume for the socket
haproxy_docker_socket_dir: /srv/haproxy_s
haproxy_docker_restart_policy: 'on-failure'

View File

@ -4,15 +4,29 @@ networks:
{{ haproxy_docker_overlay_network }}:
external: true
{% if not haproxy_docker_mount_conf_file %}
configs:
haproxy_conf:
file: /etc/haproxy/haproxy.cfg
{% endif %}
services:
haproxy:
image: {{ haproxy_docker_image }}
entrypoint: ["haproxy", "-sf", "350", "-x", "{{ haproxy_admin_socket }}", "-W", "-db", "-f", "/usr/local/etc/haproxy/haproxy.cfg", "-L", "local_haproxy"]
volumes:
- {{ haproxy_cert_dir }}:{{ haproxy_cert_dir }}:ro
- /etc/haproxy:/usr/local/etc/haproxy:ro
- /var/run/docker.sock:/var/run/docker.sock
- {{ haproxy_docker_socket_dir }}:{{ haproxy_admin_socket_dir }}
{% if haproxy_docker_mount_conf_file %}
- /etc/haproxy:/usr/local/etc/haproxy:ro
{% endif %}
{% if not haproxy_docker_mount_conf_file %}
configs:
- source: haproxy_conf
target: /usr/local/etc/haproxy/haproxy.cfg
mode: 0444
{% endif %}
networks:
- {{ haproxy_docker_overlay_network }}
ports: