haproxy: mount the docker socket

This commit is contained in:
Andrea Dell'Amico 2020-10-07 17:40:37 +02:00
parent 3f2ba86680
commit 451479c8d3
2 changed files with 11 additions and 6 deletions

View File

@ -1,4 +1,14 @@
---
- name: Manage the composition of haproxy as a docker swarm service
block:
- name: Create the local haproxy configuration directory
file: dest=/etc/haproxy state=directory mode='0755'
- name: Install a bare haproxy configuration if there's none
copy: src=haproxy-sample.cfg dest=/etc/haproxy/haproxy.cfg mode='0644' force=no
tags: [ 'haproxy', 'docker_haproxy', 'docker_swarm', 'docker' ]
- name: Manage the composition of haproxy as a docker swarm service
block:
- name: Create the destination directory of the haproxy docker compose file
@ -7,12 +17,6 @@
- name: Install the docker compose file
template: src=haproxy-docker-stack.yml.j2 dest={{ haproxy_docker_compose_dir }}/docker-haproxy-stack.yml mode='0644'
- name: Create the local haproxy configuration directory
file: dest=/etc/haproxy state=directory mode='0755'
- name: Install a bare haproxy configuration if there's none
copy: src=haproxy-sample.cfg dest=/etc/haproxy/haproxy.cfg mode='0644' force=no
- name: Run the docker compose file to start the service
docker_stack:
name: haproxy

View File

@ -6,6 +6,7 @@ services:
volumes:
- {{ haproxy_cert_dir }}:{{ haproxy_cert_dir }}:ro
- /etc/haproxy:/usr/local/etc/haproxy:ro
- /var/run/docker.sock:/var/run/docker.sock
ports:
- target: {{ haproxy_default_port }}
published: {{ haproxy_default_port }}