From bfc7330703cdf6b1eccffa552a0bf5089df064da Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Mon, 12 Oct 2020 18:48:11 +0200 Subject: [PATCH] The externall network cannot be attached from inside the compose file --- tasks/haproxy-docker-service.yml | 5 +++++ templates/haproxy-docker-stack.yml.j2 | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tasks/haproxy-docker-service.yml b/tasks/haproxy-docker-service.yml index f92bab8..3bd1e62 100644 --- a/tasks/haproxy-docker-service.yml +++ b/tasks/haproxy-docker-service.yml @@ -31,5 +31,10 @@ - '{{ haproxy_docker_compose_dir }}/docker-haproxy-stack.yml' run_once: True + - name: Connect haproxy to the external network + command: docker service update --network-add {{ haproxy_docker_overlay_network }} haproxy_haproxy --update-delay 30s --update-parallelism 1 + run_once: True + ignore_errors: True + when: docker_swarm_manager_main_node is defined and docker_swarm_manager_main_node | bool tags: [ 'haproxy', 'docker_haproxy', 'docker_swarm', 'docker' ] diff --git a/templates/haproxy-docker-stack.yml.j2 b/templates/haproxy-docker-stack.yml.j2 index 14c3177..bca122c 100644 --- a/templates/haproxy-docker-stack.yml.j2 +++ b/templates/haproxy-docker-stack.yml.j2 @@ -7,8 +7,6 @@ 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 }}