Create a overlay network as external, attach to that one

This commit is contained in:
Andrea Dell'Amico 2020-10-12 17:38:01 +02:00
parent d393ca32f7
commit 2418b25e1e
3 changed files with 13 additions and 1 deletions

View File

@ -17,6 +17,12 @@
- 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 overlay network that will be joined by the proxied services
docker_network:
name: '{{ haproxy_docker_overlay_network }}'
driver: overlay
scope: swarm
- name: Run the docker compose file to start the service
docker_stack:
name: haproxy

View File

@ -7,6 +7,8 @@ services:
- {{ haproxy_cert_dir }}:{{ haproxy_cert_dir }}:ro
- /etc/haproxy:/usr/local/etc/haproxy:ro
- /var/run/docker.sock:/var/run/docker.sock
networks:
- {{ haproxy_docker_overlay_network }}
ports:
- target: {{ haproxy_default_port }}
published: {{ haproxy_default_port }}
@ -75,3 +77,7 @@ services:
logging:
driver: 'journald'
{% endif %}
networks:
{{ haproxy_docker_overlay_network }}:
esternal: True

View File

@ -1,2 +1,2 @@
---
# vars file for ansible-role-template
haproxy_docker_overlay_network: 'haproxy-public'